From def698ecad8fd6f0ff212126a0fba18cd5a4d28a Mon Sep 17 00:00:00 2001 From: Aohan Dang Date: Mon, 7 Oct 2024 09:41:02 -0400 Subject: [PATCH] Fix issue with absolute path with Python 3.13 on Windows Fix #4669 --- newsfragments/4669.bugfix.rst | 1 + setuptools/_distutils/ccompiler.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 newsfragments/4669.bugfix.rst 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