Add uv python install --default (#8650)

This pull request is best viewed with [whitespace
hidden](https://github.com/astral-sh/uv/pull/8650/files?diff=unified&w=1)

Adds a `--default` flag to `uv python install` in preview. This includes
a `python` and `python{major}` executable in addition to the
`python{major}.{minor}` executable. We will replace uv-managed
executables, but externally managed executables require the `--force`
flag to overwrite.

If you run `uv python install` (without arguments), we include the
`--default` flag implicitly to populate `python` and `python3` for the
"default" install version.

In the future, we should add a warning if the installed executable isn't
at the front of the PATH.
This commit is contained in:
Zanie Blue 2024-12-02 19:04:57 -06:00 committed by GitHub
parent 97114ebe4b
commit 63443f1984
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 500 additions and 125 deletions

View file

@ -4226,6 +4226,21 @@ pub struct PythonInstallArgs {
/// Implies `--reinstall`.
#[arg(long, short)]
pub force: bool,
/// Use as the default Python version.
///
/// By default, only a `python{major}.{minor}` executable is installed, e.g., `python3.10`. When
/// the `--default` flag is used, `python{major}`, e.g., `python3`, and `python` executables are
/// also installed.
///
/// Alternative Python variants will still include their tag. For example, installing
/// 3.13+freethreaded with `--default` will include in `python3t` and `pythont`, not `python3`
/// and `python`.
///
/// If multiple Python versions are requested during the installation, the first request will be
/// the default.
#[arg(long)]
pub default: bool,
}
#[derive(Args)]