@@ -298,10 +298,29 @@ def get_bin_user() -> str:
298
298
return _sysconfig .get_scheme ("" , user = True ).scripts
299
299
300
300
301
+ def _looks_like_deb_system_dist_packages (value : str ) -> bool :
302
+ """Check if the value is Debian's APT-controlled dist-packages.
303
+
304
+ Debian's ``distutils.sysconfig.get_python_lib()`` implementation returns the
305
+ default package path controlled by APT, but does not patch ``sysconfig`` to
306
+ do the same. This is similar to the bug worked around in ``get_scheme()``,
307
+ but here the default is ``deb_system`` instead of ``unix_local``. Ultimately
308
+ we can't do anything about this Debian bug, and this detection allows us to
309
+ skip the warning when needed.
310
+ """
311
+ if not _looks_like_debian_patched ():
312
+ return False
313
+ if value == "/usr/lib/python3/dist-packages" :
314
+ return True
315
+ return False
316
+
317
+
301
318
def get_purelib () -> str :
302
319
"""Return the default pure-Python lib location."""
303
320
old = _distutils .get_purelib ()
304
321
new = _sysconfig .get_purelib ()
322
+ if _looks_like_deb_system_dist_packages (old ):
323
+ return old
305
324
if _warn_if_mismatch (pathlib .Path (old ), pathlib .Path (new ), key = "purelib" ):
306
325
_log_context ()
307
326
return old
@@ -311,6 +330,8 @@ def get_platlib() -> str:
311
330
"""Return the default platform-shared lib location."""
312
331
old = _distutils .get_platlib ()
313
332
new = _sysconfig .get_platlib ()
333
+ if _looks_like_deb_system_dist_packages (old ):
334
+ return old
314
335
if _warn_if_mismatch (pathlib .Path (old ), pathlib .Path (new ), key = "platlib" ):
315
336
_log_context ()
316
337
return old
0 commit comments