@@ -95,6 +95,24 @@ def _looks_like_red_hat_scheme() -> bool:
95
95
)
96
96
97
97
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
+
98
116
def _fix_abiflags (parts : Tuple [str ]) -> Iterator [str ]:
99
117
ldversion = sysconfig .get_config_var ("LDVERSION" )
100
118
abiflags : str = getattr (sys , "abiflags" , None )
@@ -239,6 +257,14 @@ def get_scheme(
239
257
if skip_sysconfig_abiflag_bug :
240
258
continue
241
259
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
+
242
268
warning_contexts .append ((old_v , new_v , f"scheme.{ k } " ))
243
269
244
270
if not warning_contexts :
0 commit comments