Skip to content

Commit e40c551

Browse files
Use resolver-returned wheel over alternate cached wheel (#12301)
## Summary I think this is reasonable to change. Right now, if you're on Python 3.11, the resolver returns `multiprocess-0.70.17-py311-none-any.whl`, but `multiprocess-0.70.17-py310-none-any.whl` is in the cache, we'll reuse `multiprocess-0.70.17-py310-none-any.whl` (since it _is_ compatible with Python 3.11). Instead, we now _require_ the cached wheel to match the wheel returned by the resolver. Closes #12273.
1 parent a95f4cf commit e40c551

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

crates/uv-installer/src/plan.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ impl<'a> Planner<'a> {
142142
if *entry.index.url() != wheel.best_wheel().index {
143143
return None;
144144
}
145-
if entry.dist.filename.version != wheel.best_wheel().filename.version {
145+
if entry.dist.filename != wheel.best_wheel().filename {
146146
return None;
147-
};
147+
}
148148
if entry.built && no_build {
149149
return None;
150150
}

crates/uv/tests/it/pip_install.rs

+58
Original file line numberDiff line numberDiff line change
@@ -8493,6 +8493,64 @@ fn stale_egg_info() -> Result<()> {
84938493
Ok(())
84948494
}
84958495

8496+
/// Avoid using a compatible, cached wheel if there's another, more compatible wheel returned by
8497+
/// the resolver.
8498+
///
8499+
/// See: <https://github.com/astral-sh/uv/issues/12273>
8500+
#[test]
8501+
fn avoid_cached_wheel() {
8502+
let context = TestContext::new_with_versions(&["3.10", "3.11"]);
8503+
8504+
// Create a Python 3.10 environment.
8505+
context
8506+
.venv()
8507+
.arg("--python")
8508+
.arg("3.10")
8509+
.assert()
8510+
.success();
8511+
8512+
uv_snapshot!(context.filters(), context.pip_install()
8513+
.arg("multiprocess"), @r"
8514+
success: true
8515+
exit_code: 0
8516+
----- stdout -----
8517+
8518+
----- stderr -----
8519+
Resolved 2 packages in [TIME]
8520+
Prepared 2 packages in [TIME]
8521+
Installed 2 packages in [TIME]
8522+
+ dill==0.3.8
8523+
+ multiprocess==0.70.16
8524+
"
8525+
);
8526+
8527+
// Create a Python 3.11 environment.
8528+
context
8529+
.venv()
8530+
.arg("--python")
8531+
.arg("3.11")
8532+
.assert()
8533+
.success();
8534+
8535+
// `multiprocessing` should be re-downloaded (i.e., we should have a `Prepare` step here).
8536+
uv_snapshot!(context.filters(), context.pip_install()
8537+
.arg("--python")
8538+
.arg("3.11")
8539+
.arg("multiprocess"), @r"
8540+
success: true
8541+
exit_code: 0
8542+
----- stdout -----
8543+
8544+
----- stderr -----
8545+
Resolved 2 packages in [TIME]
8546+
Prepared 1 package in [TIME]
8547+
Installed 2 packages in [TIME]
8548+
+ dill==0.3.8
8549+
+ multiprocess==0.70.16
8550+
"
8551+
);
8552+
}
8553+
84968554
/// `suds-community` has an incorrect layout whereby the wheel includes `suds_community.egg-info` at
84978555
/// the top-level. We're then under the impression that `suds` is installed twice, but when we go to
84988556
/// uninstall the second "version", we can't find the `egg-info` directory.

0 commit comments

Comments
 (0)