Skip to content

Commit

Permalink
Use 'resolve' instead of 'abspath'
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Aug 10, 2023
1 parent 973f7f4 commit 87d5e9c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions setuptools/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,13 @@ def get_source_files(self) -> List[str]:

def _get_internal_depends(self) -> Iterator[str]:
"""Yield ``ext.depends`` that are contained by the project directory"""
project_root = os.path.abspath(self.distribution.src_root or os.curdir)
project_root = Path(self.distribution.src_root or os.curdir).resolve()
depends = (dep for ext in self.extensions for dep in ext.depends)
for dep in depends:
try:
path = os.path.abspath(os.path.join(project_root, dep))
# if dep is absolute, os.path.join will ignore project_root
rel_path = Path(path).relative_to(project_root)
assert ".." not in rel_path.parts # abspath should take care of that
yield rel_path.as_posix() # POSIX-style relative paths
abs_path = (project_root / dep).resolve()
# if dep is absolute, Path will ignore project_root
yield abs_path.relative_to(project_root).as_posix()
except ValueError:
log.warn(f"ignoring {dep} for distribution: outside of project dir")

Expand Down

0 comments on commit 87d5e9c

Please sign in to comment.