From 83be6a10d1c9eeedfc2c3419b9116c9cc16a46e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Mon, 11 Nov 2019 11:11:11 +0100 Subject: [PATCH] Make /usr/bin/pip(2|3) work with user-installed pip 19.3+ Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1767212 == Before: $ rpm -q python3-pip python3-pip-18.1-1.fc29.noarch $ rpm -q python2-pip python2-pip-18.1-1.fc29.noarch $ /usr/bin/pip --version pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7) $ /usr/bin/pip2 --version pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7) $ /usr/bin/pip3 --version pip 18.1 from /usr/lib/python3.7/site-packages/pip (python 3.7) $ pip{2,3} install --user --upgrade pip ... Successfully installed pip-19.3.1 $ /usr/bin/pip{,2,3} --version Traceback (most recent call last): File "/usr/bin/pip{,2,3}", line 16, in sys.exit(main()) TypeError: 'module' object is not callable $ rm .local/ -rf $ pip{2,3} install --user --upgrade 'pip<10' ... Successfully installed pip-9.0.3 $ /usr/bin/pip --version pip 9.0.3 from /home/pythonista/.local/lib/python2.7/site-packages (python 2.7) $ /usr/bin/pip2 --version pip 9.0.3 from /home/pythonista/.local/lib/python2.7/site-packages (python 2.7) $ /usr/bin/pip3 --version pip 9.0.3 from /home/pythonista/.local/lib/python3.7/site-packages (python 3.7) $ pip{2,3} install --user --upgrade 'pip<9' ... Successfully installed pip-8.1.2 $ /usr/bin/pip --version pip 8.1.2 from /home/pythonista/.local/lib/python2.7/site-packages (python 2.7) $ /usr/bin/pip2 --version pip 8.1.2 from /home/pythonista/.local/lib/python2.7/site-packages (python 2.7) $ /usr/bin/pip3 --version pip 8.1.2 from /home/pythonista/.local/lib/python3.7/site-packages (python 3.7) == After $ rpm -q python3-pip python3-pip-18.1-2.fc29.noarch $ rpm -q python2-pip python2-pip-18.1-2.fc29.noarch $ /usr/bin/pip --version pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7) $ /usr/bin/pip2 --version pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7) $ /usr/bin/pip3 --version pip 18.1 from /usr/lib/python3.7/site-packages/pip (python 3.7) $ pip{2,3} install --user --upgrade pip ... Successfully installed pip-19.3.1 $ /usr/bin/pip --version pip 19.3.1 from /home/pythonista/.local/lib/python2.7/site-packages/pip (python 2.7) $ /usr/bin/pip2 --version pip 19.3.1 from /home/pythonista/.local/lib/python2.7/site-packages/pip (python 2.7) $ /usr/bin/pip3 --version pip 19.3.1 from /home/pythonista/.local/lib/python3.7/site-packages/pip (python 3.7) $ pip{2,3} install --user --upgrade 'pip<10' ... Successfully installed pip-9.0.3 $ /usr/bin/pip --version pip 9.0.3 from /home/pythonista/.local/lib/python2.7/site-packages (python 2.7) $ /usr/bin/pip2 --version pip 9.0.3 from /home/pythonista/.local/lib/python2.7/site-packages (python 2.7) $ /usr/bin/pip3 --version pip 9.0.3 from /home/pythonista/.local/lib/python3.7/site-packages (python 3.7) $ pip{2,3} install --user --upgrade 'pip<9' ... Successfully installed pip-8.1.2 $ /usr/bin/pip --version pip 8.1.2 from /home/pythonista/.local/lib/python2.7/site-packages (python 2.7) $ /usr/bin/pip2 --version pip 8.1.2 from /home/pythonista/.local/lib/python2.7/site-packages (python 2.7) $ /usr/bin/pip3 --version pip 8.1.2 from /home/pythonista/.local/lib/python3.7/site-packages (python 3.7) --- ...patch => pip-allow-different-versions.patch | 6 +++++- python-pip.spec | 18 +++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) rename pip-allow-older-versions.patch => pip-allow-different-versions.patch (80%) diff --git a/pip-allow-older-versions.patch b/pip-allow-different-versions.patch similarity index 80% rename from pip-allow-older-versions.patch rename to pip-allow-different-versions.patch index 39a272b..5b7075d 100644 --- a/pip-allow-older-versions.patch +++ b/pip-allow-different-versions.patch @@ -1,6 +1,6 @@ --- /usr/bin/pip3 2018-03-29 15:22:13.000000000 +0200 +++ pip3 2018-05-04 11:49:08.098821010 +0200 -@@ -4,7 +4,12 @@ +@@ -4,7 +4,16 @@ import re import sys @@ -11,6 +11,10 @@ + # user has most probably downgraded pip in their home + # so let them run it anyway until ~/.local/bin makes it in front of the PATH + from pip import main ++else: ++ # user might also upgraded pip... ++ if hasattr(main, 'main'): ++ main = main.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 63490df..dec5ee0 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -23,7 +23,7 @@ Name: python-%{srcname} # When updating, update the bundled libraries versions bellow! # You can use vendor_meta.sh in the dist git repo Version: 18.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A tool for installing and managing Python packages # We bundle a lot of libraries with pip, which itself is under MIT license. @@ -97,21 +97,22 @@ Patch3: remove-existing-dist-only-if-path-conflicts.patch # Downstream only patch # Users might have local installations of pip from using -# `pip install --user --upgrade pip` on older versions. +# `pip install --user --upgrade pip` on older/newer versions. # 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 (pip10+) and the import in there -# fails (it tries to import from ~/.local, but older pip is there with a bit -# different API). +# However that's the one from this RPM package and the import in there might +# fail (it tries to import from ~/.local, but older or newer pip is there with +# a bit different API). # We add this patch as a dirty workaround to make /usr/bin/pip* work with -# both pip10+ (from this RPM) and older pip (from whatever). +# both pip10+ (from this RPM) and older or newer (19.3+) pip (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 +# https://bugzilla.redhat.com/show_bug.cgi?id=1767212 # 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: pip-allow-older-versions.patch +Source10: pip-allow-different-versions.patch %description pip is a package management system used to install and manage software packages @@ -464,6 +465,9 @@ ln -sf %{buildroot}%{_bindir}/pip3 _bin/pip %endif %changelog +* Mon Nov 11 2019 Miro Hrončok - 18.1-2 +- Make /usr/bin/pip(2|3) work with user-installed pip 19.3+ (#1767212) + * Thu Nov 22 2018 Miro Hrončok - 18.1-1 - Update to 18.1 (#1652089)