Skip to content

Commit

Permalink
Allow to decide whether to use distutils or sysconfig with sysconfig.…
Browse files Browse the repository at this point in the history
…_PIP_USE_SYSCONFIG

Fixes pypa#10647
  • Loading branch information
hroncok committed Nov 19, 2021
1 parent 4cdb516 commit 607a9de
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pip/_internal/locations/__init__.py
Expand Up @@ -45,7 +45,20 @@

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

_USE_SYSCONFIG = sys.version_info >= (3, 10)

def _should_use_sysconfig() -> bool:
"""
This function determines the value of _USE_SYSCONFIG.
By default, pip uses sysconfig on Python 3.10+.
But Python distributors can override this decision by setting:
sysconfig._PIP_USE_SYSCONFIG = True / False
Rationale in https://github.com/pypa/pip/issues/10647
"""
return bool(getattr(sysconfig, "_PIP_USE_SYSCONFIG", sys.version_info >= (3, 10)))


# This is a function for testability, but should be constant during any one run.
_USE_SYSCONFIG = _should_use_sysconfig()


def _looks_like_bpo_44860() -> bool:
Expand Down

0 comments on commit 607a9de

Please sign in to comment.