Compare commits

...

3 Commits
master ... f27

Author SHA1 Message Date
Miro Hrončok 663a332e12 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 https://github.com/pypa/pip/issues/5346
2018-05-05 19:49:49 +02:00
Miro Hrončok 7bfc7e8c55 Allow to import pip10's main from pip9's /usr/bin/pip
Users are upgrading pip9 to pip10 by various manners,
one of them is `pip install --user --upgrade pip`.

If they do that and they run `pip` or  `pip3`, the one from /usr/bin is used.
However that's the one from this RPM package (pip9) and the import in there
fails (it tries to import from ~/.local, but pip10 is there with a bit
different API).

We add a patch as a dirty workaround to make /usr/bin/pip* work with
both pip9 (from this RPM) and pip10 (from whatever).

A proper fix is to put ~/.local/bin in front of /usr/bin in the PATH,
however others are against that and we cannot change it for existing
installs/user homes anyway.

This is a workaround for:
 * https://bugzilla.redhat.com/show_bug.cgi?id=1569488
 * https://bugzilla.redhat.com/show_bug.cgi?id=1571650

Patch is applied in %install, because /usr/bin/pip* are entrypoints.
2018-05-05 19:49:49 +02:00
Charalampos Stratakis 2e61c256f3 Update to 9.0.3 2018-03-29 16:59:54 +02:00
5 changed files with 106 additions and 4 deletions

2
.gitignore vendored
View File

@ -18,3 +18,5 @@ pip-0.7.2.tar.gz
/pip-8.1.2-tests.tar.gz
/pip-9.0.1.tar.gz
/pip-9.0.1-tests.tar.gz
/pip-9.0.3.tar.gz
/pip-9.0.3-tests.tar.gz

36
pip-nowarn-upgrade.patch Normal file
View File

@ -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:

View File

@ -0,0 +1,16 @@
--- /usr/bin/pip3 2018-03-29 15:22:13.000000000 +0200
+++ pip3 2018-05-04 11:49:08.098821010 +0200
@@ -4,7 +4,12 @@
import re
import sys
-from pip import main
+try:
+ from pip import main
+except ImportError:
+ # user has most probably upgraded pip in their home
+ # so let them run it anyway until ~/.local/bin makes it in front of the PATH
+ from pip._internal import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])

View File

@ -24,8 +24,8 @@
Name: python-%{srcname}
# When updating, update the bundled libraries versions bellow!
Version: 9.0.1
Release: 14%{?dist}
Version: 9.0.3
Release: 2%{?dist}
Summary: A tool for installing and managing Python packages
Group: Development/Libraries
@ -56,6 +56,29 @@ Patch0: allow-stripping-given-prefix-from-wheel-RECORD-files.patch
# Issue upstream: https://github.com/pypa/pip/issues/4288
Patch1: emit-a-warning-when-running-with-root-privileges.patch
# WIP upstream patch https://github.com/pypa/pip/issues/5346
# https://bugzilla.redhat.com/show_bug.cgi?id=1573755
Patch2: pip-nowarn-upgrade.patch
# Downstream only patch
# Users are upgrading pip9 to pip10 by various manners,
# one of them is `pip install --user --upgrade pip`.
# If they do that and they run `pip` or `pip3`, the one from /usr/bin is used.
# However that's the one from this RPM package (pip9) and the import in there
# fails (it tries to import from ~/.local, but pip10 is there with a bit
# different API).
# We add this patch as a dirty workaround to make /usr/bin/pip* work with
# both pip9 (from this RPM) and pip10 (from whatever).
# A proper fix is to put ~/.local/bin in front of /usr/bin in the PATH,
# however others are against that and we cannot change it for existing
# installs/user homes anyway.
# https://bugzilla.redhat.com/show_bug.cgi?id=1569488
# https://bugzilla.redhat.com/show_bug.cgi?id=1571650
# WARNING: /usr/bin/pip* are entrypoints, this cannot be applied in %%prep!
# %%patch10 doesn't work outside of %%prep, so we add it as a source
Source10: pip9-allow-pip10-import.patch
%description
pip is a package management system used to install and manage software packages
written in Python. Many packages can be found in the Python Package Index
@ -184,6 +207,7 @@ tar -xf %{SOURCE1}
%patch0 -p1
%patch1 -p1
%patch2 -p1
sed -i '1d' pip/__init__.py
@ -230,6 +254,11 @@ rm %{buildroot}%{_bindir}/pip
%endif
%endif # with python2
# before we ln -s anything, we apply Source10 patch to all pips:
for PIP in %{buildroot}%{_bindir}/pip*; do
patch -p1 $PIP < %{SOURCE10}
done
mkdir -p %{buildroot}%{bashcompdir}
%if %{with python2}
PYTHONPATH=%{buildroot}%{python2_sitelib} \
@ -285,6 +314,15 @@ ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3
%endif
# Make sure the INSTALLER is not pip, otherwise Patch2 won't work
# TODO Maybe we should make all our python packages have this?
%if %{with python2}
echo rpm > %{buildroot}%{python2_sitelib}/pip-%{version}.dist-info/INSTALLER
%endif
%if %{with python3}
echo rpm > %{buildroot}%{python3_sitelib}/pip-%{version}.dist-info/INSTALLER
%endif
%if %{with tests}
%check
%if %{with python2}
@ -331,6 +369,16 @@ py.test-%{python3_version} -m 'not network'
%endif # with python3
%changelog
* Fri May 04 2018 Miro Hrončok <mhroncok@redhat.com> - 9.0.3-2
- Allow to import pip10's main from pip9's /usr/bin/pip
- Do not show the "new version of pip" warning outside of venv
Resolves: rhbz#1569488
Resolves: rhbz#1571650
Resolves: rhbz#1573755
* Thu Mar 29 2018 Charalampos Stratakis <cstratak@redhat.com> - 9.0.3-1
- Update to 9.0.3
* Mon Dec 04 2017 Charalampos Stratakis <cstratak@redhat.com> - 9.0.1-14
- Reintroduce the ipaddress module in the python3 subpackage.

View File

@ -1,2 +1,2 @@
35f01da33009719497f01a4ba69d63c9 pip-9.0.1.tar.gz
93ea1b8882c0e3e0e52d5034970d900f pip-9.0.1-tests.tar.gz
SHA512 (pip-9.0.3.tar.gz) = daf5bb2460787a0391400d5e074fc69c78d623445fcc6fcb12fae9a118f19692cc7ce316a7e85a04662bc82c0a0514577fa1ca8323b09be0d08c7a7bb8728e77
SHA512 (pip-9.0.3-tests.tar.gz) = 5cc7c06b2c688307d2e081e01d750c1c462f34879ddffe204fa4523d4d4dc0afc9f584ff9bdc86768944bccd8bf79d93c87e9935b3a38e22aeb2fd839cce1447