mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-14 20:39:37 +00:00
Fix uv python install --reinstall
when the version is not yet installed (#12124)
I noticed this was failing to perform the install
This commit is contained in:
parent
553bcccb6a
commit
b7167dc4d8
2 changed files with 29 additions and 15 deletions
|
@ -205,15 +205,17 @@ pub(crate) async fn install(
|
||||||
Vec::with_capacity(existing_installations.len() + requests.len());
|
Vec::with_capacity(existing_installations.len() + requests.len());
|
||||||
|
|
||||||
for request in &requests {
|
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());
|
debug!("No installation found for request `{}`", request.cyan());
|
||||||
unsatisfied.push(Cow::Borrowed(request));
|
unsatisfied.push(Cow::Borrowed(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
for installation in existing_installations
|
for installation in matching_installations {
|
||||||
.iter()
|
|
||||||
.filter(|installation| request.matches_installation(installation))
|
|
||||||
{
|
|
||||||
changelog.existing.insert(installation.key().clone());
|
changelog.existing.insert(installation.key().clone());
|
||||||
if matches!(&request.request, &PythonRequest::Any) {
|
if matches!(&request.request, &PythonRequest::Any) {
|
||||||
// Construct a install request matching the existing installation
|
// Construct a install request matching the existing installation
|
||||||
|
@ -300,6 +302,7 @@ pub(crate) async fn install(
|
||||||
.build();
|
.build();
|
||||||
let reporter = PythonDownloadReporter::new(printer, downloads.len() as u64);
|
let reporter = PythonDownloadReporter::new(printer, downloads.len() as u64);
|
||||||
let mut tasks = FuturesUnordered::new();
|
let mut tasks = FuturesUnordered::new();
|
||||||
|
|
||||||
for download in &downloads {
|
for download in &downloads {
|
||||||
tasks.push(async {
|
tasks.push(async {
|
||||||
(
|
(
|
||||||
|
|
|
@ -99,7 +99,7 @@ fn python_reinstall() {
|
||||||
.with_managed_python_dirs();
|
.with_managed_python_dirs();
|
||||||
|
|
||||||
// Install a couple versions
|
// 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
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
@ -108,10 +108,10 @@ fn python_reinstall() {
|
||||||
Installed 2 versions in [TIME]
|
Installed 2 versions in [TIME]
|
||||||
+ cpython-3.12.9-[PLATFORM]
|
+ cpython-3.12.9-[PLATFORM]
|
||||||
+ cpython-3.13.2-[PLATFORM]
|
+ cpython-3.13.2-[PLATFORM]
|
||||||
"###);
|
");
|
||||||
|
|
||||||
// Reinstall a single version
|
// 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
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
@ -119,10 +119,10 @@ fn python_reinstall() {
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
Installed Python 3.13.2 in [TIME]
|
Installed Python 3.13.2 in [TIME]
|
||||||
~ cpython-3.13.2-[PLATFORM]
|
~ cpython-3.13.2-[PLATFORM]
|
||||||
"###);
|
");
|
||||||
|
|
||||||
// Reinstall multiple versions
|
// 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
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
@ -131,7 +131,18 @@ fn python_reinstall() {
|
||||||
Installed 2 versions in [TIME]
|
Installed 2 versions in [TIME]
|
||||||
~ cpython-3.12.9-[PLATFORM]
|
~ cpython-3.12.9-[PLATFORM]
|
||||||
~ cpython-3.13.2-[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]
|
#[test]
|
||||||
|
@ -142,7 +153,7 @@ fn python_reinstall_patch() {
|
||||||
.with_managed_python_dirs();
|
.with_managed_python_dirs();
|
||||||
|
|
||||||
// Install a couple patch versions
|
// 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
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
@ -151,12 +162,12 @@ fn python_reinstall_patch() {
|
||||||
Installed 2 versions in [TIME]
|
Installed 2 versions in [TIME]
|
||||||
+ cpython-3.12.6-[PLATFORM]
|
+ cpython-3.12.6-[PLATFORM]
|
||||||
+ cpython-3.12.7-[PLATFORM]
|
+ cpython-3.12.7-[PLATFORM]
|
||||||
"###);
|
");
|
||||||
|
|
||||||
// Reinstall all "3.12" versions
|
// Reinstall all "3.12" versions
|
||||||
// TODO(zanieb): This doesn't work today, because we need this to install the "latest" as there
|
// TODO(zanieb): This doesn't work today, because we need this to install the "latest" as there
|
||||||
// is no workflow for `--upgrade` yet
|
// 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
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
@ -164,7 +175,7 @@ fn python_reinstall_patch() {
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
Installed Python 3.12.9 in [TIME]
|
Installed Python 3.12.9 in [TIME]
|
||||||
+ cpython-3.12.9-[PLATFORM]
|
+ cpython-3.12.9-[PLATFORM]
|
||||||
"###);
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue