Env variables for python downloads (#6416)

## Summary

Resolves #6406

## Test Plan

```
❯ UV_PYTHON_PREFERENCE=only-managed cargo run -q -- sync --show-settings | rg python_preference
    python_preference: OnlyManaged,
❯ UV_PYTHON_PREFERENCE=system cargo run -q -- sync --show-settings | rg python_preference
    python_preference: System,
❯ UV_NO_PYTHON_DOWNLOADS=1 cargo run -q -- sync --show-settings | rg python_downloads
    python_downloads: Never,
❯ UV_ALLOW_PYTHON_DOWNLOADS=1 cargo run -q -- sync --show-settings | rg python_downloads
    python_downloads: Automatic,
```
This commit is contained in:
Ahmed Ilyas 2024-08-22 14:52:52 +02:00 committed by GitHub
parent a3a5b82a17
commit bbd9adaa40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 50 additions and 24 deletions

View file

@ -115,16 +115,30 @@ pub struct GlobalArgs {
global = true,
long,
help_heading = "Python options",
display_order = 700
display_order = 700,
env = "UV_PYTHON_PREFERENCE"
)]
pub python_preference: Option<PythonPreference>,
/// Allow automatically downloading Python when required.
#[arg(global = true, long, help_heading = "Python options", hide = true)]
#[arg(
global = true,
long,
help_heading = "Python options",
hide = true,
value_parser = clap::builder::BoolishValueParser::new(),
env = "UV_ALLOW_PYTHON_DOWNLOADS"
)]
pub allow_python_downloads: bool,
/// Disable automatic downloads of Python.
#[arg(global = true, long, help_heading = "Python options")]
#[arg(
global = true,
long,
help_heading = "Python options",
value_parser = clap::builder::BoolishValueParser::new(),
env = "UV_NO_PYTHON_DOWNLOADS"
)]
pub no_python_downloads: bool,
/// Deprecated version of [`Self::python_downloads`].