#42 Make /usr/bin/pip(3) work with user-installed pip 19.3+
Merged 4 years ago by churchyard. Opened 4 years ago by churchyard.
rpms/ churchyard/python-pip usr-bin-pip  into  master

pip-allow-different-versions.patch pip-allow-older-versions.patch
file renamed
+5 -1
@@ -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])

file modified
+11 -7
@@ -16,7 +16,7 @@ 

  # When updating, update the bundled libraries versions bellow!

  # You can use vendor_meta.sh in the dist git repo

  Version:        19.2.3

- 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.
@@ -95,21 +95,22 @@ 

  

  # 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
@@ -375,6 +376,9 @@ 

  %{python_wheeldir}/%{python_wheelname}

  

  %changelog

+ * Wed Oct 30 2019 Miro Hrončok <mhroncok@redhat.com> - 19.2.3-2

+ - Make /usr/bin/pip(3) work with user-installed pip 19.3+ (#1767212)

+ 

  * Mon Sep 02 2019 Miro Hrončok <mhroncok@redhat.com> - 19.2.3-1

  - Update to 19.2.3 (#1742230)

  - Drop patch that should strip path prefixes from RECORD files, the paths are relative

Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1767212

Before:

$ rpm -q python3-pip
python3-pip-19.2.3-1.fc32.noarch

$ /usr/bin/pip --version
pip 19.2.3 from /usr/lib/python3.8/site-packages/pip (python 3.8)

$ pip install --user --upgrade pip
...
Successfully installed pip-19.3.1

$ /usr/bin/pip --version
Traceback (most recent call last):
  File "/usr/bin/pip", line 15, in <module>
    sys.exit(main())
TypeError: 'module' object is not callable

$ rm .local/ -rf
$ pip install --user --upgrade 'pip<10'
...
Successfully installed pip-9.0.3

$ /usr/bin/pip --version
pip 9.0.3 from /home/pythonista/.local/lib/python3.8/site-packages (python 3.8)

$ pip install --user --upgrade 'pip<9'
...
Successfully installed pip-8.1.2

$ /usr/bin/pip --version
pip 8.1.2 from /home/pythonista/.local/lib/python3.8/site-packages (python 3.8)

After

$ rpm -q python3-pip
python3-pip-19.2.3-2.fc32.noarch

$ /usr/bin/pip --version
pip 19.2.3 from /usr/lib/python3.8/site-packages/pip (python 3.8)

$ pip install --user --upgrade pip
...
Successfully installed pip-19.3.1

$ /usr/bin/pip --version
pip 19.3.1 from /home/pythonista/.local/lib/python3.8/site-packages/pip (python 3.8)

$ pip install --user --upgrade 'pip<10'
...
Successfully installed pip-9.0.3

$ /usr/bin/pip --version
pip 9.0.3 from /home/pythonista/.local/lib/python3.8/site-packages (python 3.8)

$ pip install --user --upgrade 'pip<9'
...
Successfully installed pip-8.1.2

$ /usr/bin/pip --version
pip 8.1.2 from /home/pythonista/.local/lib/python3.8/site-packages (python 3.8)

pip sure loves to make it complicated for us! The code looks good though, ship it!

Pull-Request has been merged by churchyard

4 years ago