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.
This commit is contained in:
parent
3989bcbcc0
commit
d02d7aa312
16
pip9-allow-pip10-import.patch
Normal file
16
pip9-allow-pip10-import.patch
Normal 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])
|
@ -30,7 +30,7 @@
|
|||||||
Name: python-%{srcname}
|
Name: python-%{srcname}
|
||||||
# When updating, update the bundled libraries versions bellow!
|
# When updating, update the bundled libraries versions bellow!
|
||||||
Version: 9.0.3
|
Version: 9.0.3
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
Summary: A tool for installing and managing Python packages
|
Summary: A tool for installing and managing Python packages
|
||||||
|
|
||||||
Group: Development/Libraries
|
Group: Development/Libraries
|
||||||
@ -61,6 +61,24 @@ Patch0: allow-stripping-given-prefix-from-wheel-RECORD-files.patch
|
|||||||
# Issue upstream: https://github.com/pypa/pip/issues/4288
|
# Issue upstream: https://github.com/pypa/pip/issues/4288
|
||||||
Patch1: emit-a-warning-when-running-with-root-privileges.patch
|
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
|
%description
|
||||||
pip is a package management system used to install and manage software packages
|
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
|
written in Python. Many packages can be found in the Python Package Index
|
||||||
@ -270,6 +288,11 @@ install -pm0644 docs/_build/man/*.1 %{buildroot}%{_mandir}/man1/pip3.1
|
|||||||
%endif
|
%endif
|
||||||
%endif # with python2
|
%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}
|
mkdir -p %{buildroot}%{bashcompdir}
|
||||||
%if %{with python2}
|
%if %{with python2}
|
||||||
PYTHONPATH=%{buildroot}%{python2_sitelib} \
|
PYTHONPATH=%{buildroot}%{python2_sitelib} \
|
||||||
@ -385,6 +408,11 @@ py.test-%{python3_version} -m 'not network'
|
|||||||
%endif # with python3
|
%endif # with python3
|
||||||
|
|
||||||
%changelog
|
%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
|
||||||
|
Resolves: rhbz#1569488
|
||||||
|
Resolves: rhbz#1571650
|
||||||
|
|
||||||
* Thu Mar 29 2018 Charalampos Stratakis <cstratak@redhat.com> - 9.0.3-1
|
* Thu Mar 29 2018 Charalampos Stratakis <cstratak@redhat.com> - 9.0.3-1
|
||||||
- Update to 9.0.3
|
- Update to 9.0.3
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user