Skip to content

Commit a51faf4

Browse files
committed
Special-case PyPy's lib location differences
1 parent 826234e commit a51faf4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/pip/_internal/locations/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import pathlib
3+
import sys
34
import sysconfig
45
from typing import List, Optional
56

@@ -99,6 +100,21 @@ def get_scheme(
99100
# Extra join because distutils can return relative paths.
100101
old_v = pathlib.Path(base, getattr(old, k))
101102
new_v = pathlib.Path(getattr(new, k))
103+
104+
# distutils incorrectly put PyPy packages under ``site-packages/python``
105+
# in the ``posix_home`` scheme, but PyPy devs said they expect the
106+
# directory name to be ``pypy`` instead. So we treat this as a bug fix
107+
# and not warn about it. See bpo-43307 and python/cpython#24628.
108+
skip_pypy_special_case = (
109+
sys.implementation.name == "pypy"
110+
and home is not None
111+
and k in ("platlib", "purelib")
112+
and old_v.parent == new_v.parent
113+
and old_v.name == "python" and new_v.name == "pypy"
114+
)
115+
if skip_pypy_special_case:
116+
continue
117+
102118
warned.append(_warn_if_mismatch(old_v, new_v, key=f"scheme.{k}"))
103119

104120
if any(warned):

0 commit comments

Comments
 (0)