This repository has been archived by the owner on Nov 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,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 | ||
|
@@ -61,6 +61,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 package management system used to install and manage software packages | ||
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 # 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} | ||
%if %{with python2} | ||
PYTHONPATH=%{buildroot}%{python2_sitelib} \ | ||
|
@@ -385,6 +408,11 @@ py.test-%{python3_version} -m 'not network' | |
%endif # with python3 | ||
|
||
%changelog | ||
* Fri May 04 2018 Miro Hrončok <[email protected]> - 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 <[email protected]> - 9.0.3-1 | ||
- Update to 9.0.3 | ||
|
||
|