Skip to content

Commit 38a9bef

Browse files
authored
Merge branch 'main' into add-docs-for-platform-and-python-version
2 parents d60abab + 2d77214 commit 38a9bef

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

build-requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pyproject-hooks==1.2.0 \
1818
# via build
1919

2020
# The following packages are considered to be unsafe in a requirements file:
21-
setuptools==75.8.0 \
22-
--hash=sha256:c5afc8f407c626b8313a86e10311dd3f661c6cd9c09d4bf8c15c0e11f9f2b0e6 \
23-
--hash=sha256:e3982f444617239225d675215d51f6ba05f845d4eec313da4418fdbb56fb27e3
21+
setuptools==75.8.2 \
22+
--hash=sha256:4880473a969e5f23f2a2be3646b2dfd84af9028716d398e46192f84bc36900d2 \
23+
--hash=sha256:558e47c15f1811c1fa7adbd0096669bf76c1d3f433f58324df69f3f5ecac4e8f
2424
# via -r build-requirements.in

news/13270.bugfix.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a regression that causes dependencies to be checked *before* ``Requires-Python``
2+
project metadata is checked, leading to wasted cycles when the Python version is
3+
unsupported.

src/pip/_internal/resolution/resolvelib/candidates.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,12 @@ def _prepare(self) -> BaseDistribution:
249249
return dist
250250

251251
def iter_dependencies(self, with_requires: bool) -> Iterable[Optional[Requirement]]:
252+
# Emit the Requires-Python requirement first to fail fast on
253+
# unsupported candidates and avoid pointless downloads/preparation.
254+
yield self._factory.make_requires_python_requirement(self.dist.requires_python)
252255
requires = self.dist.iter_dependencies() if with_requires else ()
253256
for r in requires:
254257
yield from self._factory.make_requirements_from_spec(str(r), self._ireq)
255-
yield self._factory.make_requires_python_requirement(self.dist.requires_python)
256258

257259
def get_install_requirement(self) -> Optional[InstallRequirement]:
258260
return self._ireq

src/pip/_internal/resolution/resolvelib/provider.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ def _eligible_for_upgrade(identifier: str) -> bool:
250250
def is_satisfied_by(self, requirement: Requirement, candidate: Candidate) -> bool:
251251
return requirement.is_satisfied_by(candidate)
252252

253-
def get_dependencies(self, candidate: Candidate) -> Sequence[Requirement]:
253+
def get_dependencies(self, candidate: Candidate) -> Iterable[Requirement]:
254254
with_requires = not self._ignore_dependencies
255-
return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
255+
# iter_dependencies() can perform nontrivial work so delay until needed.
256+
return (r for r in candidate.iter_dependencies(with_requires) if r is not None)

tests/functional/test_new_resolver_errors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ def test_new_resolver_checks_requires_python_before_dependencies(
126126
expect_error=True,
127127
)
128128

129-
# Resolution should fail because of pkg-a's Requires-Python.
130-
# This check should be done before pkg-b, so pkg-b should never be pulled.
129+
# Resolution should fail because of pkg-root's Requires-Python.
130+
# This is done before dependencies so pkg-dep should never be pulled.
131131
assert incompatible_python in result.stderr, str(result)
132-
assert "pkg-b" not in result.stderr, str(result)
132+
# Setuptools produces wheels with normalized names.
133+
assert "pkg_dep" not in result.stderr, str(result)
134+
assert "pkg_dep" not in result.stdout, str(result)

0 commit comments

Comments
 (0)