Skip to content

Commit

Permalink
Suppress location warning caused by bpo-44860
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Aug 12, 2021
1 parent e959020 commit c1316c1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/pip/_internal/locations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@
else:
_MISMATCH_LEVEL = logging.WARNING

_PLATLIBDIR: str = getattr(sys, "platlibdir", "lib")


def _looks_like_bpo_44860() -> bool:
"""The resolution to bpo-44860 will change this incorrect platlib.
See <https://bugs.python.org/issue44860>.
"""
from distutils.command.install import INSTALL_SCHEMES # type: ignore

try:
unix_user_platlib = INSTALL_SCHEMES["unix_user"]["platlib"]
except KeyError:
return False
return unix_user_platlib == "$usersite"


def _looks_like_red_hat_patched_platlib_purelib(scheme: Dict[str, str]) -> bool:
platlib = scheme["platlib"]
Expand Down Expand Up @@ -214,6 +230,21 @@ def get_scheme(
if k == "platlib" and _looks_like_red_hat_lib():
continue

# On Python 3.9+, sysconfig's posix_user scheme sets platlib against
# sys.platlibdir, but distutils's unix_user incorrectly coninutes
# using the same $usersite for both platlib and purelib. This creates a
# mismatch when sys.platlibdir is not "lib".
skip_bpo_44860 = (
user
and k == "platlib"
and not WINDOWS
and sys.version_info >= (3, 9)
and _PLATLIBDIR != "lib"
and _looks_like_bpo_44860()
)
if skip_bpo_44860:
continue

# Both Debian and Red Hat patch Python to place the system site under
# /usr/local instead of /usr. Debian also places lib in dist-packages
# instead of site-packages, but the /usr/local check should cover it.
Expand Down

0 comments on commit c1316c1

Please sign in to comment.