diff --git a/crates/uv/src/commands/python/install.rs b/crates/uv/src/commands/python/install.rs index 2626f950a6d63..37d6a67776d50 100644 --- a/crates/uv/src/commands/python/install.rs +++ b/crates/uv/src/commands/python/install.rs @@ -166,6 +166,16 @@ pub(crate) async fn install( ) -> Result { let start = std::time::Instant::now(); + // TODO(zanieb): We should consider marking the Python installation as the default when + // `--default` is used. It's not clear how this overlaps with a global Python pin, but I'd be + // surprised if `uv python find` returned the "newest" Python version rather than the one I just + // installed with the `--default` flag. + if default && !preview.is_enabled() { + warn_user!( + "The `--default` option is experimental and may change without warning. Pass `--preview` to disable this warning" + ); + } + if upgrade && preview.is_disabled() { warn_user!( "`uv python upgrade` is experimental and may change without warning. Pass `--preview` to disable this warning" @@ -214,6 +224,8 @@ pub(crate) async fn install( .map(PythonVersionFile::into_versions) .unwrap_or_else(|| { // If no version file is found and no requests were made + // TODO(zanieb): We should consider differentiating between a global Python version + // file here, allowing a request from there to enable `is_default_install`. is_default_install = true; vec![if reinstall { // On bare `--reinstall`, reinstall all Python versions @@ -443,10 +455,10 @@ pub(crate) async fn install( } } - let bin_dir = if !matches!(bin, Some(false)) { - Some(python_executable_dir()?) - } else { + let bin_dir = if matches!(bin, Some(false)) { None + } else { + Some(python_executable_dir()?) }; let installations: Vec<_> = downloaded.iter().chain(satisfied.iter().copied()).collect(); @@ -727,7 +739,10 @@ fn create_bin_links( errors: &mut Vec<(InstallErrorKind, PythonInstallationKey, Error)>, preview: PreviewMode, ) { - let targets = if (default || (is_default_install && !reinstall)) + // 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())) && first_request.matches_installation(installation) { vec![ diff --git a/crates/uv/tests/it/python_install.rs b/crates/uv/tests/it/python_install.rs index 1712478643002..f194208b43f4e 100644 --- a/crates/uv/tests/it/python_install.rs +++ b/crates/uv/tests/it/python_install.rs @@ -30,7 +30,7 @@ fn python_install() { ----- stderr ----- Installed Python 3.13.5 in [TIME] - + cpython-3.13.5-[PLATFORM] (python, python3, python3.13) + + cpython-3.13.5-[PLATFORM] (python3.13) "); let bin_python = context @@ -130,7 +130,7 @@ fn python_install() { ----- stderr ----- Searching for Python versions matching: Python 3.13 Uninstalled Python 3.13.5 in [TIME] - - cpython-3.13.5-[PLATFORM] (python, python3, python3.13) + - cpython-3.13.5-[PLATFORM] (python3.13) "); // The executable should be removed @@ -383,7 +383,7 @@ fn python_install_force() { ----- stderr ----- Installed Python 3.13.5 in [TIME] - + cpython-3.13.5-[PLATFORM] (python, python3, python3.13) + + cpython-3.13.5-[PLATFORM] (python3.13) "); let bin_python = context @@ -398,7 +398,7 @@ fn python_install_force() { ----- stderr ----- Installed Python 3.13.5 in [TIME] - + cpython-3.13.5-[PLATFORM] (python, python3, python3.13) + + cpython-3.13.5-[PLATFORM] (python3.13) "); // The executable should still be present in the bin directory @@ -647,7 +647,7 @@ fn python_install_preview() { ----- stderr ----- Installed Python 3.13.5 in [TIME] - ~ cpython-3.13.5-[PLATFORM] (python3.13) + ~ cpython-3.13.5-[PLATFORM] (python, python3, python3.13) "); // The executable should still be present in the bin directory @@ -1185,6 +1185,7 @@ fn python_install_default() { ----- stdout ----- ----- stderr ----- + warning: The `--default` option is experimental and may change without warning. Pass `--preview` to disable this warning Installed Python 3.13.5 in [TIME] + cpython-3.13.5-[PLATFORM] (python, python3) "); @@ -1218,6 +1219,7 @@ fn python_install_default() { ----- stdout ----- ----- stderr ----- + warning: The `--default` option is experimental and may change without warning. Pass `--preview` to disable this warning Installed Python 3.13.5 in [TIME] + cpython-3.13.5-[PLATFORM] (python, python3, python3.13) "); @@ -1296,14 +1298,15 @@ fn python_install_default() { bin_python_default.assert(predicate::path::missing()); // Install multiple versions, with the `--default` flag - uv_snapshot!(context.filters(), context.python_install().arg("3.12").arg("3.13").arg("--default"), @r###" + uv_snapshot!(context.filters(), context.python_install().arg("3.12").arg("3.13").arg("--default"), @r" success: false exit_code: 2 ----- stdout ----- ----- stderr ----- + warning: The `--default` option is experimental and may change without warning. Pass `--preview` to disable this warning error: The `--default` flag cannot be used with multiple targets - "###); + "); // Install 3.12 as a new default uv_snapshot!(context.filters(), context.python_install().arg("3.12").arg("--default"), @r" @@ -1312,6 +1315,7 @@ fn python_install_default() { ----- stdout ----- ----- stderr ----- + warning: The `--default` option is experimental and may change without warning. Pass `--preview` to disable this warning Installed Python 3.12.11 in [TIME] + cpython-3.12.11-[PLATFORM] (python, python3, python3.12) "); @@ -2075,7 +2079,7 @@ fn python_install_cached() { ----- stderr ----- Installed Python 3.13.5 in [TIME] - + cpython-3.13.5-[PLATFORM] (python, python3, python3.13) + + cpython-3.13.5-[PLATFORM] (python3.13) "); let bin_python = context @@ -2105,7 +2109,7 @@ fn python_install_cached() { ----- stderr ----- Searching for Python versions matching: Python 3.13 Uninstalled Python 3.13.5 in [TIME] - - cpython-3.13.5-[PLATFORM] (python, python3, python3.13) + - cpython-3.13.5-[PLATFORM] (python3.13) "); // The cached archive can be installed offline @@ -2119,7 +2123,7 @@ fn python_install_cached() { ----- stderr ----- Installed Python 3.13.5 in [TIME] - + cpython-3.13.5-[PLATFORM] (python, python3, python3.13) + + cpython-3.13.5-[PLATFORM] (python3.13) "); // 3.12 isn't cached, so it can't be installed