@@ -277,10 +277,29 @@ def get_bin_user() -> str:
277
277
return _sysconfig .get_scheme ("" , user = True ).scripts
278
278
279
279
280
+ def _looks_like_deb_system_dist_packages (value : str ) -> bool :
281
+ """Check if the value is Debian's APT-controlled dist-packages.
282
+
283
+ Debian's ``distutils.sysconfig.get_python_lib()`` implementation returns the
284
+ default package path controlled by APT, but does not patch ``sysconfig`` to
285
+ do the same. This is similar to the bug worked around in ``get_scheme()``,
286
+ but here the default is ``deb_system`` instead of ``unix_local``. Ultimately
287
+ we can't do anything about this Debian bug, and this detection allows us to
288
+ skip the warning when needed.
289
+ """
290
+ if not _looks_like_debian_patched ():
291
+ return False
292
+ if value == "/usr/lib/python3/dist-packages" :
293
+ return True
294
+ return False
295
+
296
+
280
297
def get_purelib () -> str :
281
298
"""Return the default pure-Python lib location."""
282
299
old = _distutils .get_purelib ()
283
300
new = _sysconfig .get_purelib ()
301
+ if _looks_like_deb_system_dist_packages (old ):
302
+ return old
284
303
if _warn_if_mismatch (pathlib .Path (old ), pathlib .Path (new ), key = "purelib" ):
285
304
_log_context ()
286
305
return old
@@ -290,6 +309,8 @@ def get_platlib() -> str:
290
309
"""Return the default platform-shared lib location."""
291
310
old = _distutils .get_platlib ()
292
311
new = _sysconfig .get_platlib ()
312
+ if _looks_like_deb_system_dist_packages (old ):
313
+ return old
293
314
if _warn_if_mismatch (pathlib .Path (old ), pathlib .Path (new ), key = "platlib" ):
294
315
_log_context ()
295
316
return old
0 commit comments