mirror of https://github.com/pypa/pip
Make pip_installed_by_pip() more generic
This commit is contained in:
parent
067dd8c2c4
commit
96f9fcc4a0
|
@ -58,14 +58,14 @@ class SelfCheckState(object):
|
||||||
separators=(",", ":"))
|
separators=(",", ":"))
|
||||||
|
|
||||||
|
|
||||||
def pip_installed_by_pip():
|
def was_installed_by_pip(pkg):
|
||||||
"""Checks whether pip was installed by pip
|
"""Checks whether pkg was installed by pip
|
||||||
|
|
||||||
This is used not to display the upgrade message when pip is in fact
|
This is used not to display the upgrade message when pip is in fact
|
||||||
installed by system package manager, such as dnf on Fedora.
|
installed by system package manager, such as dnf on Fedora.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
dist = pkg_resources.get_distribution('pip')
|
dist = pkg_resources.get_distribution(pkg)
|
||||||
return (dist.has_metadata('INSTALLER') and
|
return (dist.has_metadata('INSTALLER') and
|
||||||
'pip' in dist.get_metadata_lines('INSTALLER'))
|
'pip' in dist.get_metadata_lines('INSTALLER'))
|
||||||
except pkg_resources.DistributionNotFound:
|
except pkg_resources.DistributionNotFound:
|
||||||
|
@ -125,7 +125,7 @@ def pip_version_check(session, options):
|
||||||
# Determine if our pypi_version is older
|
# Determine if our pypi_version is older
|
||||||
if (pip_version < remote_version and
|
if (pip_version < remote_version and
|
||||||
pip_version.base_version != remote_version.base_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
|
# Advise "python -m pip" on Windows to avoid issues
|
||||||
# with overwriting pip.exe.
|
# with overwriting pip.exe.
|
||||||
if WINDOWS:
|
if WINDOWS:
|
||||||
|
|
Loading…
Reference in New Issue