From 1189b23fc5c52174e948b9863bdcf2256d511e7c Mon Sep 17 00:00:00 2001 From: Charalampos Stratakis Date: Mon, 20 Nov 2017 16:00:20 +0100 Subject: [PATCH 1/5] Add virtual provides for all the libraries that pip bundles. Remove ordereddict bundle as it is only required for python <=2.6. Remove ipaddress library from the python3 build as it only required on python2. Changed some dependency names from python-* to the python2-* namespace. Resolves: rhbz#1096912 --- python-pip.spec | 84 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 71 insertions(+), 13 deletions(-) diff --git a/python-pip.spec b/python-pip.spec index e2ca90c..a599c0d 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -16,8 +16,9 @@ %endif Name: python-%{srcname} +# When updating, update the bundled libraries versions bellow! Version: 9.0.1 -Release: 9%{?dist} +Release: 10%{?dist} Summary: A tool for installing and managing Python packages Group: Development/Libraries @@ -54,23 +55,46 @@ easy_installable should be pip-installable as well. Summary: A tool for installing and managing Python 2 packages Group: Development/Libraries BuildRequires: python2-devel -BuildRequires: python-setuptools +BuildRequires: python2-setuptools %if 0%{?with_tests} -BuildRequires: git -BuildRequires: bzr -BuildRequires: python-mock -BuildRequires: pytest -BuildRequires: python-pretend -BuildRequires: python-freezegun -BuildRequires: python-pytest-capturelog -BuildRequires: python-scripttest -BuildRequires: python-virtualenv +BuildRequires: python2-mock +BuildRequires: python2-pytest +BuildRequires: python2-pretend +BuildRequires: python2-freezegun +BuildRequires: python2-pytest-capturelog +BuildRequires: python2-scripttest +BuildRequires: python2-virtualenv %endif %if 0%{?build_wheel} BuildRequires: python2-pip -BuildRequires: python-wheel +BuildRequires: python2-wheel %endif -Requires: python-setuptools +Requires: python2-setuptools + +# Virtual provides for the packages bundled by pip. +# You can find the versions in pip/_vendor/vendor.txt file. +# Don't forget to update this bellow for python3 as well. +Provides: bundled(python2dist(appdirs)) = 1.4.0 +Provides: bundled(python2dist(cachecontrol)) = 0.11.7 +Provides: bundled(python2dist(colorama)) = 0.3.7 +Provides: bundled(python2dist(distlib)) = 0.2.4 +Provides: bundled(python2dist(distro)) = 1.0.1 +Provides: bundled(python2dist(html5lib)) = 1.0b10 +Provides: bundled(python2dist(ipaddress) = 1.0.17 +Provides: bundled(python2dist(lockfile)) = 0.12.2 +Provides: bundled(python2dist(packaging)) = 16.8 +Provides: bundled(python2dist(setuptools)) = 28.8.0 +Provides: bundled(python2dist(progress)) = 1.2 +Provides: bundled(python2dist(pyparsing)) = 2.1.10 +Provides: bundled(python2dist(requests)) = 2.11.1 +Provides: bundled(python2dist(retrying)) = 1.3.3 +Provides: bundled(python2dist(six)) = 1.10.0 +Provides: bundled(python2dist(webencodings)) = 0.5 + +# Bundled within the requests bundle +Provides: bundled(python2dist(chardet)) = 2.3.0 +Provides: bundled(python2dist(urllib3)) = 1.16 + %{?python_provide:%python_provide python2-%{srcname}} %description -n python2-%{srcname} @@ -102,6 +126,29 @@ BuildRequires: python%{python3_pkgversion}-pip BuildRequires: python%{python3_pkgversion}-wheel %endif Requires: python%{python3_pkgversion}-setuptools + +# Virtual provides for the packages bundled by pip. +# See the python2 list above for instructions. +Provides: bundled(python3dist(appdirs)) = 1.4.0 +Provides: bundled(python3dist(cachecontrol)) = 0.11.7 +Provides: bundled(python3dist(colorama)) = 0.3.7 +Provides: bundled(python3dist(distlib)) = 0.2.4 +Provides: bundled(python3dist(distro)) = 1.0.1 +Provides: bundled(python3dist(html5lib)) = 1.0b10 +Provides: bundled(python3dist(lockfile)) = 0.12.2 +Provides: bundled(python3dist(packaging)) = 16.8 +Provides: bundled(python3dist(setuptools)) = 28.8.0 +Provides: bundled(python3dist(progress)) = 1.2 +Provides: bundled(python3dist(pyparsing)) = 2.1.10 +Provides: bundled(python3dist(requests)) = 2.11.1 +Provides: bundled(python3dist(retrying)) = 1.3.3 +Provides: bundled(python3dist(six)) = 1.10.0 +Provides: bundled(python3dist(webencodings)) = 0.5 + +# Bundled within the requests bundle +Provides: bundled(python3dist(chardet)) = 2.3.0 +Provides: bundled(python3dist(urllib3)) = 1.16 + %{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}} %description -n python%{python3_pkgversion}-%{srcname} @@ -123,6 +170,9 @@ tar -xf %{SOURCE1} sed -i '1d' pip/__init__.py +# Remove ordereddict as it is only required for python <= 2.6 +rm pip/_vendor/ordereddict.py + %build %if 0%{?build_wheel} @@ -152,6 +202,11 @@ rm %{buildroot}%{_bindir}/pip %endif %endif # with_python3 +# Remove the bundled ipaddress library from the python3 build +# as it is only required by the python2 one. +rm %{buildroot}%{python3_sitelib}/pip/_vendor/ipaddress.py +rm %{buildroot}%{python3_sitelib}/pip/_vendor/__pycache__/ipaddress.cpython-*.pyc + %if 0%{?build_wheel} %py2_install_wheel %{python2_wheelname} %else @@ -244,6 +299,9 @@ py.test-%{python3_version} -m 'not network' %endif # with_python3 %changelog +* Mon Nov 20 2017 Charalampos Stratakis - 9.0.1-10 +- Add virtual provides for the bundled libraries. (rhbz#1096912) + * Tue Mar 21 2017 Tomas Orsava - 9.0.1-9 - Fix typo in the sudo pip warning From e32f36f5efb5e24b5647e5233b8e879ed8b5c714 Mon Sep 17 00:00:00 2001 From: Charalampos Stratakis Date: Mon, 4 Dec 2017 15:53:44 +0100 Subject: [PATCH 2/5] Reintroduce the ipaddress module in the python3 subpackage as it is used within python3's upstream test suite. --- python-pip.spec | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/python-pip.spec b/python-pip.spec index a599c0d..a21b089 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -18,7 +18,7 @@ Name: python-%{srcname} # When updating, update the bundled libraries versions bellow! Version: 9.0.1 -Release: 10%{?dist} +Release: 11%{?dist} Summary: A tool for installing and managing Python packages Group: Development/Libraries @@ -135,6 +135,7 @@ Provides: bundled(python3dist(colorama)) = 0.3.7 Provides: bundled(python3dist(distlib)) = 0.2.4 Provides: bundled(python3dist(distro)) = 1.0.1 Provides: bundled(python3dist(html5lib)) = 1.0b10 +Provides: bundled(python3dist(ipaddress) = 1.0.17 Provides: bundled(python3dist(lockfile)) = 0.12.2 Provides: bundled(python3dist(packaging)) = 16.8 Provides: bundled(python3dist(setuptools)) = 28.8.0 @@ -202,11 +203,6 @@ rm %{buildroot}%{_bindir}/pip %endif %endif # with_python3 -# Remove the bundled ipaddress library from the python3 build -# as it is only required by the python2 one. -rm %{buildroot}%{python3_sitelib}/pip/_vendor/ipaddress.py -rm %{buildroot}%{python3_sitelib}/pip/_vendor/__pycache__/ipaddress.cpython-*.pyc - %if 0%{?build_wheel} %py2_install_wheel %{python2_wheelname} %else @@ -299,6 +295,9 @@ py.test-%{python3_version} -m 'not network' %endif # with_python3 %changelog +* Mon Dec 04 2017 Charalampos Stratakis - 9.0.1-11 +- Reintroduce the ipaddress module in the python3 subpackage. + * Mon Nov 20 2017 Charalampos Stratakis - 9.0.1-10 - Add virtual provides for the bundled libraries. (rhbz#1096912) From 24630acdcb3967ac12b3cbe217c254019fb10855 Mon Sep 17 00:00:00 2001 From: Charalampos Stratakis Date: Thu, 29 Mar 2018 15:17:28 +0200 Subject: [PATCH 3/5] Update to 9.0.3 --- .gitignore | 2 ++ python-pip.spec | 7 +++++-- sources | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4844c76..5abdf9b 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/python-pip.spec b/python-pip.spec index a21b089..2d1bad1 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -17,8 +17,8 @@ Name: python-%{srcname} # When updating, update the bundled libraries versions bellow! -Version: 9.0.1 -Release: 11%{?dist} +Version: 9.0.3 +Release: 1%{?dist} Summary: A tool for installing and managing Python packages Group: Development/Libraries @@ -295,6 +295,9 @@ py.test-%{python3_version} -m 'not network' %endif # with_python3 %changelog +* Thu Mar 29 2018 Charalampos Stratakis - 9.0.3-1 +- Update to 9.0.3 + * Mon Dec 04 2017 Charalampos Stratakis - 9.0.1-11 - Reintroduce the ipaddress module in the python3 subpackage. diff --git a/sources b/sources index 31e725f..49c5067 100644 --- a/sources +++ b/sources @@ -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 From 8cd1535c34077ebfb9260180245124a53960537c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 4 May 2018 12:11:26 +0200 Subject: [PATCH 4/5] 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. --- pip9-allow-pip10-import.patch | 16 ++++++++++++++++ python-pip.spec | 30 +++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 pip9-allow-pip10-import.patch diff --git a/pip9-allow-pip10-import.patch b/pip9-allow-pip10-import.patch new file mode 100644 index 0000000..657b7b3 --- /dev/null +++ b/pip9-allow-pip10-import.patch @@ -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]) diff --git a/python-pip.spec b/python-pip.spec index 2d1bad1..2d68cee 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -18,7 +18,7 @@ Name: python-%{srcname} # When updating, update the bundled libraries versions bellow! Version: 9.0.3 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A tool for installing and managing Python packages Group: Development/Libraries @@ -44,6 +44,24 @@ 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 +# 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 replacement for `easy_install `_. It uses mostly the @@ -209,6 +227,11 @@ rm %{buildroot}%{_bindir}/pip %py2_install %endif +# 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} PYTHONPATH=%{buildroot}%{python_sitelib} \ %{buildroot}%{_bindir}/pip completion --bash \ @@ -295,6 +318,11 @@ py.test-%{python3_version} -m 'not network' %endif # with_python3 %changelog +* Fri May 04 2018 Miro Hrončok - 9.0.3-2 +- Allow to import pip10's main from pip9's /usr/bin/pip +Resolves: rhbz#1569488 +Resolves: rhbz#1571650 + * Thu Mar 29 2018 Charalampos Stratakis - 9.0.3-1 - Update to 9.0.3 From 9a0914ebc4593d7318b27aed9cbc70d33c672ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 4 May 2018 14:26:11 +0200 Subject: [PATCH 5/5] 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 --- pip-nowarn-upgrade.patch | 36 ++++++++++++++++++++++++++++++++++++ python-pip.spec | 14 ++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 pip-nowarn-upgrade.patch diff --git a/pip-nowarn-upgrade.patch b/pip-nowarn-upgrade.patch new file mode 100644 index 0000000..9e314a5 --- /dev/null +++ b/pip-nowarn-upgrade.patch @@ -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: diff --git a/python-pip.spec b/python-pip.spec index 2d68cee..155e41e 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -44,6 +44,11 @@ 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`. @@ -186,6 +191,7 @@ tar -xf %{SOURCE1} %patch0 -p1 %patch1 -p1 +%patch2 -p1 sed -i '1d' pip/__init__.py @@ -276,6 +282,12 @@ ln -s ./pip%{python3_version} %{buildroot}%{_bindir}/pip-%{python3_version} ln -s ./pip-%{python2_version} %{buildroot}%{_bindir}/pip-2 ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3 +# Make sure the INSTALLER is not pip, otherwise Patch2 won't work +# TODO Maybe we should make all our python packages have this? +echo rpm > %{buildroot}%{python2_sitelib}/pip-%{version}.dist-info/INSTALLER +%if 0%{?with_python3} +echo rpm > %{buildroot}%{python3_sitelib}/pip-%{version}.dist-info/INSTALLER +%endif %if 0%{?with_tests} %check @@ -320,8 +332,10 @@ py.test-%{python3_version} -m 'not network' %changelog * Fri May 04 2018 Miro Hrončok - 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 - 9.0.3-1 - Update to 9.0.3