Skip to content

Commit

Permalink
Rename _mangle_base to _make_relative and add documentation about its…
Browse files Browse the repository at this point in the history
… purpose. Ref #169.
  • Loading branch information
jaraco committed Aug 21, 2022
1 parent 9c4dc49 commit ea04533
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
8 changes: 5 additions & 3 deletions distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand Down

0 comments on commit ea04533

Please sign in to comment.