Skip to content

Commit

Permalink
Fix issue with absolute path with Python 3.13 on Windows
Browse files Browse the repository at this point in the history
With Python 3.13 on Windows, `os.path.isabs()` no longer returns `True`
for a path that starts with a slash. Thus, when the argument to
`_make_relative()` is an absolute path, the return value starts with a
slash on Python 3.13 and does not start with a slash on older Python
versions. This causes the extension module build directory to be
calculated incorrectly with Python 3.13 on Windows.

Fix this by ensuring that the return value does not start with a slash.
  • Loading branch information
adang1345 committed Oct 21, 2024
1 parent 378984e commit 464735f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,8 @@ def _make_relative(base):
# Chop off the drive
no_drive = os.path.splitdrive(base)[1]
# If abs, chop off leading /
return no_drive[os.path.isabs(no_drive) :]
is_abs = os.path.isabs(no_drive) or sys.platform == 'win32' and (no_drive.startswith('/') or no_drive.startswith('\\'))
return no_drive[is_abs:]

def shared_object_filename(self, basename, strip_dir=False, output_dir=''):
assert output_dir is not None
Expand Down

0 comments on commit 464735f

Please sign in to comment.