mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-03 10:33:49 +00:00
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:
parent
a129cf7d7e
commit
4df0fe9a01
28 changed files with 266 additions and 488 deletions
|
@ -15,7 +15,7 @@ use uv_configuration::{
|
|||
ConfigSettingEntry, IndexStrategy, KeyringProviderType, PackageNameSpecifier, TargetTriple,
|
||||
};
|
||||
use uv_normalize::{ExtraName, PackageName};
|
||||
use uv_python::{PythonFetch, PythonPreference, PythonVersion};
|
||||
use uv_python::{PythonDownloads, PythonPreference, PythonVersion};
|
||||
use uv_resolver::{AnnotationStyle, ExcludeNewer, PrereleaseMode, ResolutionMode};
|
||||
|
||||
pub mod compat;
|
||||
|
@ -119,9 +119,17 @@ pub struct GlobalArgs {
|
|||
)]
|
||||
pub python_preference: Option<PythonPreference>,
|
||||
|
||||
/// Whether to automatically download Python when required.
|
||||
/// Allow automatically downloading Python when required.
|
||||
#[arg(global = true, long, help_heading = "Python options", hide = true)]
|
||||
pub allow_python_downloads: bool,
|
||||
|
||||
/// Disable automatic downloads of Python.
|
||||
#[arg(global = true, long, help_heading = "Python options")]
|
||||
pub python_fetch: Option<PythonFetch>,
|
||||
pub no_python_downloads: bool,
|
||||
|
||||
/// Deprecated version of [`Self::python_downloads`].
|
||||
#[arg(global = true, long, hide = true)]
|
||||
pub python_fetch: Option<PythonDownloads>,
|
||||
|
||||
/// Do not print any output.
|
||||
#[arg(global = true, long, short, conflicts_with = "verbose")]
|
||||
|
@ -258,7 +266,7 @@ pub enum Commands {
|
|||
///
|
||||
/// When preview is enabled, i.e., via `--preview` or by using a preview
|
||||
/// command, uv will download Python if a version cannot be found. This
|
||||
/// behavior can be disabled with the `--python-fetch` option.
|
||||
/// behavior can be disabled with the `--python-downloads` option.
|
||||
///
|
||||
/// The `--python` option allows requesting a different interpreter.
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue