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:
Miro Hrončok 2018-05-04 12:11:26 +02:00
commit 8cd1535c34
2 changed files with 45 additions and 1 deletions

View file

@ -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
<http://peak.telecommunity.com/DevCenter/EasyInstall>`_. 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 <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
- Update to 9.0.3