File tree Expand file tree Collapse file tree 5 files changed +17
-9
lines changed
src/pip/_internal/resolution/resolvelib Expand file tree Collapse file tree 5 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ pyproject-hooks==1.2.0 \
18
18
# via build
19
19
20
20
# 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
24
24
# via -r build-requirements.in
Original file line number Diff line number Diff line change
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.
Original file line number Diff line number Diff line change @@ -249,10 +249,12 @@ def _prepare(self) -> BaseDistribution:
249
249
return dist
250
250
251
251
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 )
252
255
requires = self .dist .iter_dependencies () if with_requires else ()
253
256
for r in requires :
254
257
yield from self ._factory .make_requirements_from_spec (str (r ), self ._ireq )
255
- yield self ._factory .make_requires_python_requirement (self .dist .requires_python )
256
258
257
259
def get_install_requirement (self ) -> Optional [InstallRequirement ]:
258
260
return self ._ireq
Original file line number Diff line number Diff line change @@ -250,6 +250,7 @@ def _eligible_for_upgrade(identifier: str) -> bool:
250
250
def is_satisfied_by (self , requirement : Requirement , candidate : Candidate ) -> bool :
251
251
return requirement .is_satisfied_by (candidate )
252
252
253
- def get_dependencies (self , candidate : Candidate ) -> Sequence [Requirement ]:
253
+ def get_dependencies (self , candidate : Candidate ) -> Iterable [Requirement ]:
254
254
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 )
Original file line number Diff line number Diff line change @@ -126,7 +126,9 @@ def test_new_resolver_checks_requires_python_before_dependencies(
126
126
expect_error = True ,
127
127
)
128
128
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.
131
131
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 )
You can’t perform that action at this time.
0 commit comments