Skip to content

Commit

Permalink
Extract method for mangling the base path. Ref #169.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 13, 2022
1 parent 46001cb commit e5a5a9f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions distutils/ccompiler.py
Expand Up @@ -925,8 +925,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 = os.path.splitdrive(base)[1] # Chop off the drive
base = base[os.path.isabs(base) :] # If abs, chop off leading /
base = self._mangle_base(base)
if ext not in self.src_extensions:
raise UnknownFileError(
"unknown file type '{}' (from '{}')".format(ext, src_name)
Expand All @@ -936,6 +935,16 @@ def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
obj_names.append(os.path.join(output_dir, base + self.obj_extension))
return obj_names

@staticmethod
def _mangle_base(base):
"""
For unknown reasons, absolute paths are mangled.
"""
# Chop off the drive
no_drive = os.path.splitdrive(base)[1]
# If abs, chop off leading /
return no_drive[os.path.isabs(no_drive) :]

def shared_object_filename(self, basename, strip_dir=0, output_dir=''):
assert output_dir is not None
if strip_dir:
Expand Down

0 comments on commit e5a5a9f

Please sign in to comment.