Skip to content
Merged
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
13 changes: 8 additions & 5 deletions crates/uv/src/commands/python/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,17 @@ pub(crate) async fn install(
Vec::with_capacity(existing_installations.len() + requests.len());

for request in &requests {
if existing_installations.is_empty() {
let mut matching_installations = existing_installations
.iter()
.filter(|installation| request.matches_installation(installation))
.peekable();

if matching_installations.peek().is_none() {
debug!("No installation found for request `{}`", request.cyan());
unsatisfied.push(Cow::Borrowed(request));
}

for installation in existing_installations
.iter()
.filter(|installation| request.matches_installation(installation))
{
for installation in matching_installations {
changelog.existing.insert(installation.key().clone());
if matches!(&request.request, &PythonRequest::Any) {
// Construct a install request matching the existing installation
Expand Down Expand Up @@ -300,6 +302,7 @@ pub(crate) async fn install(
.build();
let reporter = PythonDownloadReporter::new(printer, downloads.len() as u64);
let mut tasks = FuturesUnordered::new();

for download in &downloads {
tasks.push(async {
(
Expand Down
31 changes: 21 additions & 10 deletions crates/uv/tests/it/python_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn python_reinstall() {
.with_managed_python_dirs();

// Install a couple versions
uv_snapshot!(context.filters(), context.python_install().arg("3.12").arg("3.13"), @r###"
uv_snapshot!(context.filters(), context.python_install().arg("3.12").arg("3.13"), @r"
success: true
exit_code: 0
----- stdout -----
Expand All @@ -108,21 +108,21 @@ fn python_reinstall() {
Installed 2 versions in [TIME]
+ cpython-3.12.9-[PLATFORM]
+ cpython-3.13.2-[PLATFORM]
"###);
");

// Reinstall a single version
uv_snapshot!(context.filters(), context.python_install().arg("3.13").arg("--reinstall"), @r###"
uv_snapshot!(context.filters(), context.python_install().arg("3.13").arg("--reinstall"), @r"
success: true
exit_code: 0
----- stdout -----

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

// Reinstall multiple versions
uv_snapshot!(context.filters(), context.python_install().arg("--reinstall"), @r###"
uv_snapshot!(context.filters(), context.python_install().arg("--reinstall"), @r"
success: true
exit_code: 0
----- stdout -----
Expand All @@ -131,7 +131,18 @@ fn python_reinstall() {
Installed 2 versions in [TIME]
~ cpython-3.12.9-[PLATFORM]
~ cpython-3.13.2-[PLATFORM]
"###);
");

// Reinstalling a version that is not installed should also work
uv_snapshot!(context.filters(), context.python_install().arg("3.11").arg("--reinstall"), @r"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Installed Python 3.11.11 in [TIME]
+ cpython-3.11.11-[PLATFORM]
");
}

#[test]
Expand All @@ -142,7 +153,7 @@ fn python_reinstall_patch() {
.with_managed_python_dirs();

// Install a couple patch versions
uv_snapshot!(context.filters(), context.python_install().arg("3.12.6").arg("3.12.7"), @r###"
uv_snapshot!(context.filters(), context.python_install().arg("3.12.6").arg("3.12.7"), @r"
success: true
exit_code: 0
----- stdout -----
Expand All @@ -151,20 +162,20 @@ fn python_reinstall_patch() {
Installed 2 versions in [TIME]
+ cpython-3.12.6-[PLATFORM]
+ cpython-3.12.7-[PLATFORM]
"###);
");

// Reinstall all "3.12" versions
// TODO(zanieb): This doesn't work today, because we need this to install the "latest" as there
// is no workflow for `--upgrade` yet
uv_snapshot!(context.filters(), context.python_install().arg("3.12").arg("--reinstall"), @r###"
uv_snapshot!(context.filters(), context.python_install().arg("3.12").arg("--reinstall"), @r"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Installed Python 3.12.9 in [TIME]
+ cpython-3.12.9-[PLATFORM]
"###);
");
}

#[test]
Expand Down
Loading