Skip to content

Add uv python install --default #8650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4214,6 +4214,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)]
Expand Down
23 changes: 21 additions & 2 deletions crates/uv-python/src/installation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ impl PythonInstallationKey {
&self.libc
}

/// Return a canonical name for a versioned executable.
pub fn versioned_executable_name(&self) -> String {
/// Return a canonical name for a minor versioned executable.
pub fn executable_name_minor(&self) -> String {
format!(
"python{maj}.{min}{var}{exe}",
maj = self.major,
Expand All @@ -337,6 +337,25 @@ impl PythonInstallationKey {
exe = std::env::consts::EXE_SUFFIX
)
}

/// Return a canonical name for a major versioned executable.
pub fn executable_name_major(&self) -> String {
format!(
"python{maj}{var}{exe}",
maj = self.major,
var = self.variant.suffix(),
exe = std::env::consts::EXE_SUFFIX
)
}

/// Return a canonical name for an un-versioned executable.
pub fn executable_name(&self) -> String {
format!(
"python{var}{exe}",
var = self.variant.suffix(),
exe = std::env::consts::EXE_SUFFIX
)
}
}

impl fmt::Display for PythonInstallationKey {
Expand Down
Loading
Loading