diff --git a/crates/uv-installer/src/plan.rs b/crates/uv-installer/src/plan.rs index 26bcf933c..67ac5c26e 100644 --- a/crates/uv-installer/src/plan.rs +++ b/crates/uv-installer/src/plan.rs @@ -142,9 +142,9 @@ impl<'a> Planner<'a> { if *entry.index.url() != wheel.best_wheel().index { return None; } - if entry.dist.filename.version != wheel.best_wheel().filename.version { + if entry.dist.filename != wheel.best_wheel().filename { return None; - }; + } if entry.built && no_build { return None; } diff --git a/crates/uv/tests/it/pip_install.rs b/crates/uv/tests/it/pip_install.rs index b49951232..cf25c1af7 100644 --- a/crates/uv/tests/it/pip_install.rs +++ b/crates/uv/tests/it/pip_install.rs @@ -8493,6 +8493,64 @@ fn stale_egg_info() -> Result<()> { Ok(()) } +/// Avoid using a compatible, cached wheel if there's another, more compatible wheel returned by +/// the resolver. +/// +/// See: +#[test] +fn avoid_cached_wheel() { + let context = TestContext::new_with_versions(&["3.10", "3.11"]); + + // Create a Python 3.10 environment. + context + .venv() + .arg("--python") + .arg("3.10") + .assert() + .success(); + + uv_snapshot!(context.filters(), context.pip_install() + .arg("multiprocess"), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 2 packages in [TIME] + Prepared 2 packages in [TIME] + Installed 2 packages in [TIME] + + dill==0.3.8 + + multiprocess==0.70.16 + " + ); + + // Create a Python 3.11 environment. + context + .venv() + .arg("--python") + .arg("3.11") + .assert() + .success(); + + // `multiprocessing` should be re-downloaded (i.e., we should have a `Prepare` step here). + uv_snapshot!(context.filters(), context.pip_install() + .arg("--python") + .arg("3.11") + .arg("multiprocess"), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 2 packages in [TIME] + Prepared 1 package in [TIME] + Installed 2 packages in [TIME] + + dill==0.3.8 + + multiprocess==0.70.16 + " + ); +} + /// `suds-community` has an incorrect layout whereby the wheel includes `suds_community.egg-info` at /// the top-level. We're then under the impression that `suds` is installed twice, but when we go to /// uninstall the second "version", we can't find the `egg-info` directory.