This repository has been archived by the owner on Nov 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When pip is run outside of venv, don't show the upgrade warning
This is a fix for https://bugzilla.redhat.com/show_bug.cgi?id=1573755 1. We put "rpm" inside pip's INSTALLER instead of "pip" 2. From pip, we check what's in INSTALLER and only show the warning if it's "pip". When a venv is cearted, pip is installed from wheel (trough rewheel), INSTALLER contains "pip". When virtualenv is used, pip is installed from the Interwebz via pip, so INSTALLER contains "pip". Upstream issue pypa/pip#5346
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
diff --git a/pip/utils/outdated.py b/pip/utils/outdated.py | ||
index 2164cc3..c71539f 100644 | ||
--- a/pip/utils/outdated.py | ||
+++ b/pip/utils/outdated.py | ||
@@ -92,6 +92,21 @@ def load_selfcheck_statefile(): | ||
return GlobalSelfCheckState() | ||
|
||
|
||
+def pip_installed_by_pip(): | ||
+ """Checks whether pip 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. | ||
+ """ | ||
+ import pkg_resources | ||
+ try: | ||
+ dist = pkg_resources.get_distribution('pip') | ||
+ return (dist.has_metadata('INSTALLER') and | ||
+ 'pip' in dist.get_metadata_lines('INSTALLER')) | ||
+ except pkg_resources.DistributionNotFound: | ||
+ return False | ||
+ | ||
+ | ||
def pip_version_check(session): | ||
"""Check for an update for pip. | ||
|
||
@@ -141,7 +156,8 @@ def pip_version_check(session): | ||
|
||
# Determine if our pypi_version is older | ||
if (pip_version < remote_version and | ||
- pip_version.base_version != remote_version.base_version): | ||
+ pip_version.base_version != remote_version.base_version and | ||
+ pip_installed_by_pip()): | ||
# Advise "python -m pip" on Windows to avoid issues | ||
# with overwriting pip.exe. | ||
if WINDOWS: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters