Skip to content

Commit 79d2a98

Browse files
committed
Ignore warning on MSYS MINGW's incorrect sysconfig
1 parent d3a78eb commit 79d2a98

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
@@ -95,6 +95,24 @@ def _looks_like_red_hat_scheme() -> bool:
9595
)
9696

9797

98+
@functools.lru_cache(maxsize=None)
99+
def _looks_like_msys2_mingw_scheme() -> bool:
100+
"""MSYS2 patches distutils and sysconfig to use a UNIX-like scheme.
101+
102+
However, MSYS2 incorrectly patches sysconfig ``nt`` scheme. The fix is
103+
likely going to be included in their 3.10 release, so we ignore the warning.
104+
See msys2/MINGW-packages#9319.
105+
106+
MSYS2 MINGW's patch uses lowercase ``"lib"`` instead of the usual uppercase,
107+
and is missing the final ``"site-packages"``.
108+
"""
109+
paths = sysconfig.get_paths("nt", expand=False)
110+
return all(
111+
"Lib" not in p and "lib" in p and not p.endswith("site-packages")
112+
for p in (paths[key] for key in ("platlib", "purelib"))
113+
)
114+
115+
98116
def _fix_abiflags(parts: Tuple[str]) -> Iterator[str]:
99117
ldversion = sysconfig.get_config_var("LDVERSION")
100118
abiflags: str = getattr(sys, "abiflags", None)
@@ -239,6 +257,14 @@ def get_scheme(
239257
if skip_sysconfig_abiflag_bug:
240258
continue
241259

260+
# MSYS2 MINGW's sysconfig patch does not include the "site-packages"
261+
# part of the path. This is incorrect and will be fixed in MSYS.
262+
skip_msys2_mingw_bug = (
263+
WINDOWS and k in ("platlib", "purelib") and _looks_like_msys2_mingw_scheme()
264+
)
265+
if skip_msys2_mingw_bug:
266+
continue
267+
242268
warning_contexts.append((old_v, new_v, f"scheme.{k}"))
243269

244270
if not warning_contexts:

0 commit comments

Comments
 (0)