From ea04533962eb5ac86630b9cc65e4a5d5c6cfef55 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 21 Aug 2022 13:28:05 -0400 Subject: [PATCH] Rename _mangle_base to _make_relative and add documentation about its purpose. Ref pypa/distutils#169. --- conftest.py | 2 +- distutils/ccompiler.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/conftest.py b/conftest.py index feac1b60..018e1075 100644 --- a/conftest.py +++ b/conftest.py @@ -154,5 +154,5 @@ def suppress_path_mangle(monkeysession): from distutils import ccompiler monkeysession.setattr( - ccompiler.CCompiler, '_mangle_base', staticmethod(lambda x: x) + ccompiler.CCompiler, '_make_relative', staticmethod(lambda x: x) ) diff --git a/distutils/ccompiler.py b/distutils/ccompiler.py index c8d3b24b..6b168792 100644 --- a/distutils/ccompiler.py +++ b/distutils/ccompiler.py @@ -927,7 +927,7 @@ def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): obj_names = [] for src_name in source_filenames: base, ext = os.path.splitext(src_name) - base = self._mangle_base(base) + base = self._make_relative(base) if ext not in self.src_extensions: raise UnknownFileError( "unknown file type '{}' (from '{}')".format(ext, src_name) @@ -938,9 +938,11 @@ def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): return obj_names @staticmethod - def _mangle_base(base): + def _make_relative(base): """ - For unknown reasons, absolute paths are mangled. + In order to ensure that a filename always honors the + indicated output_dir, make sure it's relative. + Ref python/cpython#37775. """ # Chop off the drive no_drive = os.path.splitdrive(base)[1]