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]