commit:     cd58e32401e6e898830b6d051c5e9e7c9acd1831
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 19 13:24:44 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Feb 19 14:34:18 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cd58e324

dev-python/build: Add a patch to support unbundled pip

Bug: https://bugs.gentoo.org/934922
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 ...ld-1.2.2_p1.ebuild => build-1.2.2_p1-r1.ebuild} |  5 ++++
 .../build/files/build-1.2.2_p1-gentoo-pip.patch    | 28 ++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/dev-python/build/build-1.2.2_p1.ebuild 
b/dev-python/build/build-1.2.2_p1-r1.ebuild
similarity index 96%
rename from dev-python/build/build-1.2.2_p1.ebuild
rename to dev-python/build/build-1.2.2_p1-r1.ebuild
index ce998bf4e24a..1abc9dd82b84 100644
--- a/dev-python/build/build-1.2.2_p1.ebuild
+++ b/dev-python/build/build-1.2.2_p1-r1.ebuild
@@ -52,6 +52,11 @@ BDEPEND="
 
 distutils_enable_tests pytest
 
+PATCHES=(
+       # https://github.com/pypa/build/pull/861
+       "${FILESDIR}/${P}-gentoo-pip.patch"
+)
+
 python_test() {
        if ! has "${EPYTHON/./_}" "${PYTHON_TESTED[@]}"; then
                einfo "Skipping tests on ${EPYTHON}"

diff --git a/dev-python/build/files/build-1.2.2_p1-gentoo-pip.patch 
b/dev-python/build/files/build-1.2.2_p1-gentoo-pip.patch
new file mode 100644
index 000000000000..4335500e73a8
--- /dev/null
+++ b/dev-python/build/files/build-1.2.2_p1-gentoo-pip.patch
@@ -0,0 +1,28 @@
+diff --git a/src/build/env.py b/src/build/env.py
+index b8c7b5f6..f10cf4bf 100644
+--- a/src/build/env.py
++++ b/src/build/env.py
+@@ -11,6 +11,7 @@
+ import sysconfig
+ import tempfile
+ import typing
++import warnings
+ 
+ from collections.abc import Collection, Mapping
+ 
+@@ -158,6 +159,15 @@ def _has_valid_outer_pip(self) -> bool | None:
+         This checks for a valid global pip. Returns None if pip is missing, 
False
+         if pip is too old, and True if it can be used.
+         """
++        # `pip install --python` is nonfunctional on Gentoo debundled pip.
++        # Detect that by checking if pip._vendor` module exists.  However,
++        # searching for pip could yield warnings from _distutils_hack,
++        # so silence them.
++        with warnings.catch_warnings():
++            warnings.simplefilter('ignore')
++            if importlib.util.find_spec('pip._vendor') is None:
++                return False  # pragma: no cover
++
+         # Version to have added the `--python` option.
+         return _has_dependency('pip', '22.3')
+ 

Reply via email to