Skip to content

Commit 607a9de

Browse files
committed
Allow to decide whether to use distutils or sysconfig with sysconfig._PIP_USE_SYSCONFIG
Fixes #10647
1 parent 4cdb516 commit 607a9de

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/pip/_internal/locations/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,20 @@
4545

4646
_PLATLIBDIR: str = getattr(sys, "platlibdir", "lib")
4747

48-
_USE_SYSCONFIG = sys.version_info >= (3, 10)
48+
49+
def _should_use_sysconfig() -> bool:
50+
"""
51+
This function determines the value of _USE_SYSCONFIG.
52+
By default, pip uses sysconfig on Python 3.10+.
53+
But Python distributors can override this decision by setting:
54+
sysconfig._PIP_USE_SYSCONFIG = True / False
55+
Rationale in https://github.com/pypa/pip/issues/10647
56+
"""
57+
return bool(getattr(sysconfig, "_PIP_USE_SYSCONFIG", sys.version_info >= (3, 10)))
58+
59+
60+
# This is a function for testability, but should be constant during any one run.
61+
_USE_SYSCONFIG = _should_use_sysconfig()
4962

5063

5164
def _looks_like_bpo_44860() -> bool:

0 commit comments

Comments
 (0)