@@ -111,6 +111,24 @@ def _looks_like_red_hat_scheme() -> bool:
111
111
)
112
112
113
113
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
+
114
132
def _fix_abiflags (parts : Tuple [str ]) -> Iterator [str ]:
115
133
ldversion = sysconfig .get_config_var ("LDVERSION" )
116
134
abiflags : str = getattr (sys , "abiflags" , None )
@@ -270,6 +288,14 @@ def get_scheme(
270
288
if skip_sysconfig_abiflag_bug :
271
289
continue
272
290
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
+
273
299
warning_contexts .append ((old_v , new_v , f"scheme.{ k } " ))
274
300
275
301
if not warning_contexts :
0 commit comments