Skip to content

Commit 464735f

Browse files
committed
Fix issue with absolute path with Python 3.13 on Windows
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.
1 parent 378984e commit 464735f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

distutils/ccompiler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,8 @@ def _make_relative(base):
989989
# Chop off the drive
990990
no_drive = os.path.splitdrive(base)[1]
991991
# If abs, chop off leading /
992-
return no_drive[os.path.isabs(no_drive) :]
992+
is_abs = os.path.isabs(no_drive) or sys.platform == 'win32' and (no_drive.startswith('/') or no_drive.startswith('\\'))
993+
return no_drive[is_abs:]
993994

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

0 commit comments

Comments
 (0)