Skip to content

Commit 346bba7

Browse files
authored
Merge pull request #10290 from uranusjr/locations-skip-mingw-wrong-lib
Ignore warning on MSYS MINGW's incorrect sysconfig
2 parents aaaaf4b + 79d2a98 commit 346bba7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/pip/_internal/locations/__init__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@ def _looks_like_red_hat_scheme() -> bool:
111111
)
112112

113113

114+
@functools.lru_cache(maxsize=None)
115+
def _looks_like_msys2_mingw_scheme() -> bool:
116+
"""MSYS2 patches distutils and sysconfig to use a UNIX-like scheme.
117+
118+
However, MSYS2 incorrectly patches sysconfig ``nt`` scheme. The fix is
119+
likely going to be included in their 3.10 release, so we ignore the warning.
120+
See msys2/MINGW-packages#9319.
121+
122+
MSYS2 MINGW's patch uses lowercase ``"lib"`` instead of the usual uppercase,
123+
and is missing the final ``"site-packages"``.
124+
"""
125+
paths = sysconfig.get_paths("nt", expand=False)
126+
return all(
127+
"Lib" not in p and "lib" in p and not p.endswith("site-packages")
128+
for p in (paths[key] for key in ("platlib", "purelib"))
129+
)
130+
131+
114132
def _fix_abiflags(parts: Tuple[str]) -> Iterator[str]:
115133
ldversion = sysconfig.get_config_var("LDVERSION")
116134
abiflags: str = getattr(sys, "abiflags", None)
@@ -270,6 +288,14 @@ def get_scheme(
270288
if skip_sysconfig_abiflag_bug:
271289
continue
272290

291+
# MSYS2 MINGW's sysconfig patch does not include the "site-packages"
292+
# part of the path. This is incorrect and will be fixed in MSYS.
293+
skip_msys2_mingw_bug = (
294+
WINDOWS and k in ("platlib", "purelib") and _looks_like_msys2_mingw_scheme()
295+
)
296+
if skip_msys2_mingw_bug:
297+
continue
298+
273299
warning_contexts.append((old_v, new_v, f"scheme.{k}"))
274300

275301
if not warning_contexts:

0 commit comments

Comments
 (0)