Update the interface for declaring Python download preferences (#5936)
The loose consensus is that "fetch" doesn't have much meaning and that a boolean flag makes more sense from the command line. 1. Adds `--allow-python-downloads` (hidden, default) and `--no-python-downloads` to the CLI to quickly enable or disable downloads 2. Deprecates `--python-fetch` in favor of the options from (1) 3. Removes `python-fetch` in favor of a `python-downloads` setting 5. Adds a `never` variant to the enum, allowing even explicit installs to be disabled via the configuration file ## Test plan I tested this with various `pyproject.toml`-level settings and `uv venv --preview --python 3.12.2` and `uv python install 3.12.2` with and without the new CLI flags.
This commit is contained in:
@@ -79,12 +79,25 @@ pub enum PythonPreference {
|
||||
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub enum PythonFetch {
|
||||
/// Automatically fetch managed Python installations when needed.
|
||||
pub enum PythonDownloads {
|
||||
/// Automatically download managed Python installations when needed.
|
||||
#[default]
|
||||
#[serde(alias = "auto")]
|
||||
Automatic,
|
||||
/// Do not automatically fetch managed Python installations; require explicit installation.
|
||||
/// Do not automatically download managed Python installations; require explicit installation.
|
||||
Manual,
|
||||
/// Do not ever allow Python downloads.
|
||||
Never,
|
||||
}
|
||||
|
||||
impl From<bool> for PythonDownloads {
|
||||
fn from(value: bool) -> Self {
|
||||
if value {
|
||||
PythonDownloads::Automatic
|
||||
} else {
|
||||
PythonDownloads::Never
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
@@ -1298,7 +1311,7 @@ impl PythonPreference {
|
||||
}
|
||||
}
|
||||
|
||||
impl PythonFetch {
|
||||
impl PythonDownloads {
|
||||
pub fn is_automatic(self) -> bool {
|
||||
matches!(self, Self::Automatic)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user