mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-22 00:02:32 +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 crate::implementation::LenientImplementationName;
|
|||
use crate::managed::{ManagedPythonInstallation, ManagedPythonInstallations};
|
||||
use crate::platform::{Arch, Libc, Os};
|
||||
use crate::{
|
||||
downloads, Error, Interpreter, PythonFetch, PythonPreference, PythonSource, PythonVersion,
|
||||
downloads, Error, Interpreter, PythonDownloads, PythonPreference, PythonSource, PythonVersion,
|
||||
};
|
||||
|
||||
/// A Python interpreter and accompanying tools.
|
||||
|
@ -77,11 +77,11 @@ impl PythonInstallation {
|
|||
/// Find or fetch a [`PythonInstallation`].
|
||||
///
|
||||
/// Unlike [`PythonInstallation::find`], if the required Python is not installed it will be installed automatically.
|
||||
pub async fn find_or_fetch<'a>(
|
||||
pub async fn find_or_download<'a>(
|
||||
request: Option<PythonRequest>,
|
||||
environments: EnvironmentPreference,
|
||||
preference: PythonPreference,
|
||||
python_fetch: PythonFetch,
|
||||
python_downloads: PythonDownloads,
|
||||
client_builder: &BaseClientBuilder<'a>,
|
||||
cache: &Cache,
|
||||
reporter: Option<&dyn Reporter>,
|
||||
|
@ -94,7 +94,7 @@ impl PythonInstallation {
|
|||
// If missing and allowed, perform a fetch
|
||||
Err(Error::MissingPython(err))
|
||||
if preference.allows_managed()
|
||||
&& python_fetch.is_automatic()
|
||||
&& python_downloads.is_automatic()
|
||||
&& client_builder.connectivity.is_online() =>
|
||||
{
|
||||
if let Some(request) = PythonDownloadRequest::from_request(&request) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue