diff --git a/python-pip.spec b/python-pip.spec index 4161ad0c0313cd459601d343afe863bb6591e4b9..3d21f6fd50771125be982ee17deb1cdd27daa89e 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -6,7 +6,7 @@ pip is the package installer for Python. You can use pip to install packages fro %global bashcompdir %(b=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null); echo ${b:-%{_sysconfdir}/bash_completion.d}) Name: python-%{srcname} Version: 21.3.1 -Release: 1 +Release: 2 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 @@ -14,6 +14,7 @@ Source0: %{pypi_source} 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 @@ -117,6 +118,9 @@ install -p dist/%{python_wheelname} -t %{buildroot}%{python_wheeldir} %{python_wheeldir}/%{python_wheelname} %changelog +* Mon May 23 2022 renhongxun - 21.3.1-2 +- sync a left patch from sp3 + * Mon Dec 20 2021 renhongxun - 21.3.1-1 - upgrade version to 21.3.1 diff --git a/remove-existing-dist-only-if-path-conflicts.patch b/remove-existing-dist-only-if-path-conflicts.patch new file mode 100644 index 0000000000000000000000000000000000000000..99171ecaa935c6ee1cb11451e139d3f20f6ab55b --- /dev/null +++ b/remove-existing-dist-only-if-path-conflicts.patch @@ -0,0 +1,90 @@ +From d381c59fdc15949c4dc293bd92bbccb60289a703 Mon Sep 17 00:00:00 2001 +From: Tomas Hrnciar +Date: Sun, 26 Apr 2020 21:19:03 +0200 +Subject: [PATCH] Prevent removing of the system packages installed under + /usr/lib + +when pip install -U is executed. + +Resolves: rhbz#1550368 + +--- + src/pip/_internal/req/req_install.py | 3 ++- + src/pip/_internal/resolution/legacy/resolver.py | 5 ++++- + src/pip/_internal/utils/misc.py | 9 +++++++++ + 3 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py +index 4759f4a..2e76e35 100644 +--- a/src/pip/_internal/req/req_install.py ++++ b/src/pip/_internal/req/req_install.py +@@ -39,6 +39,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, +@@ -446,7 +447,7 @@ class InstallRequirement(object): + "lack sys.path precedence to {} in {}".format( + existing_dist.project_name, existing_dist.location) + ) +- else: ++ elif dist_in_install_path(existing_dist): + 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 c9b4c66..8b98ebd 100644 +--- a/src/pip/_internal/resolution/legacy/resolver.py ++++ b/src/pip/_internal/resolution/legacy/resolver.py +@@ -34,6 +34,7 @@ from pip._internal.resolution.base import BaseResolver + 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, + get_requires_python, +@@ -207,7 +208,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 dist_in_usersite(req.satisfied_by)) ++ and dist_in_install_path(req.satisfied_by)): + req.should_reinstall = True + req.satisfied_by = None + +diff --git a/src/pip/_internal/utils/misc.py b/src/pip/_internal/utils/misc.py +index 5629c60..6bd6daa 100644 +--- a/src/pip/_internal/utils/misc.py ++++ b/src/pip/_internal/utils/misc.py +@@ -31,6 +31,7 @@ from pip._vendor.six.moves.urllib.parse import unquote as urllib_unquote + from pip import __version__ + from pip._internal.exceptions import CommandError + from pip._internal.locations import ( ++ distutils_scheme, + get_major_minor_version, + site_packages, + user_site, +@@ -402,6 +403,14 @@ def dist_in_site_packages(dist): + """ + 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( ++ distutils_scheme("")['purelib'].split('python')[0])) + + def dist_is_editable(dist): + # type: (Distribution) -> bool +-- +2.23.0 +