diff --git a/allow-stripping-given-prefix-from-wheel-RECORD-files.patch b/allow-stripping-given-prefix-from-wheel-RECORD-files.patch deleted file mode 100644 index e038bd5d6a6fee7aaa52fe2f3e6e327b22980afa..0000000000000000000000000000000000000000 --- a/allow-stripping-given-prefix-from-wheel-RECORD-files.patch +++ /dev/null @@ -1,31 +0,0 @@ -From e2126b5d4efdbddb15a3c354110055f40d78f4cc Mon Sep 17 00:00:00 2001 -From: wwx930846 -Date: Mon, 24 Aug 2020 22:01:50 +0800 -Subject: [PATCH] allow-stripping-given-prefix-from-wheel-RECORD-files - ---- - src/pip/_internal/commands/install.py | 8 ++++++++ - src/pip/_internal/req/req_install.py | 4 +++- - 2 files changed, 11 insertions(+), 1 deletion(-) - -diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py -index 8c2c32f..674d30c 100644 ---- a/src/pip/_internal/commands/install.py -+++ b/src/pip/_internal/commands/install.py -@@ -134,6 +134,13 @@ class InstallCommand(RequirementCommand): - "folders are placed" - ), - ) -+ self.cmd_opts.add_option( -+ '--strip-file-prefix', -+ dest='strip_file_prefix', -+ metavar='prefix', -+ default=None, -+ help="Strip given prefix from script paths in wheel RECORD." -+ ) - - self.cmd_opts.add_option(cmdoptions.src()) - --- -2.23.0 - diff --git a/bad-metadata-fix.patch b/bad-metadata-fix.patch new file mode 100644 index 0000000000000000000000000000000000000000..740dc71fdbc8c6594e7cbb9bba2fde3b666942fb --- /dev/null +++ b/bad-metadata-fix.patch @@ -0,0 +1,92 @@ +From 6817fbfb1fd389ad61009f0199db5670b146c8d3 Mon Sep 17 00:00:00 2001 +From: Tzu-ping Chung +Date: Sat, 6 Aug 2022 06:18:59 +0800 +Subject: [PATCH] Skip dist if metadata does not have a valid name + +--- + news/11352.bugfix.rst | 2 ++ + src/pip/_internal/metadata/importlib/_compat.py | 14 +++++++++++++- + src/pip/_internal/metadata/importlib/_envs.py | 14 +++++++++++--- + 3 files changed, 26 insertions(+), 4 deletions(-) + create mode 100644 news/11352.bugfix.rst + +diff --git a/news/11352.bugfix.rst b/news/11352.bugfix.rst +new file mode 100644 +index 00000000000..78016c912ef +--- /dev/null ++++ b/news/11352.bugfix.rst +@@ -0,0 +1,2 @@ ++Ignore distributions with invalid ``Name`` in metadata instead of crashing, when ++using the ``importlib.metadata`` backend. +diff --git a/src/pip/_internal/metadata/importlib/_compat.py b/src/pip/_internal/metadata/importlib/_compat.py +index e0879807ab9..593bff23ede 100644 +--- a/src/pip/_internal/metadata/importlib/_compat.py ++++ b/src/pip/_internal/metadata/importlib/_compat.py +@@ -2,6 +2,15 @@ + from typing import Any, Optional, Protocol, cast + + ++class BadMetadata(ValueError): ++ def __init__(self, dist: importlib.metadata.Distribution, *, reason: str) -> None: ++ self.dist = dist ++ self.reason = reason ++ ++ def __str__(self) -> str: ++ return f"Bad metadata in {self.dist} ({self.reason})" ++ ++ + class BasePath(Protocol): + """A protocol that various path objects conform. + +@@ -40,4 +49,7 @@ def get_dist_name(dist: importlib.metadata.Distribution) -> str: + The ``name`` attribute is only available in Python 3.10 or later. We are + targeting exactly that, but Mypy does not know this. + """ +- return cast(Any, dist).name ++ name = cast(Any, dist).name ++ if not isinstance(name, str): ++ raise BadMetadata(dist, reason="invalid metadata entry 'name'") ++ return name +diff --git a/src/pip/_internal/metadata/importlib/_envs.py b/src/pip/_internal/metadata/importlib/_envs.py +index d5fcfdbfef2..cbec59e2c6d 100644 +--- a/src/pip/_internal/metadata/importlib/_envs.py ++++ b/src/pip/_internal/metadata/importlib/_envs.py +@@ -1,5 +1,6 @@ + import functools + import importlib.metadata ++import logging + import os + import pathlib + import sys +@@ -14,9 +15,11 @@ + from pip._internal.utils.deprecation import deprecated + from pip._internal.utils.filetypes import WHEEL_EXTENSION + +-from ._compat import BasePath, get_dist_name, get_info_location ++from ._compat import BadMetadata, BasePath, get_dist_name, get_info_location + from ._dists import Distribution + ++logger = logging.getLogger(__name__) ++ + + def _looks_like_wheel(location: str) -> bool: + if not location.endswith(WHEEL_EXTENSION): +@@ -56,11 +59,16 @@ def _find_impl(self, location: str) -> Iterator[FoundResult]: + # To know exactly where we find a distribution, we have to feed in the + # paths one by one, instead of dumping the list to importlib.metadata. + for dist in importlib.metadata.distributions(path=[location]): +- normalized_name = canonicalize_name(get_dist_name(dist)) ++ info_location = get_info_location(dist) ++ try: ++ raw_name = get_dist_name(dist) ++ except BadMetadata as e: ++ logger.warning("Skipping %s due to %s", info_location, e.reason) ++ continue ++ normalized_name = canonicalize_name(raw_name) + if normalized_name in self._found_names: + continue + self._found_names.add(normalized_name) +- info_location = get_info_location(dist) + yield dist, info_location + + def find(self, location: str) -> Iterator[BaseDistribution]: diff --git a/dummy-certifi.patch b/dummy-certifi.patch index ede6f03fd61c92c401bb3df9b9c3c14c615a7f00..a691caddcb01a0f79dce66ff72cfdebf49887a2f 100644 --- a/dummy-certifi.patch +++ b/dummy-certifi.patch @@ -1,35 +1,36 @@ -From 09bf87d33141a5c06a1d410839d162262baa16c4 Mon Sep 17 00:00:00 2001 -From: Tomas Hrnciar -Date: Sun, 26 Apr 2020 21:38:44 +0200 +From cacd6d2fa9a27b29415a4ce25d76406fe69fc398 Mon Sep 17 00:00:00 2001 +From: Karolina Surma +Date: Mon, 10 May 2021 16:38:50 +0200 Subject: [PATCH] Dummy certifi patch +Co-Authored-By: Tomas Hrnciar --- src/pip/_vendor/certifi/core.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pip/_vendor/certifi/core.py b/src/pip/_vendor/certifi/core.py -index 8987449..568d078 100644 +index f34045b..a2ada08 100644 --- a/src/pip/_vendor/certifi/core.py +++ b/src/pip/_vendor/certifi/core.py -@@ -23,6 +23,7 @@ try: - return _PIP_STANDALONE_CERT - raise _PipPatchedCertificate() +@@ -14,6 +14,7 @@ class _PipPatchedCertificate(Exception): -+ raise ImportError # force fallback - from importlib.resources import path as get_path, read_text - _CACERT_CTX = None -@@ -67,9 +68,7 @@ except ImportError: + try: ++ raise ImportError # force fallback + # Return a certificate file on disk for a standalone pip zipapp running in + # an isolated build environment to use. Passing --cert to the standalone + # pip does not work since requests calls where() unconditionally on import. +@@ -75,9 +76,7 @@ except ImportError: # If we don't have importlib.resources, then we will just do the old logic # of assuming we're on the filesystem and munge the path directly. - def where(): + def where() -> str: - f = os.path.dirname(__file__) - - return os.path.join(f, "cacert.pem") + return '/etc/pki/tls/certs/ca-bundle.crt' - def contents(): + def contents() -> str: -- -1.8.3.1 +2.35.3 diff --git a/emit-a-warning-when-running-with-root-privileges.patch b/emit-a-warning-when-running-with-root-privileges.patch deleted file mode 100644 index cb886a0eeed5262032f60447634ed8c3cba12a4e..0000000000000000000000000000000000000000 --- a/emit-a-warning-when-running-with-root-privileges.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 74bb5d26e232493de43adfa1f4b42b66fd701294 Mon Sep 17 00:00:00 2001 -From: Tomas Hrnciar -Date: Sun, 26 Apr 2020 13:52:24 +0200 -Subject: [PATCH] Downstream only patch - -Emit a warning to the user if pip install is run with root privileges -Issue upstream: https://github.com/pypa/pip/issues/4288 ---- - src/pip/_internal/commands/install.py | 19 +++++++++++++++++++ - 1 file changed, 19 insertions(+) - -diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py -index 70bda2e2..1e750ae1 100644 ---- a/src/pip/_internal/commands/install.py -+++ b/src/pip/_internal/commands/install.py -@@ -13,6 +13,8 @@ import operator - import os - import shutil - import site -+import sys -+from os import path - from optparse import SUPPRESS_HELP, Values - from typing import Iterable, List, Optional - -@@ -241,6 +243,23 @@ class InstallCommand(RequirementCommand): - raise CommandError("Can not combine '--user' and '--target'") - - cmdoptions.check_install_build_global(options) -+ -+ def is_venv(): -+ return (hasattr(sys, 'real_prefix') or -+ (hasattr(sys, 'base_prefix') and -+ sys.base_prefix != sys.prefix)) -+ -+ # Check whether we have root privileges and aren't in venv/virtualenv -+ if os.getuid() == 0 and not is_venv() and not options.root_path: -+ command = path.basename(sys.argv[0]) -+ if command == "__main__.py": -+ command = path.basename(sys.executable) + " -m pip" -+ logger.warning( -+ "Running pip install with root privileges is " -+ "generally not a good idea. Try `%s install --user` instead." -+ % command -+ ) -+ - upgrade_strategy = "to-satisfy-only" - if options.upgrade: - upgrade_strategy = options.upgrade_strategy --- -2.23.0 - diff --git a/no-version-warning.patch b/no-version-warning.patch new file mode 100644 index 0000000000000000000000000000000000000000..6c34bec3412d042e0ecb6346e2d4463c69cb9924 --- /dev/null +++ b/no-version-warning.patch @@ -0,0 +1,16 @@ +diff --git a/src/pip/_vendor/packaging/version.py b/src/pip/_vendor/packaging/version.py +index de9a09a..154e94d 100644 +--- a/src/pip/_vendor/packaging/version.py ++++ b/src/pip/_vendor/packaging/version.py +@@ -108,11 +108,6 @@ class LegacyVersion(_BaseVersion): + self._version = str(version) + self._key = _legacy_cmpkey(self._version) + +- warnings.warn( +- "Creating a LegacyVersion has been deprecated and will be " +- "removed in the next major release", +- DeprecationWarning, +- ) + + def __str__(self) -> str: + return self._version diff --git a/nowarn-pip._internal.main.patch b/nowarn-pip._internal.main.patch new file mode 100644 index 0000000000000000000000000000000000000000..68f5971651031ff56c71914a9492cae44c412740 --- /dev/null +++ b/nowarn-pip._internal.main.patch @@ -0,0 +1,76 @@ +From 8dd3793d1bab226cec9c5c49b01718a9634bc403 Mon Sep 17 00:00:00 2001 +From: Karolina Surma +Date: Mon, 10 May 2021 16:48:49 +0200 +Subject: [PATCH] Don't warn the user about pip._internal.main() entrypoint + +In Fedora, we use that in ensurepip and users cannot do anything about it, +this warning is juts moot. Also, the warning breaks CPython test suite. + +Co-Authored-By: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +--- + src/pip/_internal/__init__.py | 2 +- + src/pip/_internal/utils/entrypoints.py | 19 ++++++++++--------- + tests/functional/test_cli.py | 3 ++- + 3 files changed, 13 insertions(+), 11 deletions(-) + +diff --git a/src/pip/_internal/__init__.py b/src/pip/_internal/__init__.py +index 6afb5c6..faf25af 100755 +--- a/src/pip/_internal/__init__.py ++++ b/src/pip/_internal/__init__.py +@@ -16,4 +16,4 @@ def main(args: (Optional[List[str]]) = None) -> int: + """ + from pip._internal.utils.entrypoints import _wrapper + +- return _wrapper(args) ++ return _wrapper(args, _nowarn=True) +diff --git a/src/pip/_internal/utils/entrypoints.py b/src/pip/_internal/utils/entrypoints.py +index f292c64..2e29a5e 100644 +--- a/src/pip/_internal/utils/entrypoints.py ++++ b/src/pip/_internal/utils/entrypoints.py +@@ -20,7 +20,7 @@ if WINDOWS: + ] + + +-def _wrapper(args: Optional[List[str]] = None) -> int: ++def _wrapper(args: Optional[List[str]] = None, _nowarn: bool = False) -> int: + """Central wrapper for all old entrypoints. + + Historically pip has had several entrypoints defined. Because of issues +@@ -32,14 +32,15 @@ def _wrapper(args: Optional[List[str]] = None) -> int: + directing them to an appropriate place for help, we now define all of + our old entrypoints as wrappers for the current one. + """ +- sys.stderr.write( +- "WARNING: pip is being invoked by an old script wrapper. This will " +- "fail in a future version of pip.\n" +- "Please see https://github.com/pypa/pip/issues/5599 for advice on " +- "fixing the underlying issue.\n" +- "To avoid this problem you can invoke Python with '-m pip' instead of " +- "running pip directly.\n" +- ) ++ if not _nowarn: ++ sys.stderr.write( ++ "WARNING: pip is being invoked by an old script wrapper. This will " ++ "fail in a future version of pip.\n" ++ "Please see https://github.com/pypa/pip/issues/5599 for advice on " ++ "fixing the underlying issue.\n" ++ "To avoid this problem you can invoke Python with '-m pip' instead of " ++ "running pip directly.\n" ++ ) + return main(args) + + +diff --git a/tests/functional/test_cli.py b/tests/functional/test_cli.py +index 3e85703..f86c392 100644 +--- a/tests/functional/test_cli.py ++++ b/tests/functional/test_cli.py +@@ -43,4 +43,5 @@ def test_entrypoints_work(entrypoint: str, script: PipTestEnvironment) -> None: + result = script.pip("-V") + result2 = script.run("fake_pip", "-V", allow_stderr_warning=True) + assert result.stdout == result2.stdout +- assert "old script wrapper" in result2.stderr ++ if entrypoint[0] != "fake_pip = pip._internal:main": ++ assert "old script wrapper" in result2.stderr +-- +2.35.3 + diff --git a/pip-21.3.1.tar.gz b/pip-21.3.1.tar.gz deleted file mode 100644 index 6b33f4aea56d4470f3776fb8aca3541d5e1d94b1..0000000000000000000000000000000000000000 Binary files a/pip-21.3.1.tar.gz and /dev/null differ diff --git a/pip-22.2.2.tar.gz b/pip-22.2.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..7a716c4aa0304a6c0677fc1176d102c49a1a8960 Binary files /dev/null and b/pip-22.2.2.tar.gz differ diff --git a/pip-allow-older-versions.patch b/pip-allow-different-versions.patch similarity index 96% rename from pip-allow-older-versions.patch rename to pip-allow-different-versions.patch index 74fb01e00cc2ed214ea8fd43f833275a9c8082b8..4a1151743787811004ff3c6314013d7392d9bc2d 100644 --- a/pip-allow-older-versions.patch +++ b/pip-allow-different-versions.patch @@ -1,27 +1,27 @@ ---- /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()) +--- /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 5c05fb5e41911e01874594842c5a65970dface20..47462e46f4aff7279db5aa88c2ce1dd78329b370 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -1,64 +1,173 @@ +%if 0%{?rhel} >= 9 && !0%{?epel} +%bcond_with tests +%bcond_with doc +%else +%bcond_without tests +%bcond_without doc +%endif + %global srcname pip -%global python_wheelname %{srcname}-%{version}-py3-none-any.whl -%global python_wheeldir %{_datadir}/python-wheels -%global _description \ -pip is the package installer for Python. You can use pip to install packages from the Python Package Index and other indexes. -%global bashcompdir %(b=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null); echo ${b:-%{_sysconfdir}/bash_completion.d}) +%global base_version 22.2.2 +%global upstream_version %{base_version}%{?prerel} +%global python_wheel_name %{srcname}-%{upstream_version}-py3-none-any.whl +%global bashcompdir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null) + Name: python-%{srcname} -Version: 21.3.1 -Release: 3 +Version: %{base_version}%{?prerel:~%{prerel}} +Release: 1 Summary: A tool for installing and managing Python packages License: MIT and Python and ASL 2.0 and BSD and ISC and LGPLv2 and MPLv2.0 and (ASL 2.0 or BSD) -URL: http://www.pip-installer.org -Source0: %{pypi_source} +URL: https://pip.pypa.io/ +Source0: https://github.com/pypa/pip/archive/%{upstream_version}/%{srcname}-%{upstream_version}.tar.gz BuildArch: noarch -Patch1: allow-stripping-given-prefix-from-wheel-RECORD-files.patch -Patch2: emit-a-warning-when-running-with-root-privileges.patch -Patch3: remove-existing-dist-only-if-path-conflicts.patch -Patch6000: dummy-certifi.patch -Source10: pip-allow-older-versions.patch +%if %{with tests} +BuildRequires: /usr/bin/git +BuildRequires: /usr/bin/hg +BuildRequires: /usr/bin/bzr +BuildRequires: /usr/bin/svn +BuildRequires: python-setuptools-wheel +BuildRequires: python-wheel-wheel +%endif -%description %{_description} +Patch: remove-existing-dist-only-if-path-conflicts.patch +Patch: dummy-certifi.patch +Patch: nowarn-pip._internal.main.patch +Patch: no-version-warning.patch +Patch: bad-metadata-fix.patch +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 +(PyPI). pip is a recursive acronym that can stand for either "Pip Installs +Packages" or "Pip Installs Python". + +%global bundled() %{expand: +Provides: bundled(python%{1}dist(cachecontrol)) = 0.12.11 +Provides: bundled(python%{1}dist(certifi)) = 2022.6.15 +Provides: bundled(python%{1}dist(chardet)) = 5 +Provides: bundled(python%{1}dist(colorama)) = 0.4.5 +Provides: bundled(python%{1}dist(distlib)) = 0.3.5 +Provides: bundled(python%{1}dist(distro)) = 1.7 +Provides: bundled(python%{1}dist(idna)) = 3.3 +Provides: bundled(python%{1}dist(msgpack)) = 1.0.4 +Provides: bundled(python%{1}dist(packaging)) = 21.3 +Provides: bundled(python%{1}dist(pep517)) = 0.12 +Provides: bundled(python%{1}dist(platformdirs)) = 2.5.2 +Provides: bundled(python%{1}dist(pygments)) = 2.12 +Provides: bundled(python%{1}dist(pyparsing)) = 3.0.9 +Provides: bundled(python%{1}dist(requests)) = 2.28.1 +Provides: bundled(python%{1}dist(resolvelib)) = 0.8.1 +Provides: bundled(python%{1}dist(rich)) = 12.5.1 +Provides: bundled(python%{1}dist(setuptools)) = 44 +Provides: bundled(python%{1}dist(six)) = 1.16 +Provides: bundled(python%{1}dist(tenacity)) = 8.0.1 +Provides: bundled(python%{1}dist(tomli)) = 2.0.1 +Provides: bundled(python%{1}dist(typing-extensions)) = 4.3 +Provides: bundled(python%{1}dist(urllib3)) = 1.26.10 +Provides: bundled(python%{1}dist(webencodings)) = 0.5.1 +} +%global crypt_compat_recommends() %{expand: +Recommends: (libcrypt.so.1()(64bit) if python%{1}(x86-64)) +Recommends: (libcrypt.so.1 if python%{1}(x86-32)) +} %package -n python%{python3_pkgversion}-%{srcname} -Summary: %{summary} -BuildRequires: python%{python3_pkgversion}-devel python%{python3_pkgversion}-setuptools bash-completion ca-certificates -Requires: python%{python3_pkgversion}-setuptools ca-certificates +Summary: A tool for installing and managing Python3 packages + +BuildRequires: python%{python3_pkgversion}-devel +BuildRequires: python3-rpm-generators >= 11-8 +BuildRequires: python%{python3_pkgversion}-setuptools +BuildRequires: bash-completion +%if %{with tests} +BuildRequires: python%{python3_pkgversion}-cryptography +BuildRequires: python%{python3_pkgversion}-mock +BuildRequires: python%{python3_pkgversion}-pytest +BuildRequires: python%{python3_pkgversion}-pretend +BuildRequires: python%{python3_pkgversion}-freezegun +BuildRequires: python%{python3_pkgversion}-scripttest +BuildRequires: python%{python3_pkgversion}-virtualenv +BuildRequires: python%{python3_pkgversion}-werkzeug +BuildRequires: python%{python3_pkgversion}-pyyaml +BuildRequires: python%{python3_pkgversion}-tomli-w +BuildRequires: python%{python3_pkgversion}-installer +%endif BuildRequires: python%{python3_pkgversion}-wheel -%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}} -Provides: python%{python3_pkgversion}dist(pip) = %{version} -Provides: python%{python3_version}dist(pip) = %{version} -%description -n python%{python3_pkgversion}-%{srcname} %{_description} +BuildRequires: ca-certificates +Requires: ca-certificates +Recommends: python%{python3_pkgversion}-setuptools + +%{bundled 3} +Provides: pip = %{version}-%{release} +Conflicts: python-pip < %{version}-%{release} +Requires: python3-libs >= 3.11.0~rc1-2 + +%{crypt_compat_recommends 3} + +%description -n python%{python3_pkgversion}-%{srcname} +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 +(PyPI). pip is a recursive acronym that can stand for either "Pip Installs +Packages" or "Pip Installs Python". -%package_help +%if %{with doc} +%package doc +Summary: A documentation for a tool for installing and managing Python packages +BuildRequires: python%{python3_pkgversion}-sphinx +BuildRequires: python%{python3_pkgversion}-sphinx-inline-tabs +BuildRequires: python%{python3_pkgversion}-sphinx-copybutton +BuildRequires: python%{python3_pkgversion}-myst-parser + +%description doc +A documentation for a tool for installing and managing Python packages -%package wheel +%endif + +%package -n %{python_wheel_pkg_prefix}-%{srcname}-wheel Summary: The pip wheel Requires: ca-certificates -%description wheel -A Python wheel of pip to use with venv +%{bundled 3} -%prep -%autosetup -n %{srcname}-%{version} -p1 +%{crypt_compat_recommends 3} -# this goes together with Patch6000 +%description -n %{python_wheel_pkg_prefix}-%{srcname}-wheel +A Python wheel of pip to use with venv. + +%prep +%autosetup -p1 -n %{srcname}-%{upstream_version} rm src/pip/_vendor/certifi/*.pem -sed -i '/\.pem$/d' src/pip.egg-info/SOURCES.txt +sed -i '/html_theme = "furo"/d' docs/html/conf.py +sed -i '/"sphinxcontrib.towncrier",/d' docs/html/conf.py +ln -s %{python_wheel_dir} tests/data/common_wheels +rm -v src/pip/_vendor/distlib/*.exe +sed -i '/\.exe/d' setup.py %build %py3_build_wheel +%if %{with doc} +export PYTHONPATH=./src/ +sphinx-build-3 -b html docs/html docs/build/html +sphinx-build-3 -b man docs/man docs/build/man -c docs/html +rm -rf docs/build/html/{.doctrees,.buildinfo} +%endif + + %install -%{__python3} dist/%{python_wheelname}/pip install \ +%{python3} dist/%{python_wheel_name}/pip install \ --root %{buildroot} \ --no-deps \ - --no-cache-dir \ - --no-index \ + --disable-pip-version-check \ + --progress-bar off \ + --verbose \ --ignore-installed \ + --no-warn-script-location \ + --no-index \ + --no-cache-dir \ --find-links dist \ - 'pip==%{version}' + 'pip==%{upstream_version}' %if %{with doc} pushd docs/build/man @@ -71,55 +180,74 @@ done 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 \ > %{buildroot}%{bashcompdir}/pip3 - -# Make bash completion apply to all the 5 symlinks we install sed -i -e "s/^\\(complete.*\\) pip\$/\\1 pip pip{,-}{3,%{python3_version}}/" \ -e s/_pip_completion/_pip3_completion/ \ %{buildroot}%{bashcompdir}/pip3 - -# Provide symlinks to executables to comply with Fedora guidelines for Python ln -s ./pip%{python3_version} %{buildroot}%{_bindir}/pip-%{python3_version} ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3 - -# Make sure the INSTALLER is not pip and remove RECORD, otherwise Patch2 won't work -# %%pyproject macros do this for all packages -echo rpm > %{buildroot}%{python3_sitelib}/pip-%{version}.dist-info/INSTALLER -rm %{buildroot}%{python3_sitelib}/pip-%{version}.dist-info/RECORD - -mkdir -p %{buildroot}%{python_wheeldir} -install -p dist/%{python_wheelname} -t %{buildroot}%{python_wheeldir} +echo rpm > %{buildroot}%{python3_sitelib}/pip-%{upstream_version}.dist-info/INSTALLER +rm %{buildroot}%{python3_sitelib}/pip-%{upstream_version}.dist-info/RECORD +mkdir -p %{buildroot}%{python_wheel_dir} +install -p dist/%{python_wheel_name} -t %{buildroot}%{python_wheel_dir} + +%if %{with tests} +%check +%{_rpmconfigdir}/pythonbundles.py src/pip/_vendor/vendor.txt --compare-with '%{bundled 3}' +pytest_k='not completion and + not test_pep517_and_build_options and + not test_config_file_venv_option and + not test_from_link_vcs_with_source_dir_obtains_commit_id and + not test_from_link_vcs_without_source_dir and + not test_should_cache_git_sha' +%pytest -m 'not network' -k "$(echo $pytest_k)" \ + --deselect tests/functional --deselect tests/lib/test_lib.py --deselect tests/unit/test_build_env.py +%endif %files -n python%{python3_pkgversion}-%{srcname} -%license LICENSE.txt +%doc README.rst +%license %{python3_sitelib}/pip-%{upstream_version}.dist-info/LICENSE.txt +%if %{with doc} +%{_mandir}/man1/pip.* +%{_mandir}/man1/pip-*.* +%{_mandir}/man1/pip3.* +%{_mandir}/man1/pip3-*.* +%endif %{_bindir}/pip %{_bindir}/pip3 -%{_bindir}/pip-3* +%{_bindir}/pip-3 %{_bindir}/pip%{python3_version} +%{_bindir}/pip-%{python3_version} %{python3_sitelib}/pip* %dir %{bashcompdir} -%{bashcompdir}/pip3* -%dir %(dirname %{bashcompdir}) +%{bashcompdir}/pip3 -%files help +%if %{with doc} +%files doc +%license LICENSE.txt %doc README.rst +%doc docs/build/html +%endif -%files wheel +%files -n %{python_wheel_pkg_prefix}-%{srcname}-wheel %license LICENSE.txt -%dir %{python_wheeldir}/ -%{python_wheeldir}/%{python_wheelname} +# we own the dir for simplicity +%dir %{python_wheel_dir}/ +%{python_wheel_dir}/%{python_wheel_name} %changelog +* Tue Nov 15 2022 hkgy - 22.2.2-1 +- Upgrade to v22.2.2 + * Wed Aug 03 2022 renhongxun - 21.3.1-3 - provides python3.10dist(pip) and python3dist(pip) diff --git a/remove-existing-dist-only-if-path-conflicts.patch b/remove-existing-dist-only-if-path-conflicts.patch index 7ff95e55db1c7c286e36c9b17d338142aaf50266..3a9ea2590ad04677710c92d1494df0a0a6d66c76 100644 --- a/remove-existing-dist-only-if-path-conflicts.patch +++ b/remove-existing-dist-only-if-path-conflicts.patch @@ -1,14 +1,12 @@ -From 517656ed4520b09ac6365467e459778f94ca2f0c Mon Sep 17 00:00:00 2001 -From: Karolina Surma -Date: Mon, 10 May 2021 18:16:20 +0200 +From 2c3f3a590ddfc151a456b44a5f96f0f603d178e9 Mon Sep 17 00:00:00 2001 +From: Lumir Balhar +Date: Wed, 16 Feb 2022 08:36:21 +0100 Subject: [PATCH] Prevent removing of the system packages installed under - /usr/lib + /usr/lib when pip install --upgrade is executed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -when pip install --upgrade is executed. - Resolves: rhbz#1550368 Co-Authored-By: Michal Cyprian @@ -16,59 +14,74 @@ Co-Authored-By: Victor Stinner Co-Authored-By: Petr Viktorin Co-Authored-By: Lumir Balhar Co-Authored-By: Miro HronĨok +Co-Authored-By: Karolina Surma --- - src/pip/_internal/req/req_install.py | 3 ++- - src/pip/_internal/resolution/legacy/resolver.py | 5 ++++- - src/pip/_internal/resolution/resolvelib/factory.py | 13 +++++++++++++ - src/pip/_internal/utils/misc.py | 11 +++++++++++ - 4 files changed, 30 insertions(+), 2 deletions(-) + src/pip/_internal/metadata/base.py | 12 +++++++++++- + src/pip/_internal/req/req_install.py | 2 +- + src/pip/_internal/resolution/legacy/resolver.py | 4 +++- + src/pip/_internal/resolution/resolvelib/factory.py | 12 ++++++++++++ + 4 files changed, 27 insertions(+), 3 deletions(-) +diff --git a/src/pip/_internal/metadata/base.py b/src/pip/_internal/metadata/base.py +index 151fd6d..f9109cd 100644 +--- a/src/pip/_internal/metadata/base.py ++++ b/src/pip/_internal/metadata/base.py +@@ -28,7 +28,7 @@ from pip._vendor.packaging.utils import NormalizedName + from pip._vendor.packaging.version import LegacyVersion, Version + + from pip._internal.exceptions import NoneMetadataError +-from pip._internal.locations import site_packages, user_site ++from pip._internal.locations import get_scheme, site_packages, user_site + from pip._internal.models.direct_url import ( + DIRECT_URL_METADATA_NAME, + DirectUrl, +@@ -560,6 +560,16 @@ class BaseDistribution(Protocol): + for extra in self._iter_egg_info_extras(): + metadata["Provides-Extra"] = extra + ++ @property ++ def in_install_path(self) -> bool: ++ """ ++ Return True if given Distribution is installed in ++ path matching distutils_scheme layout. ++ """ ++ norm_path = normalize_path(self.installed_location) ++ return norm_path.startswith(normalize_path( ++ get_scheme("").purelib.split('python')[0])) ++ + + class BaseEnvironment: + """An environment containing distributions to introspect.""" diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py -index ff0dd2f..a72aec8 100644 +index a1e376c..ed7facf 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py -@@ -46,6 +46,7 @@ from pip._internal.utils.misc import ( - ask_path_exists, - backup_dir, - display_path, -+ dist_in_install_path, - dist_in_site_packages, - dist_in_usersite, - get_distribution, -@@ -433,7 +434,7 @@ class InstallRequirement: - existing_dist.project_name, existing_dist.location - ) +@@ -416,7 +416,7 @@ class InstallRequirement: + f"lack sys.path precedence to {existing_dist.raw_name} " + f"in {existing_dist.location}" ) - else: -+ elif dist_in_install_path(existing_dist): ++ elif existing_dist.in_install_path: self.should_reinstall = True else: if self.editable: diff --git a/src/pip/_internal/resolution/legacy/resolver.py b/src/pip/_internal/resolution/legacy/resolver.py -index 09caaa6..c1542ec 100644 +index fb49d41..040f2c1 100644 --- a/src/pip/_internal/resolution/legacy/resolver.py +++ b/src/pip/_internal/resolution/legacy/resolver.py -@@ -44,6 +44,7 @@ from pip._internal.resolution.base import BaseResolver, InstallRequirementProvid - from pip._internal.utils.compatibility_tags import get_supported - from pip._internal.utils.logging import indent_log - from pip._internal.utils.misc import dist_in_usersite, normalize_version_info -+from pip._internal.utils.misc import dist_in_install_path - from pip._internal.utils.packaging import check_requires_python - - logger = logging.getLogger(__name__) -@@ -203,7 +204,9 @@ class Resolver(BaseResolver): +@@ -325,7 +325,9 @@ class Resolver(BaseResolver): """ # Don't uninstall the conflict if doing a user install and the # conflict is not a user install. -- if not self.use_user_site or dist_in_usersite(req.satisfied_by): +- if not self.use_user_site or req.satisfied_by.in_usersite: + if ((not self.use_user_site -+ or dist_in_usersite(req.satisfied_by)) -+ and dist_in_install_path(req.satisfied_by)): ++ or req.satisfied_by.in_usersite) ++ and req.satisfied_by.in_install_path): req.should_reinstall = True req.satisfied_by = None diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py -index 766dc26..c8c1cd8 100644 +index a4c24b5..e7e2da9 100644 --- a/src/pip/_internal/resolution/resolvelib/factory.py +++ b/src/pip/_internal/resolution/resolvelib/factory.py @@ -1,6 +1,8 @@ @@ -80,32 +93,16 @@ index 766dc26..c8c1cd8 100644 from typing import ( TYPE_CHECKING, Dict, -@@ -33,6 +34,7 @@ from pip._internal.exceptions import ( - UnsupportedWheel, - ) - from pip._internal.index.package_finder import PackageFinder -+from pip._internal.locations import get_scheme - from pip._internal.metadata import BaseDistribution, get_default_environment - from pip._internal.models.link import Link - from pip._internal.models.wheel import Wheel -@@ -45,6 +47,7 @@ from pip._internal.req.req_install import ( - from pip._internal.resolution.base import InstallRequirementProvider - from pip._internal.utils.compatibility_tags import get_supported - from pip._internal.utils.hashes import Hashes -+from pip._internal.utils.misc import dist_location - from pip._internal.utils.packaging import get_requirement - from pip._internal.utils.virtualenv import running_under_virtualenv - -@@ -526,6 +529,16 @@ class Factory: +@@ -549,6 +551,16 @@ class Factory: if dist is None: # Not installed, no uninstallation required. return None + # Prevent uninstalling packages from /usr + try: -+ if dist_location(dist._dist) in ( -+ sysconfig.get_path('purelib', scheme='rpm_prefix', vars={'base': sys.base_prefix}), -+ sysconfig.get_path('platlib', scheme='rpm_prefix', vars={'base': sys.base_prefix}), -+ ): ++ if dist.installed_location in ( ++ sysconfig.get_path('purelib', scheme='posix_prefix', vars={'base': sys.base_prefix}), ++ sysconfig.get_path('platlib', scheme='posix_prefix', vars={'platbase': sys.base_prefix}), ++ ): + return None + except KeyError: # this Python doesn't have 'rpm_prefix' scheme yet + pass @@ -113,35 +110,6 @@ index 766dc26..c8c1cd8 100644 # We're installing into global site. The current installation must # be uninstalled, no matter it's in global or user site, because the # user site installation has precedence over global. -diff --git a/src/pip/_internal/utils/misc.py b/src/pip/_internal/utils/misc.py -index d3e9053..d25d1c3 100644 ---- a/src/pip/_internal/utils/misc.py -+++ b/src/pip/_internal/utils/misc.py -@@ -38,6 +38,7 @@ from pip._vendor.tenacity import retry, stop_after_delay, wait_fixed - from pip import __version__ - from pip._internal.exceptions import CommandError - from pip._internal.locations import get_major_minor_version, site_packages, user_site -+from pip._internal.locations import get_scheme - from pip._internal.utils.compat import WINDOWS - from pip._internal.utils.egg_link import egg_link_path_from_location - from pip._internal.utils.virtualenv import running_under_virtualenv -@@ -354,6 +355,16 @@ def dist_in_site_packages(dist: Distribution) -> bool: - return dist_location(dist).startswith(normalize_path(site_packages)) - - -+def dist_in_install_path(dist): -+ """ -+ Return True if given Distribution is installed in -+ path matching distutils_scheme layout. -+ """ -+ norm_path = normalize_path(dist_location(dist)) -+ return norm_path.startswith(normalize_path( -+ get_scheme("").purelib.split('python')[0])) -+ -+ - def get_distribution(req_name: str) -> Optional[Distribution]: - """Given a requirement name, return the installed Distribution object. - -- -2.32.0 +2.35.3