From e82cd73bd4ba80246d0c14b6542665abfc5477e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 26 Jul 2023 16:03:11 +0200 Subject: [PATCH] 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 from pip._internal.main import main File ".../venv3.12/lib64/python3.12/site-packages/pip/_internal/main.py", line 13, in from pip._internal.cli.autocompletion import autocomplete File ".../venv3.12/lib64/python3.12/site-packages/pip/_internal/cli/autocompletion.py", line 11, in 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 from pip._internal.cli import cmdoptions File ".../venv3.12/lib64/python3.12/site-packages/pip/_internal/cli/cmdoptions.py", line 19, in 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. --- pip-allow-different-versions.patch | 27 ------------------------ python-pip.spec | 34 +++++------------------------- 2 files changed, 5 insertions(+), 56 deletions(-) delete mode 100644 pip-allow-different-versions.patch diff --git a/pip-allow-different-versions.patch b/pip-allow-different-versions.patch deleted file mode 100644 index 4a11517..0000000 --- a/pip-allow-different-versions.patch +++ /dev/null @@ -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()) diff --git a/python-pip.spec b/python-pip.spec index 94b6713..8cf5b31 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -16,7 +16,7 @@ Name: python-%{srcname} Version: %{base_version}%{?prerel:~%{prerel}} -Release: 5%{?dist} +Release: 6%{?dist} Summary: A tool for installing and managing Python packages # 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 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 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 @@ -309,11 +286,6 @@ done popd %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} PYTHONPATH=%{buildroot}%{python3_sitelib} \ %{buildroot}%{_bindir}/pip completion --bash \ @@ -389,6 +361,10 @@ pytest_k='not completion' %{python_wheel_dir}/%{python_wheel_name} %changelog +* Wed Jul 26 2023 Miro HronĨok - 23.1.2-6 +- Drop no-longer-needed custom changes to /usr/bin/pip* +Resolves: rhbz#2150373 + * Tue Jul 25 2023 Python Maint - 23.1.2-5 - Rebuilt for Python 3.12