From 725b75f39a057caa029f7f14ed568b0691692c67 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Sun, 1 Aug 2021 15:46:43 +0800 Subject: [PATCH] Try to make distutils not emit relative paths --- src/pip/_internal/locations/__init__.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/pip/_internal/locations/__init__.py b/src/pip/_internal/locations/__init__.py index be18f21bb58..062a9effd00 100644 --- a/src/pip/_internal/locations/__init__.py +++ b/src/pip/_internal/locations/__init__.py @@ -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" @@ -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, @@ -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: