Drop no-longer-needed custom changes to /usr/bin/pip*

pip >= 20 has a mechanism that replaces our pip-allow-different-versions.patch
However, we kept our patch to support users doing e.g.:

    $ pip install --user --upgrade 'pip<20'

However, pip 19.3.1 (the latest <20 version) does not even operate without distutils:

    (venv3.12)$ pip list
    Package    Version
    ---------- -------
    pip        22.3.1
    setuptools 65.5.0

    (venv3.12)$ pip install --upgrade 'pip<20'
    ...

    (venv3.12) $ pip list
    Traceback (most recent call last):
      File ".../venv3.12/bin/pip", line 5, in <module>
        from pip._internal.main import main
      File ".../venv3.12/lib64/python3.12/site-packages/pip/_internal/main.py", line 13, in <module>
        from pip._internal.cli.autocompletion import autocomplete
      File ".../venv3.12/lib64/python3.12/site-packages/pip/_internal/cli/autocompletion.py", line 11, in <module>
        from pip._internal.cli.main_parser import create_main_parser
      File ".../venv3.12/lib64/python3.12/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
        from pip._internal.cli import cmdoptions
      File ".../venv3.12/lib64/python3.12/site-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
        from distutils.util import strtobool
    ModuleNotFoundError: No module named 'distutils'

Hence, it no longer makes any sense to keep the patch with Python 3.12.
This commit is contained in:
Miro Hrončok 2023-07-26 16:03:11 +02:00
parent 3292de8e3b
commit e82cd73bd4
2 changed files with 5 additions and 56 deletions

View File

@ -1,27 +0,0 @@
--- /usr/bin/pip3 2019-11-12 17:37:34.793131862 +0100
+++ pip3 2019-11-12 17:40:42.014107134 +0100
@@ -2,7 +2,23 @@
# -*- coding: utf-8 -*-
import re
import sys
-from pip._internal.cli.main import main
+
+try:
+ from pip._internal.cli.main import main
+except ImportError:
+ try:
+ from pip._internal.main import main
+ except ImportError:
+ try:
+ # If the user has downgraded pip, the above import will fail.
+ # Let's try older methods of invoking it:
+
+ # pip 19 uses this
+ from pip._internal import main
+ except ImportError:
+ # older pip versions use this
+ from pip import main
+
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -16,7 +16,7 @@
Name: python-%{srcname} Name: python-%{srcname}
Version: %{base_version}%{?prerel:~%{prerel}} Version: %{base_version}%{?prerel:~%{prerel}}
Release: 5%{?dist} Release: 6%{?dist}
Summary: A tool for installing and managing Python packages Summary: A tool for installing and managing Python packages
# We bundle a lot of libraries with pip, which itself is under MIT license. # We bundle a lot of libraries with pip, which itself is under MIT license.
@ -85,29 +85,6 @@ Patch: nowarn-pip._internal.main.patch
# Upstream issue: https://github.com/pypa/packaging/issues/368 # Upstream issue: https://github.com/pypa/packaging/issues/368
Patch: no-version-warning.patch Patch: no-version-warning.patch
# Downstream only patch
# Users might have local installations of pip from using
# `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 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 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
# Note that since pip 20, old main() import paths are preserved for backwards
# compatibility: https://github.com/pypa/pip/issues/7498
# Meaning we don't need to update any of the older pips to support 20+
# We also don't need to update Pythons to use new import path in ensurepip
Source10: pip-allow-different-versions.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
@ -309,11 +286,6 @@ done
popd popd
%endif %endif
# before we ln -s anything, we apply Source10 patch to all pips:
for PIP in %{buildroot}%{_bindir}/pip*; do
patch -p1 --no-backup-if-mismatch $PIP < %{SOURCE10}
done
mkdir -p %{buildroot}%{bashcompdir} mkdir -p %{buildroot}%{bashcompdir}
PYTHONPATH=%{buildroot}%{python3_sitelib} \ PYTHONPATH=%{buildroot}%{python3_sitelib} \
%{buildroot}%{_bindir}/pip completion --bash \ %{buildroot}%{_bindir}/pip completion --bash \
@ -389,6 +361,10 @@ pytest_k='not completion'
%{python_wheel_dir}/%{python_wheel_name} %{python_wheel_dir}/%{python_wheel_name}
%changelog %changelog
* Wed Jul 26 2023 Miro Hrončok <mhroncok@redhat.com> - 23.1.2-6
- Drop no-longer-needed custom changes to /usr/bin/pip*
Resolves: rhbz#2150373
* Tue Jul 25 2023 Python Maint <python-maint@redhat.com> - 23.1.2-5 * Tue Jul 25 2023 Python Maint <python-maint@redhat.com> - 23.1.2-5
- Rebuilt for Python 3.12 - Rebuilt for Python 3.12