From ca50cea929c137f2adcc694d4d6a43c4d8ada3d7 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Thu, 23 Sep 2021 05:30:00 +0800 Subject: [PATCH] Kill location warning for Python in source tree --- src/pip/_internal/locations/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/pip/_internal/locations/__init__.py b/src/pip/_internal/locations/__init__.py index 7d5491d20ad..dba182d7578 100644 --- a/src/pip/_internal/locations/__init__.py +++ b/src/pip/_internal/locations/__init__.py @@ -303,6 +303,18 @@ def get_scheme( if skip_msys2_mingw_bug: continue + # CPython's POSIX install script invokes pip (via ensurepip) against the + # interpreter located in the source tree, not the install site. This + # triggers special logic in sysconfig that's not present in distutils. + # https://github.com/python/cpython/blob/8c21941ddaf/Lib/sysconfig.py#L178-L194 + skip_cpython_build = ( + sysconfig.is_python_build(check_home=True) + and not WINDOWS + and k in ("headers", "include", "platinclude") + ) + if skip_cpython_build: + continue + warning_contexts.append((old_v, new_v, f"scheme.{k}")) if not warning_contexts: