Fix broken uninstallation by a bogus downstream patch

In pip 21.2, the Distribution here is a wrapper around the regular Distribution.
It has a limited set of API defined by the BaseDistribution protocol.
dist_location() uses the project_name attribute under the hood --
and that is not part of the API.

If we ever upstream this, we should make this check a property of BaseDistribution.
But, for now, we hotfix it by accessing the private wrapped Distribution object directly.
Yes, this is ugly.
This commit is contained in:
Miro Hrončok 2021-08-16 12:26:06 +02:00
parent d7a96d26f4
commit 192c4aebdf
2 changed files with 8 additions and 4 deletions

View File

@ -22,7 +22,7 @@
Name: python-%{srcname} Name: python-%{srcname}
Version: %{base_version}%{?prerel:~%{prerel}} Version: %{base_version}%{?prerel:~%{prerel}}
Release: 1%{?dist} Release: 2%{?dist}
Summary: A tool for installing and managing Python packages Summary: A tool for installing and managing Python packages
# We bundle a lot of libraries with pip, which itself is under MIT license. # We bundle a lot of libraries with pip, which itself is under MIT license.
@ -391,6 +391,9 @@ pytest_k='not completion and
%{python_wheeldir}/%{python_wheelname} %{python_wheeldir}/%{python_wheelname}
%changelog %changelog
* Mon Aug 16 2021 Miro Hrončok <mhroncok@redhat.com> - 21.2.3-2
- Fix broken uninstallation by a bogus downstream patch
* Mon Aug 09 2021 Miro Hrončok <mhroncok@redhat.com> - 21.2.3-1 * Mon Aug 09 2021 Miro Hrončok <mhroncok@redhat.com> - 21.2.3-1
- Update to 21.2.3 - Update to 21.2.3
- Resolves: rhbz#1985635 - Resolves: rhbz#1985635

View File

@ -1,4 +1,4 @@
From a722cbefa5e1a4bf5357f13852fa927a46fcd624 Mon Sep 17 00:00:00 2001 From aca0c9df4ef54f70a3fedb07f4faac463f88a331 Mon Sep 17 00:00:00 2001
From: Karolina Surma <ksurma@redhat.com> From: Karolina Surma <ksurma@redhat.com>
Date: Mon, 10 May 2021 18:16:20 +0200 Date: Mon, 10 May 2021 18:16:20 +0200
Subject: [PATCH] Prevent removing of the system packages installed under Subject: [PATCH] Prevent removing of the system packages installed under
@ -12,6 +12,7 @@ Co-Authored-By: Michal Cyprian <m.cyprian@gmail.com>
Co-Authored-By: Victor Stinner <vstinner@redhat.com> Co-Authored-By: Victor Stinner <vstinner@redhat.com>
Co-Authored-By: Petr Viktorin <pviktori@redhat.com> Co-Authored-By: Petr Viktorin <pviktori@redhat.com>
Co-Authored-By: Lumir Balhar <lbalhar@redhat.com> Co-Authored-By: Lumir Balhar <lbalhar@redhat.com>
Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
--- ---
src/pip/_internal/req/req_install.py | 3 ++- src/pip/_internal/req/req_install.py | 3 ++-
src/pip/_internal/resolution/legacy/resolver.py | 5 ++++- src/pip/_internal/resolution/legacy/resolver.py | 5 ++++-
@ -64,7 +65,7 @@ index 4df8f7e..dda2292 100644
req.satisfied_by = None req.satisfied_by = None
diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py
index e7fd344..e36f025 100644 index e7fd344..555e657 100644
--- a/src/pip/_internal/resolution/resolvelib/factory.py --- a/src/pip/_internal/resolution/resolvelib/factory.py
+++ b/src/pip/_internal/resolution/resolvelib/factory.py +++ b/src/pip/_internal/resolution/resolvelib/factory.py
@@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
@ -96,7 +97,7 @@ index e7fd344..e36f025 100644
return None return None
+ # Prevent uninstalling packages from /usr + # Prevent uninstalling packages from /usr
+ if dist_location(dist) in ( + if dist_location(dist._dist) in (
+ get_scheme('', prefix=sys.base_prefix).purelib, + get_scheme('', prefix=sys.base_prefix).purelib,
+ get_scheme('', prefix=sys.base_prefix).platlib, + get_scheme('', prefix=sys.base_prefix).platlib,
+ ): + ):