Skip to content

Commit

Permalink
Try to make distutils not emit relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Aug 1, 2021
1 parent 6468908 commit 725b75f
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/pip/_internal/locations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,6 @@ def _fix_abiflags(parts: Tuple[str]) -> Iterator[str]:
yield part


def _default_base(*, user: bool) -> str:
if user:
base = sysconfig.get_config_var("userbase")
else:
base = sysconfig.get_config_var("base")
assert base is not None
return base


@functools.lru_cache(maxsize=None)
def _warn_mismatched(old: pathlib.Path, new: pathlib.Path, *, key: str) -> None:
issue_url = "https://github.com/pypa/pip/issues/10151"
Expand Down Expand Up @@ -144,6 +135,13 @@ def get_scheme(
isolated: bool = False,
prefix: Optional[str] = None,
) -> Scheme:
if home is not None and not os.path.isabs(home):
home = os.path.join(os.getcwd(), home)
if root is not None and not os.path.isabs(root):
root = os.path.join(os.getcwd(), root)
if prefix is not None and not os.path.isabs(prefix):
prefix = os.path.join(os.getcwd(), prefix)

old = _distutils.get_scheme(
dist_name,
user=user,
Expand All @@ -161,11 +159,9 @@ def get_scheme(
prefix=prefix,
)

base = prefix or home or _default_base(user=user)
warning_contexts = []
for k in SCHEME_KEYS:
# Extra join because distutils can return relative paths.
old_v = pathlib.Path(base, getattr(old, k))
old_v = pathlib.Path(getattr(old, k))
new_v = pathlib.Path(getattr(new, k))

if old_v == new_v:
Expand Down

0 comments on commit 725b75f

Please sign in to comment.