mirror of https://github.com/pypa/pip
Simplify was_installed_by_pip() (#6616)
This uses `get_installer()` to reduce code duplication.
This commit is contained in:
commit
82284073e7
|
@ -0,0 +1 @@
|
|||
Override the definition of the function was_installed_by_pip (src\pip\_internal\utils\outdated.py) too specific with a more general alternative
|
|
@ -13,6 +13,7 @@ from pip._internal.index import PackageFinder
|
|||
from pip._internal.utils.compat import WINDOWS
|
||||
from pip._internal.utils.filesystem import check_path_owner
|
||||
from pip._internal.utils.misc import ensure_dir, get_installed_version
|
||||
from pip._internal.utils.packaging import get_installer
|
||||
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
||||
|
||||
if MYPY_CHECK_RUNNING:
|
||||
|
@ -85,8 +86,7 @@ def was_installed_by_pip(pkg):
|
|||
"""
|
||||
try:
|
||||
dist = pkg_resources.get_distribution(pkg)
|
||||
return (dist.has_metadata('INSTALLER') and
|
||||
'pip' in dist.get_metadata_lines('INSTALLER'))
|
||||
return "pip" == get_installer(dist)
|
||||
except pkg_resources.DistributionNotFound:
|
||||
return False
|
||||
|
||||
|
|
Loading…
Reference in New Issue