| |
@@ -1,7 +1,7 @@
|
| |
- From 854fd7296bb9306d46ba3cc8bb7c6f18a7960ed6 Mon Sep 17 00:00:00 2001
|
| |
- From: Tomas Hrnciar <thrnciar@redhat.com>
|
| |
- Date: Sun, 26 Apr 2020 21:19:03 +0200
|
| |
- Subject: [PATCH] Prevent removing of the system packages installed under
|
| |
+ From 0c41df7c4161de2453d5161382a3bbfc7178bec6 Mon Sep 17 00:00:00 2001
|
| |
+ From: Lumir Balhar <lbalhar@redhat.com>
|
| |
+ Date: Tue, 26 Jan 2021 09:05:07 +0100
|
| |
+ Subject: [PATCH] Prevent removing of the system packages installed under
|
| |
/usr/lib
|
| |
|
| |
when pip install -U is executed.
|
| |
@@ -12,11 +12,17 @@
|
| |
Co-Authored-By: Victor Stinner <vstinner@redhat.com>
|
| |
Co-Authored-By: Petr Viktorin <pviktori@redhat.com>
|
| |
---
|
| |
+ src/pip/_internal/req/req_install.py | 3 ++-
|
| |
+ src/pip/_internal/resolution/legacy/resolver.py | 5 ++++-
|
| |
+ src/pip/_internal/resolution/resolvelib/factory.py | 10 ++++++++++
|
| |
+ src/pip/_internal/utils/misc.py | 11 +++++++++++
|
| |
+ 4 files changed, 27 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
|
| |
+ index 6d0aa30..0a5f8ed 100644
|
| |
--- a/src/pip/_internal/req/req_install.py
|
| |
+++ b/src/pip/_internal/req/req_install.py
|
| |
- @@ -41,6 +41,7 @@ from pip._internal.utils.misc import (
|
| |
+ @@ -39,6 +39,7 @@ from pip._internal.utils.misc import (
|
| |
ask_path_exists,
|
| |
backup_dir,
|
| |
display_path,
|
| |
@@ -24,7 +30,7 @@
|
| |
dist_in_site_packages,
|
| |
dist_in_usersite,
|
| |
get_distribution,
|
| |
- @@ -447,7 +448,7 @@ class InstallRequirement(object):
|
| |
+ @@ -445,7 +446,7 @@ class InstallRequirement:
|
| |
"lack sys.path precedence to {} in {}".format(
|
| |
existing_dist.project_name, existing_dist.location)
|
| |
)
|
| |
@@ -34,7 +40,7 @@
|
| |
else:
|
| |
if self.editable:
|
| |
diff --git a/src/pip/_internal/resolution/legacy/resolver.py b/src/pip/_internal/resolution/legacy/resolver.py
|
| |
- index c9b4c66..ff361d8 100644
|
| |
+ index 665dba1..a219e63 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
|
| |
@@ -56,44 +62,18 @@
|
| |
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 24a7455..5fd48d3 100644
|
| |
- --- a/src/pip/_internal/utils/misc.py
|
| |
- +++ b/src/pip/_internal/utils/misc.py
|
| |
- @@ -31,7 +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 get_major_minor_version, site_packages, user_site
|
| |
- +from pip._internal.locations import distutils_scheme, get_major_minor_version, site_packages, user_site
|
| |
- from pip._internal.utils.compat import WINDOWS, expanduser, stdlib_pkgs, str_to_display
|
| |
- from pip._internal.utils.typing import MYPY_CHECK_RUNNING, cast
|
| |
- from pip._internal.utils.virtualenv import (
|
| |
- @@ -406,6 +406,16 @@ 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
|
| |
- """
|
| |
+ diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py
|
| |
+ index bfaa052..68915aa 100644
|
| |
--- a/src/pip/_internal/resolution/resolvelib/factory.py
|
| |
+++ b/src/pip/_internal/resolution/resolvelib/factory.py
|
| |
- @@ -1,3 +1,4 @@
|
| |
+ @@ -1,4 +1,5 @@
|
| |
import logging
|
| |
+import sys
|
| |
|
| |
from pip._vendor.packaging.utils import canonicalize_name
|
| |
- @@ -17,5 +18,7 @@
|
| |
+
|
| |
+ @@ -18,7 +19,9 @@ from pip._internal.utils.misc import (
|
| |
+ dist_in_site_packages,
|
| |
dist_in_usersite,
|
| |
get_installed_distributions,
|
| |
+ dist_location,
|
| |
@@ -101,7 +81,9 @@
|
| |
+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 @@
|
| |
+
|
| |
+ @@ -365,6 +368,13 @@ class Factory:
|
| |
+ if dist is None: # Not installed, no uninstallation required.
|
| |
return None
|
| |
|
| |
+ # Prevent uninstalling packages from /usr
|
| |
@@ -113,6 +95,36 @@
|
| |
+
|
| |
# 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 6dd94e2..7925518 100644
|
| |
+ --- a/src/pip/_internal/utils/misc.py
|
| |
+ +++ b/src/pip/_internal/utils/misc.py
|
| |
+ @@ -27,6 +27,7 @@ from pip._vendor.retrying import retry # type: ignore
|
| |
+ 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 distutils_scheme, get_major_minor_version, site_packages, user_site
|
| |
+ from pip._internal.utils.compat import WINDOWS, stdlib_pkgs
|
| |
+ from pip._internal.utils.typing import MYPY_CHECK_RUNNING, cast
|
| |
+ from pip._internal.utils.virtualenv import (
|
| |
+ @@ -398,6 +399,16 @@ 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.25.4
|
| |
+ 2.29.2
|
| |
|
| |
Support for Python 3.5 is dropped but this version in rawhide already uses bundled wheels.