Skip to content

Commit

Permalink
Refactor for simplicity.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 4, 2025
1 parent ede1af2 commit 36ce8b3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,14 +983,13 @@ def _make_out_path_exts(cls, output_dir, strip_dir, src_name, extensions):
>>> CCompiler._make_out_path_exts('.', True, '/foo/bar.c', exts).replace('\\', '/')
'./bar.o'
"""
base, ext = os.path.splitext(src_name)
base = pathlib.PurePath(base)
src = pathlib.PurePath(src_name)
# Ensure base is relative to honor output_dir (python/cpython#37775).
base = cls._make_relative(base)
base = cls._make_relative(src)
try:
new_ext = extensions[ext]
new_ext = extensions[src.suffix]
except LookupError:
raise UnknownFileError(f"unknown file type '{ext}' (from '{src_name}')")
raise UnknownFileError(f"unknown file type '{src.suffix}' (from '{src}')")
if strip_dir:
base = pathlib.PurePath(base.name)
return os.path.join(output_dir, base.with_suffix(new_ext))
Expand Down

0 comments on commit 36ce8b3

Please sign in to comment.