Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/uv-python/src/downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,11 @@ impl PythonDownloadRequest {
self.implementation.as_ref()
}

/// Return the requested build, if any.
pub fn build(&self) -> Option<&str> {
self.build.as_deref()
}

pub(crate) fn version(&self) -> Option<&VersionRequest> {
self.version.as_ref()
}
Expand Down
19 changes: 16 additions & 3 deletions crates/uv/src/commands/python/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,19 @@ async fn perform_install(
}
} else if let Some(installation) = existing_installations
.iter()
.find(|inst| request.matches_installation(inst))
.find(|inst| request.download_request.satisfied_by_key(inst.key()))
{
debug!("Found `{}` for request `{}`", installation.key(), request);
satisfied.push(installation);
if matches_build(request.download_request.build(), installation.build()) {
debug!("Found `{}` for request `{}`", installation.key(), request);
satisfied.push(installation);
} else {
debug!(
"Build version mismatch for `{}`, will reinstall",
installation.key()
);
changelog.existing.insert(installation.key().clone());
unsatisfied.push(Cow::Borrowed(request));
}
} else {
debug!("No installation found for request `{}`", request);
unsatisfied.push(Cow::Borrowed(request));
Expand Down Expand Up @@ -609,6 +618,10 @@ async fn perform_install(

let mut tasks = futures::stream::iter(&downloads)
.map(async |download| {
let reinstall = reinstall
|| existing_installations
.iter()
.any(|installation| download.key() == installation.key());
(
*download,
download
Expand Down
23 changes: 23 additions & 0 deletions crates/uv/tests/python/python_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4110,6 +4110,29 @@ fn python_install_build_version() {
let build_content = fs_err::read_to_string(&build_file_path).unwrap();
assert_eq!(build_content, "20240814");

// A matching patch with an outdated build must be re-extracted for an explicit build pin.
let stale_file = cpython_dir.child("stale-file");
stale_file.touch().unwrap();
fs_err::write(&build_file_path, "19000101").unwrap();

uv_snapshot!(context.filters(), context.python_install()
.arg("3.12.5")
.env(EnvVars::UV_PYTHON_CPYTHON_BUILD, "20240814"), @"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Installed Python 3.12.5 in [TIME]
~ cpython-3.12.5-[PLATFORM]
");

assert!(!stale_file.exists());
assert_eq!(
fs_err::read_to_string(&build_file_path).unwrap(),
"20240814"
);

// We should find the build
uv_snapshot!(context.filters(), context.python_find()
.arg("3.12")
Expand Down
Loading