Skip to content

Commit 0d57982

Browse files
committed
More workaround for Debian's faulty sysconfig
1 parent 6468908 commit 0d57982

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/pip/_internal/locations/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,29 @@ def get_bin_user() -> str:
277277
return _sysconfig.get_scheme("", user=True).scripts
278278

279279

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+
280297
def get_purelib() -> str:
281298
"""Return the default pure-Python lib location."""
282299
old = _distutils.get_purelib()
283300
new = _sysconfig.get_purelib()
301+
if _looks_like_deb_system_dist_packages(old):
302+
return old
284303
if _warn_if_mismatch(pathlib.Path(old), pathlib.Path(new), key="purelib"):
285304
_log_context()
286305
return old
@@ -290,6 +309,8 @@ def get_platlib() -> str:
290309
"""Return the default platform-shared lib location."""
291310
old = _distutils.get_platlib()
292311
new = _sysconfig.get_platlib()
312+
if _looks_like_deb_system_dist_packages(old):
313+
return old
293314
if _warn_if_mismatch(pathlib.Path(old), pathlib.Path(new), key="platlib"):
294315
_log_context()
295316
return old

0 commit comments

Comments
 (0)