diff --git a/distutils/ccompiler.py b/distutils/ccompiler.py index 3cf5761c..8c9b1d48 100644 --- a/distutils/ccompiler.py +++ b/distutils/ccompiler.py @@ -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) @@ -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: