mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-07-30 22:48:07 -07:00
60 lines
2.3 KiB
Diff
60 lines
2.3 KiB
Diff
https://github.com/sarugaku/resolvelib/commit/017d3a7a9ecdd01f5349d263e31d196f4f27e483
|
|
|
|
From 017d3a7a9ecdd01f5349d263e31d196f4f27e483 Mon Sep 17 00:00:00 2001
|
|
From: Damian Shaw <damian.peter.shaw@gmail.com>
|
|
Date: Thu, 12 Feb 2026 20:48:03 -0500
|
|
Subject: [PATCH] Correct `PythonInputProvider._iter_matches` to fix tests with
|
|
packaging 26.0 (#201)
|
|
|
|
---
|
|
.../python/test_resolvers_python.py | 25 ++++++++++++++-----
|
|
1 file changed, 19 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/tests/functional/python/test_resolvers_python.py b/tests/functional/python/test_resolvers_python.py
|
|
index eafb1cb..c44b777 100644
|
|
--- a/tests/functional/python/test_resolvers_python.py
|
|
+++ b/tests/functional/python/test_resolvers_python.py
|
|
@@ -3,9 +3,11 @@
|
|
import operator
|
|
import os
|
|
from collections import defaultdict
|
|
+from functools import reduce
|
|
|
|
import packaging.markers
|
|
import packaging.requirements
|
|
+import packaging.specifiers
|
|
import packaging.utils
|
|
import packaging.version
|
|
import pytest
|
|
@@ -92,12 +94,23 @@ def _iter_matches(self, identifier, requirements, incompatibilities):
|
|
name, _, _ = identifier.partition("[")
|
|
bad_versions = {c.version for c in incompatibilities[identifier]}
|
|
extras = {e for r in requirements[identifier] for e in r.extras}
|
|
- for key in self.index[name]:
|
|
- v = packaging.version.parse(key)
|
|
- if any(v not in r.specifier for r in requirements[identifier]):
|
|
- continue
|
|
- if v in bad_versions:
|
|
- continue
|
|
+
|
|
+ # Get all versions from the index, excluding bad versions
|
|
+ available_versions = (
|
|
+ v
|
|
+ for key in self.index[name]
|
|
+ if (v := packaging.version.parse(key)) not in bad_versions
|
|
+ )
|
|
+
|
|
+ # Combine all requirement specifiers using & operator
|
|
+ combined_specifier = reduce(
|
|
+ operator.and_,
|
|
+ map(operator.attrgetter("specifier"), requirements[identifier]),
|
|
+ packaging.specifiers.SpecifierSet(),
|
|
+ )
|
|
+
|
|
+ # Filter versions using the combined specifier
|
|
+ for v in combined_specifier.filter(available_versions):
|
|
yield Candidate(name=name, version=v, extras=extras)
|
|
|
|
def find_matches(self, identifier, requirements, incompatibilities):
|
|
|