summaryrefslogtreecommitdiff
path: root/dev-python
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2025-04-28 18:53:36 +0200
committerMichał Górny <mgorny@gentoo.org>2025-04-28 18:53:36 +0200
commit7dc393d98a583b593cbc3562c5e7d2fda485c0ae (patch)
treeb04a5db5fec42ef6cb9225f6dba2c8c643551ab0 /dev-python
parent95e67f425720750367818f2d517ca8f6147b6c62 (diff)
downloadgentoo-7dc393d98a583b593cbc3562c5e7d2fda485c0ae.tar.gz
gentoo-7dc393d98a583b593cbc3562c5e7d2fda485c0ae.tar.bz2
gentoo-7dc393d98a583b593cbc3562c5e7d2fda485c0ae.zip
dev-python/pip: Fix tomli dep regression
Closes: https://bugs.gentoo.org/955029 Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python')
-rw-r--r--dev-python/pip/files/pip-25.1-tomli-dep.patch76
-rw-r--r--dev-python/pip/pip-25.1-r1.ebuild (renamed from dev-python/pip/pip-25.1.ebuild)2
2 files changed, 78 insertions, 0 deletions
diff --git a/dev-python/pip/files/pip-25.1-tomli-dep.patch b/dev-python/pip/files/pip-25.1-tomli-dep.patch
new file mode 100644
index 000000000000..780d9a84ad35
--- /dev/null
+++ b/dev-python/pip/files/pip-25.1-tomli-dep.patch
@@ -0,0 +1,76 @@
+From 23d20ea18ab4e43a4a4cb2b721d818a8dcd62542 Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <eschwartz93@gmail.com>
+Date: Mon, 28 Apr 2025 11:42:02 -0400
+Subject: [PATCH] Fix new dependency-groups feature to use the stdlib tomllib
+ where possible
+
+Previously, commit 88c9f31ad8a5ffe0bb31ab500b8ddd1b9ff6a5dd modified pip
+to use the stdlib on versions of python where this module is in the
+stdlib. As justified there:
+
+Although a tomli copy is vendored, doing this conditional import allows:
+- automatically upgrading the code, when the time comes to drop py3.10
+ support
+
+- slightly simplifying debundling support, as it's no longer necessary
+ to depend on a tomli(-wheel)? package on sufficiently newer versions
+ of python.
+
+https://github.com/pypa/pip/pull/13065 added a new feature, including a
+vendored "dependency_groups" library that likewise supports using the
+stdlib tomllib via `dependency_groups/_toml_compat.py`. But the code in
+pip itself to use dependency_groups manually loads pyproject.toml and
+passes it to dependency_groups, and fails to use the same compatibility
+dispatch as both the pre-existing pip code and dependency_groups itself.
+
+Add back the conditional logic.
+---
+ news/13356.vendor.rst | 1 +
+ src/pip/_internal/req/req_dependency_group.py | 11 ++++++++---
+ tests/unit/test_req_dependency_group.py | 2 +-
+ 3 files changed, 10 insertions(+), 4 deletions(-)
+ create mode 100644 news/13356.vendor.rst
+
+diff --git a/src/pip/_internal/req/req_dependency_group.py b/src/pip/_internal/req/req_dependency_group.py
+index 8f124de5b81..e81dd45522a 100644
+--- a/src/pip/_internal/req/req_dependency_group.py
++++ b/src/pip/_internal/req/req_dependency_group.py
+@@ -1,6 +1,11 @@
++import sys
+ from typing import Any, Dict, Iterable, Iterator, List, Tuple
+
+-from pip._vendor import tomli
++if sys.version_info >= (3, 11):
++ import tomllib
++else:
++ from pip._vendor import tomli as tomllib
++
+ from pip._vendor.dependency_groups import DependencyGroupResolver
+
+ from pip._internal.exceptions import InstallationError
+@@ -65,10 +70,10 @@ def _load_pyproject(path: str) -> Dict[str, Any]:
+ """
+ try:
+ with open(path, "rb") as fp:
+- return tomli.load(fp)
++ return tomllib.load(fp)
+ except FileNotFoundError:
+ raise InstallationError(f"{path} not found. Cannot resolve '--group' option.")
+- except tomli.TOMLDecodeError as e:
++ except tomllib.TOMLDecodeError as e:
+ raise InstallationError(f"Error parsing {path}: {e}") from e
+ except OSError as e:
+ raise InstallationError(f"Error reading {path}: {e}") from e
+diff --git a/tests/unit/test_req_dependency_group.py b/tests/unit/test_req_dependency_group.py
+index b596f6fc5d7..1b180f8d7f8 100644
+--- a/tests/unit/test_req_dependency_group.py
++++ b/tests/unit/test_req_dependency_group.py
+@@ -120,7 +120,7 @@ def epipe_toml_load(*args: Any, **kwargs: Any) -> None:
+ raise OSError(errno.EPIPE, "Broken pipe")
+
+ monkeypatch.setattr(
+- "pip._internal.req.req_dependency_group.tomli.load", epipe_toml_load
++ "pip._internal.req.req_dependency_group.tomllib.load", epipe_toml_load
+ )
+
+ with pytest.raises(InstallationError, match=r"Error reading pyproject\.toml"):
diff --git a/dev-python/pip/pip-25.1.ebuild b/dev-python/pip/pip-25.1-r1.ebuild
index 0ae9fd71e75f..c5086ace420d 100644
--- a/dev-python/pip/pip-25.1.ebuild
+++ b/dev-python/pip/pip-25.1-r1.ebuild
@@ -78,6 +78,8 @@ python_prepare_all() {
"${FILESDIR}/pip-23.1-no-coverage.patch"
# prepare to unbundle dependencies
"${FILESDIR}/pip-25.0.1-unbundle.patch"
+ # https://github.com/pypa/pip/pull/13356
+ "${FILESDIR}/${P}-tomli-dep.patch"
)
distutils-r1_python_prepare_all