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
14 changes: 6 additions & 8 deletions crates/uv/src/commands/python/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,15 @@ pub(crate) async fn install(
.collect::<Result<Vec<_>>>()?
};

let Some(first_request) = requests.first() else {
if requests.is_empty() {
if upgrade {
writeln!(
printer.stderr(),
"There are no installed versions to upgrade"
)?;
}
return Ok(ExitStatus::Success);
};
}

let requested_minor_versions = requests
.iter()
Expand Down Expand Up @@ -500,7 +500,6 @@ pub(crate) async fn install(
upgradeable,
upgrade,
is_default_install,
first_request,
&existing_installations,
&installations,
&mut changelog,
Expand Down Expand Up @@ -764,7 +763,6 @@ fn create_bin_links(
upgradeable: bool,
upgrade: bool,
is_default_install: bool,
first_request: &InstallRequest,
existing_installations: &[ManagedPythonInstallation],
installations: &[&ManagedPythonInstallation],
changelog: &mut Changelog,
Expand All @@ -774,10 +772,10 @@ fn create_bin_links(
// TODO(zanieb): We want more feedback on the `is_default_install` behavior before stabilizing
// it. In particular, it may be confusing because it does not apply when versions are loaded
// from a `.python-version` file.
let targets = if (default
|| (is_default_install && preview.is_enabled(PreviewFeatures::PYTHON_INSTALL_DEFAULT)))
&& first_request.matches_installation(installation)
{
let should_create_default_links = default
|| (is_default_install && preview.is_enabled(PreviewFeatures::PYTHON_INSTALL_DEFAULT));

let targets = if should_create_default_links {
vec![
installation.key().executable_name_minor(),
installation.key().executable_name_major(),
Expand Down
39 changes: 39 additions & 0 deletions crates/uv/tests/it/python_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2255,6 +2255,45 @@ fn python_install_broken_link() {
});
}

/// Test that --default works with pre-release versions (e.g., 3.15.0a1).
/// This test verifies the fix for issue #16696 where --default didn't create
/// python.exe and python3.exe links for pre-release versions.
#[test]
fn python_install_default_prerelease() {
let context: TestContext = TestContext::new_with_versions(&[])
.with_filtered_python_keys()
.with_filtered_exe_suffix()
.with_managed_python_dirs()
.with_python_download_cache();

// Install Python 3.15, which currently only exists as a pre-release (3.15.0a1).
context
.python_install()
.arg("--default")
.arg("--preview-features")
.arg("python-install-default")
.arg("3.15")
.assert()
.success();

let bin_python_minor_15 = context
.bin_dir
.child(format!("python3.15{}", std::env::consts::EXE_SUFFIX));

let bin_python_major = context
.bin_dir
.child(format!("python3{}", std::env::consts::EXE_SUFFIX));

let bin_python_default = context
.bin_dir
.child(format!("python{}", std::env::consts::EXE_SUFFIX));

// Verify that all three executables are created when --default is used with a pre-release version
bin_python_minor_15.assert(predicate::path::exists());
bin_python_major.assert(predicate::path::exists());
bin_python_default.assert(predicate::path::exists());
}

#[test]
fn python_install_default_from_env() {
let context: TestContext = TestContext::new_with_versions(&[])
Expand Down
Loading