diff --git a/newsfragments/4669.bugfix.rst b/newsfragments/4669.bugfix.rst new file mode 100644 index 0000000000..25bc4cfae7 --- /dev/null +++ b/newsfragments/4669.bugfix.rst @@ -0,0 +1 @@ +Fix an issue with Python 3.13 on Windows where specifying the absolute path to an extension module source file would cause the build files to be written to the directory containing the source file. diff --git a/setuptools/_distutils/ccompiler.py b/setuptools/_distutils/ccompiler.py index 5e73e56d02..fdbb1ca795 100644 --- a/setuptools/_distutils/ccompiler.py +++ b/setuptools/_distutils/ccompiler.py @@ -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