Split preview mode into separate feature flags (#14823)
I think this would give us better hygiene than a global flag. It makes it easier for users to opt-in to overlapping features, such as Python upgrades and Python bin installations and to disable warnings for preview mode without opting in to a bunch of other features. In general, I want to reduce the burden for putting something under preview. The `--preview` and `--no-preview` flags are retained as global overrides. A new `--preview-features` option is added which accepts comma separated features or can be passed multiple times, e.g., `--preview-features add-bounds,pylock`. There's a `UV_PREVIEW_FEATURES` environment variable for that option (I'm not sure if we should overload `UV_PREVIEW`, but could be convinced).
This commit is contained in:
@@ -8,7 +8,7 @@ use std::{env, io, iter};
|
||||
use std::{path::Path, path::PathBuf, str::FromStr};
|
||||
use thiserror::Error;
|
||||
use tracing::{debug, instrument, trace};
|
||||
use uv_configuration::PreviewMode;
|
||||
use uv_configuration::Preview;
|
||||
use which::{which, which_all};
|
||||
|
||||
use uv_cache::Cache;
|
||||
@@ -335,7 +335,7 @@ fn python_executables_from_installed<'a>(
|
||||
implementation: Option<&'a ImplementationName>,
|
||||
platform: PlatformRequest,
|
||||
preference: PythonPreference,
|
||||
preview: PreviewMode,
|
||||
preview: Preview,
|
||||
) -> Box<dyn Iterator<Item = Result<(PythonSource, PathBuf), Error>> + 'a> {
|
||||
let from_managed_installations = iter::once_with(move || {
|
||||
ManagedPythonInstallations::from_settings(None)
|
||||
@@ -485,7 +485,7 @@ fn python_executables<'a>(
|
||||
platform: PlatformRequest,
|
||||
environments: EnvironmentPreference,
|
||||
preference: PythonPreference,
|
||||
preview: PreviewMode,
|
||||
preview: Preview,
|
||||
) -> Box<dyn Iterator<Item = Result<(PythonSource, PathBuf), Error>> + 'a> {
|
||||
// Always read from `UV_INTERNAL__PARENT_INTERPRETER` — it could be a system interpreter
|
||||
let from_parent_interpreter = iter::once_with(|| {
|
||||
@@ -705,7 +705,7 @@ fn python_interpreters<'a>(
|
||||
environments: EnvironmentPreference,
|
||||
preference: PythonPreference,
|
||||
cache: &'a Cache,
|
||||
preview: PreviewMode,
|
||||
preview: Preview,
|
||||
) -> impl Iterator<Item = Result<(PythonSource, Interpreter), Error>> + 'a {
|
||||
python_interpreters_from_executables(
|
||||
// Perform filtering on the discovered executables based on their source. This avoids
|
||||
@@ -1053,7 +1053,7 @@ pub fn find_python_installations<'a>(
|
||||
environments: EnvironmentPreference,
|
||||
preference: PythonPreference,
|
||||
cache: &'a Cache,
|
||||
preview: PreviewMode,
|
||||
preview: Preview,
|
||||
) -> Box<dyn Iterator<Item = Result<FindPythonResult, Error>> + 'a> {
|
||||
let sources = DiscoveryPreferences {
|
||||
python_preference: preference,
|
||||
@@ -1254,7 +1254,7 @@ pub(crate) fn find_python_installation(
|
||||
environments: EnvironmentPreference,
|
||||
preference: PythonPreference,
|
||||
cache: &Cache,
|
||||
preview: PreviewMode,
|
||||
preview: Preview,
|
||||
) -> Result<FindPythonResult, Error> {
|
||||
let installations =
|
||||
find_python_installations(request, environments, preference, cache, preview);
|
||||
@@ -1353,7 +1353,7 @@ pub(crate) fn find_best_python_installation(
|
||||
environments: EnvironmentPreference,
|
||||
preference: PythonPreference,
|
||||
cache: &Cache,
|
||||
preview: PreviewMode,
|
||||
preview: Preview,
|
||||
) -> Result<FindPythonResult, Error> {
|
||||
debug!("Starting Python discovery for {}", request);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user