Merge pull request #5604 from nehaljwani/generic_was_installed

Make pip_installed_by_pip() more generic
This commit is contained in:
Pradyun Gedam 2018-07-16 12:12:42 +05:30 committed by GitHub
commit cff2367bf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -58,14 +58,14 @@ class SelfCheckState(object):
separators=(",", ":"))
def pip_installed_by_pip():
"""Checks whether pip was installed by pip
def was_installed_by_pip(pkg):
"""Checks whether pkg was installed by pip
This is used not to display the upgrade message when pip is in fact
installed by system package manager, such as dnf on Fedora.
"""
try:
dist = pkg_resources.get_distribution('pip')
dist = pkg_resources.get_distribution(pkg)
return (dist.has_metadata('INSTALLER') and
'pip' in dist.get_metadata_lines('INSTALLER'))
except pkg_resources.DistributionNotFound:
@ -125,7 +125,7 @@ def pip_version_check(session, options):
# Determine if our pypi_version is older
if (pip_version < remote_version and
pip_version.base_version != remote_version.base_version and
pip_installed_by_pip()):
was_installed_by_pip('pip')):
# Advise "python -m pip" on Windows to avoid issues
# with overwriting pip.exe.
if WINDOWS: