Skip to content
This repository was archived by the owner on Nov 6, 2024. It is now read-only.

Commit 4b288bd

Browse files
committed
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
1 parent d02d7aa commit 4b288bd

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

pip-nowarn-upgrade.patch

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
diff --git a/pip/utils/outdated.py b/pip/utils/outdated.py
2+
index 2164cc3..c71539f 100644
3+
--- a/pip/utils/outdated.py
4+
+++ b/pip/utils/outdated.py
5+
@@ -92,6 +92,21 @@ def load_selfcheck_statefile():
6+
return GlobalSelfCheckState()
7+
8+
9+
+def pip_installed_by_pip():
10+
+ """Checks whether pip was installed by pip
11+
+
12+
+ This is used not to display the upgrade message when pip is in fact
13+
+ installed by system package manager, such as dnf on Fedora.
14+
+ """
15+
+ import pkg_resources
16+
+ try:
17+
+ dist = pkg_resources.get_distribution('pip')
18+
+ return (dist.has_metadata('INSTALLER') and
19+
+ 'pip' in dist.get_metadata_lines('INSTALLER'))
20+
+ except pkg_resources.DistributionNotFound:
21+
+ return False
22+
+
23+
+
24+
def pip_version_check(session):
25+
"""Check for an update for pip.
26+
27+
@@ -141,7 +156,8 @@ def pip_version_check(session):
28+
29+
# Determine if our pypi_version is older
30+
if (pip_version < remote_version and
31+
- pip_version.base_version != remote_version.base_version):
32+
+ pip_version.base_version != remote_version.base_version and
33+
+ pip_installed_by_pip()):
34+
# Advise "python -m pip" on Windows to avoid issues
35+
# with overwriting pip.exe.
36+
if WINDOWS:

python-pip.spec

+17
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ Patch0: allow-stripping-given-prefix-from-wheel-RECORD-files.patch
6161
# Issue upstream: https://github.com/pypa/pip/issues/4288
6262
Patch1: emit-a-warning-when-running-with-root-privileges.patch
6363

64+
65+
# WIP upstream patch https://github.com/pypa/pip/issues/5346
66+
# https://bugzilla.redhat.com/show_bug.cgi?id=1573755
67+
Patch2: pip-nowarn-upgrade.patch
68+
6469
# Downstream only patch
6570
# Users are upgrading pip9 to pip10 by various manners,
6671
# one of them is `pip install --user --upgrade pip`.
@@ -223,6 +228,7 @@ tar -xf %{SOURCE1}
223228

224229
%patch0 -p1
225230
%patch1 -p1
231+
%patch2 -p1
226232

227233
sed -i '1d' pip/__init__.py
228234

@@ -348,6 +354,15 @@ ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3
348354
%endif
349355

350356

357+
# Make sure the INSTALLER is not pip, otherwise Patch2 won't work
358+
# TODO Maybe we should make all our python packages have this?
359+
%if %{with python2}
360+
echo rpm > %{buildroot}%{python2_sitelib}/pip-%{version}.dist-info/INSTALLER
361+
%endif
362+
%if %{with python3}
363+
echo rpm > %{buildroot}%{python3_sitelib}/pip-%{version}.dist-info/INSTALLER
364+
%endif
365+
351366
%if %{with tests}
352367
%check
353368
%if %{with python2}
@@ -410,8 +425,10 @@ py.test-%{python3_version} -m 'not network'
410425
%changelog
411426
* Fri May 04 2018 Miro Hrončok <[email protected]> - 9.0.3-2
412427
- Allow to import pip10's main from pip9's /usr/bin/pip
428+
- Do not show the "new version of pip" warning outside of venv
413429
Resolves: rhbz#1569488
414430
Resolves: rhbz#1571650
431+
Resolves: rhbz#1573755
415432

416433
* Thu Mar 29 2018 Charalampos Stratakis <[email protected]> - 9.0.3-1
417434
- Update to 9.0.3

0 commit comments

Comments
 (0)