From 6eac568430dd51111226d96605b9fefcde20f1aa Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 3 Dec 2020 11:21:56 +0100 Subject: [PATCH] Patch the new resolver to not uninstall from /usr/lib on updates --- ...existing-dist-only-if-path-conflicts.patch | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/remove-existing-dist-only-if-path-conflicts.patch b/remove-existing-dist-only-if-path-conflicts.patch index 08279c8..328d2d5 100644 --- a/remove-existing-dist-only-if-path-conflicts.patch +++ b/remove-existing-dist-only-if-path-conflicts.patch @@ -10,12 +10,8 @@ Resolves: rhbz#1550368 Co-Authored-By: Michal Cyprian Co-Authored-By: Victor Stinner +Co-Authored-By: Petr Viktorin --- - src/pip/_internal/req/req_install.py | 3 ++- - src/pip/_internal/resolution/legacy/resolver.py | 5 ++++- - src/pip/_internal/utils/misc.py | 11 +++++++++++ - 3 files changed, 17 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 @@ -90,6 +86,33 @@ index 24a7455..5fd48d3 100644 def dist_is_editable(dist): # type: (Distribution) -> bool """ +--- a/src/pip/_internal/resolution/resolvelib/factory.py ++++ b/src/pip/_internal/resolution/resolvelib/factory.py +@@ -1,3 +1,4 @@ + import logging ++import sys + + from pip._vendor.packaging.utils import canonicalize_name +@@ -17,5 +18,7 @@ + dist_in_usersite, + get_installed_distributions, ++ dist_location, + ) ++from pip._internal.locations import distutils_scheme + from pip._internal.utils.typing import MYPY_CHECK_RUNNING + from pip._internal.utils.virtualenv import running_under_virtualenv +@@ -313,4 +316,11 @@ + return None + ++ # Prevent uninstalling packages from /usr ++ if dist_location(dist) in ( ++ distutils_scheme('', prefix=sys.base_prefix)['purelib'], ++ distutils_scheme('', prefix=sys.base_prefix)['platlib'], ++ ): ++ return None ++ + # We're installing into global site. The current installation must + # be uninstalled, no matter it's in global or user site, because the -- 2.25.4