|
43 | 43 | else:
|
44 | 44 | _MISMATCH_LEVEL = logging.WARNING
|
45 | 45 |
|
| 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 | + |
46 | 62 |
|
47 | 63 | def _looks_like_red_hat_patched_platlib_purelib(scheme: Dict[str, str]) -> bool:
|
48 | 64 | platlib = scheme["platlib"]
|
@@ -214,6 +230,21 @@ def get_scheme(
|
214 | 230 | if k == "platlib" and _looks_like_red_hat_lib():
|
215 | 231 | continue
|
216 | 232 |
|
| 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 | + |
217 | 248 | # Both Debian and Red Hat patch Python to place the system site under
|
218 | 249 | # /usr/local instead of /usr. Debian also places lib in dist-packages
|
219 | 250 | # instead of site-packages, but the /usr/local check should cover it.
|
|
0 commit comments