Skip to content

Commit d95fe76

Browse files
committed
Review feedback
1 parent c2b582a commit d95fe76

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

crates/uv/src/commands/python/install.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,14 @@ pub(crate) async fn install(
138138
let start = std::time::Instant::now();
139139

140140
if default && !preview.is_enabled() {
141-
writeln!(printer.stderr(), "The `--default` flag is only available in preview mode; add the `--preview` flag to use `--default.")?;
141+
writeln!(printer.stderr(), "The `--default` flag is only available in preview mode; add the `--preview` flag to use `--default")?;
142142
return Ok(ExitStatus::Failure);
143143
}
144144

145+
if default && targets.len() > 1 {
146+
anyhow::bail!("The `--default` flag cannot be used with multiple targets");
147+
}
148+
145149
// Resolve the requests
146150
let mut is_default_install = false;
147151
let requests: Vec<_> = if targets.is_empty() {

crates/uv/tests/it/python_install.rs

+13-21
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ fn python_install_default() {
507507
----- stdout -----
508508
509509
----- stderr -----
510-
The `--default` flag is only available in preview mode; add the `--preview` flag to use `--default.
510+
The `--default` flag is only available in preview mode; add the `--preview` flag to use `--default
511511
"###);
512512

513513
// Install a specific version
@@ -594,14 +594,23 @@ fn python_install_default() {
594594

595595
// Install multiple versions, with the `--default` flag
596596
uv_snapshot!(context.filters(), context.python_install().arg("--preview").arg("3.12").arg("3.13").arg("--default"), @r###"
597+
success: false
598+
exit_code: 2
599+
----- stdout -----
600+
601+
----- stderr -----
602+
error: The `--default` flag cannot be used with multiple targets
603+
"###);
604+
605+
// Install 3.12 as a new default
606+
uv_snapshot!(context.filters(), context.python_install().arg("--preview").arg("3.12").arg("--default"), @r###"
597607
success: true
598608
exit_code: 0
599609
----- stdout -----
600610
601611
----- stderr -----
602-
Installed 2 versions in [TIME]
612+
Installed Python 3.12.7 in [TIME]
603613
+ cpython-3.12.7-[PLATFORM] (python, python3, python3.12)
604-
+ cpython-3.13.0-[PLATFORM] (python3.13)
605614
"###);
606615

607616
let bin_python_minor_12 = context
@@ -610,7 +619,6 @@ fn python_install_default() {
610619
.child(format!("python3.12{}", std::env::consts::EXE_SUFFIX));
611620

612621
// All the executables should exist
613-
bin_python_minor_13.assert(predicate::path::exists());
614622
bin_python_minor_12.assert(predicate::path::exists());
615623
bin_python_major.assert(predicate::path::exists());
616624
bin_python_default.assert(predicate::path::exists());
@@ -625,14 +633,6 @@ fn python_install_default() {
625633
);
626634
});
627635

628-
insta::with_settings!({
629-
filters => context.filters(),
630-
}, {
631-
insta::assert_snapshot!(
632-
read_link_path(&bin_python_minor_13), @"[TEMP_DIR]/managed/cpython-3.13.0-[PLATFORM]/bin/python3.13"
633-
);
634-
});
635-
636636
insta::with_settings!({
637637
filters => context.filters(),
638638
}, {
@@ -657,14 +657,6 @@ fn python_install_default() {
657657
);
658658
});
659659

660-
insta::with_settings!({
661-
filters => context.filters(),
662-
}, {
663-
insta::assert_snapshot!(
664-
read_link_path(&bin_python_minor_13), @"[TEMP_DIR]/managed/cpython-3.13.0-[PLATFORM]/python"
665-
);
666-
});
667-
668660
insta::with_settings!({
669661
filters => context.filters(),
670662
}, {
@@ -690,7 +682,7 @@ fn python_install_default() {
690682
691683
----- stderr -----
692684
Installed Python 3.13.0 in [TIME]
693-
+ cpython-3.13.0-[PLATFORM] (python, python3)
685+
+ cpython-3.13.0-[PLATFORM] (python, python3, python3.13)
694686
"###);
695687

696688
// All the executables should exist

0 commit comments

Comments
 (0)