Skip to content

Commit aaaaf4b

Browse files
authored
Merge pull request #10286 from uranusjr/locations-skip-bpo-44860
Suppress location warning caused by bpo-44860
2 parents 7e7c10a + 2e416b0 commit aaaaf4b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/pip/_internal/locations/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@
4343
else:
4444
_MISMATCH_LEVEL = logging.WARNING
4545

46+
_PLATLIBDIR: str = getattr(sys, "platlibdir", "lib")
47+
48+
49+
def _looks_like_bpo_44860() -> bool:
50+
"""The resolution to bpo-44860 will change this incorrect platlib.
51+
52+
See <https://bugs.python.org/issue44860>.
53+
"""
54+
from distutils.command.install import INSTALL_SCHEMES # type: ignore
55+
56+
try:
57+
unix_user_platlib = INSTALL_SCHEMES["unix_user"]["platlib"]
58+
except KeyError:
59+
return False
60+
return unix_user_platlib == "$usersite"
61+
4662

4763
def _looks_like_red_hat_patched_platlib_purelib(scheme: Dict[str, str]) -> bool:
4864
platlib = scheme["platlib"]
@@ -214,6 +230,21 @@ def get_scheme(
214230
if k == "platlib" and _looks_like_red_hat_lib():
215231
continue
216232

233+
# On Python 3.9+, sysconfig's posix_user scheme sets platlib against
234+
# sys.platlibdir, but distutils's unix_user incorrectly coninutes
235+
# using the same $usersite for both platlib and purelib. This creates a
236+
# mismatch when sys.platlibdir is not "lib".
237+
skip_bpo_44860 = (
238+
user
239+
and k == "platlib"
240+
and not WINDOWS
241+
and sys.version_info >= (3, 9)
242+
and _PLATLIBDIR != "lib"
243+
and _looks_like_bpo_44860()
244+
)
245+
if skip_bpo_44860:
246+
continue
247+
217248
# Both Debian and Red Hat patch Python to place the system site under
218249
# /usr/local instead of /usr. Debian also places lib in dist-packages
219250
# instead of site-packages, but the /usr/local check should cover it.

0 commit comments

Comments
 (0)