diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index 4d0b4d05f..1c116c600 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -1302,15 +1302,6 @@ impl ResolverState impl Iterator { self.overrides .apply(dependencies) - .flat_map(|requirement| { - iter::once(requirement).chain( - // If the requirement was constrained, add those constraints. - self.constraints - .get(&requirement.name) - .into_iter() - .flatten(), - ) - }) .filter(move |requirement| { // If the requirement would not be selected with any Python version // supported by the root, skip it. @@ -1353,8 +1344,50 @@ impl ResolverState { + if !constraint.evaluate_markers( + self.markers.as_ref(), + std::slice::from_ref(source_extra), + ) { + return false; + } + } + None => { + if !constraint.evaluate_markers(self.markers.as_ref(), &[]) { + return false; + } + } + } + + true + }), + ) + }) } /// Fetch the metadata for a stream of packages and versions. diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index 5daffafe4..af0ed8e93 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -9731,3 +9731,38 @@ fn no_binary_only_binary() -> Result<()> { Ok(()) } + +/// `gunicorn` only depends on `eventlet` via an extra, so the resolution should succeed despite +/// the nonsensical extra. +#[test] +fn ignore_invalid_constraint() -> Result<()> { + let context = TestContext::new("3.12"); + + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str("gunicorn>=20")?; + + let constraints_txt = context.temp_dir.child("constraints.txt"); + constraints_txt.write_str("eventlet==9999.0.1.2.3.4.5")?; + + uv_snapshot!(context + .pip_compile() + .arg("requirements.in") + .arg("-c") + .arg("constraints.txt"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv pip compile --cache-dir [CACHE_DIR] requirements.in -c constraints.txt + gunicorn==21.2.0 + # via -r requirements.in + packaging==24.0 + # via gunicorn + + ----- stderr ----- + Resolved 2 packages in [TIME] + "### + ); + + Ok(()) +} diff --git a/req.txt b/req.txt deleted file mode 100644 index c14e9aa79..000000000 --- a/req.txt +++ /dev/null @@ -1,3 +0,0 @@ ---index-url file:///Users/crmarsh/workspace/packse/index/simple-html/ - -example-a-961b4c22