Skip to content

Commit

Permalink
Merge pull request #10840 from uranusjr/disable-location-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg authored Jan 29, 2022
2 parents 649048b + 698ccec commit 448f8b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
3 changes: 3 additions & 0 deletions news/10840.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Disable location mismatch warnings on Python versions prior to 3.10 since we
have completed the transition and no longer need to rely on reports from older
Python versions.
25 changes: 15 additions & 10 deletions src/pip/_internal/locations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,35 @@

logger = logging.getLogger(__name__)

if os.environ.get("_PIP_LOCATIONS_NO_WARN_ON_MISMATCH"):
_MISMATCH_LEVEL = logging.DEBUG
else:
_MISMATCH_LEVEL = logging.WARNING

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

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


def _should_use_sysconfig() -> bool:
"""
This function determines the value of _USE_SYSCONFIG.
"""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
This is a function for testability, but should be constant during any one
run.
"""
if hasattr(sysconfig, "_PIP_USE_SYSCONFIG"):
return bool(sysconfig._PIP_USE_SYSCONFIG) # type: ignore [attr-defined]
return sys.version_info >= (3, 10)
return bool(getattr(sysconfig, "_PIP_USE_SYSCONFIG", _USE_SYSCONFIG_DEFAULT))


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

# Be noisy about incompatibilities if this platforms "should" be using
# sysconfig, but is explicitly opting out and using distutils instead.
if _USE_SYSCONFIG_DEFAULT and not _USE_SYSCONFIG:
_MISMATCH_LEVEL = logging.WARNING
else:
_MISMATCH_LEVEL = logging.DEBUG


def _looks_like_bpo_44860() -> bool:
"""The resolution to bpo-44860 will change this incorrect platlib.
Expand Down

0 comments on commit 448f8b7

Please sign in to comment.