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