mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 05:15:00 +00:00
Drop prefer
prefix from toolchain-preference
values (#4602)
I think `--toolchain-preference system` is sufficiently clear and `--toolchain-preference prefer-system` is excessively verbose. This was discussed in the original pull request at https://github.com/astral-sh/uv/pull/4424 but because we had a case for preferring "installed managed" toolchains I was hesitant to change it. Now that I've dropped that in #4601, I think we can drop the prefix.
This commit is contained in:
parent
6799cc883a
commit
c0a06a2c1b
4 changed files with 24 additions and 25 deletions
|
@ -57,16 +57,20 @@ pub enum ToolchainRequest {
|
|||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub enum ToolchainPreference {
|
||||
/// Only use managed toolchains, never use system toolchains.
|
||||
/// Only use managed toolchains; never use system toolchains.
|
||||
OnlyManaged,
|
||||
/// Prefer installed toolchains, only download managed toolchains if no system toolchain is found.
|
||||
///
|
||||
/// Installed managed toolchains are still preferred over system toolchains.
|
||||
#[default]
|
||||
Installed,
|
||||
/// Prefer managed toolchains over system toolchains, even if one needs to be downloaded.
|
||||
PreferManaged,
|
||||
/// Prefer system toolchains, only use managed toolchains if no system toolchain is found.
|
||||
PreferSystem,
|
||||
/// Only use system toolchains, never use managed toolchains.
|
||||
/// Prefer managed toolchains over system toolchains, even if fetching is required.
|
||||
Managed,
|
||||
/// Prefer system toolchains over managed toolchains.
|
||||
///
|
||||
/// If a system toolchain cannot be found, a managed toolchain can be used.
|
||||
System,
|
||||
/// Only use system toolchains; never use managed toolchains.
|
||||
OnlySystem,
|
||||
}
|
||||
|
||||
|
@ -313,12 +317,12 @@ fn python_executables_from_installed<'a>(
|
|||
|
||||
match preference {
|
||||
ToolchainPreference::OnlyManaged => Box::new(from_managed_toolchains),
|
||||
ToolchainPreference::PreferManaged | ToolchainPreference::Installed => Box::new(
|
||||
ToolchainPreference::Managed | ToolchainPreference::Installed => Box::new(
|
||||
from_managed_toolchains
|
||||
.chain(from_search_path)
|
||||
.chain(from_py_launcher),
|
||||
),
|
||||
ToolchainPreference::PreferSystem => Box::new(
|
||||
ToolchainPreference::System => Box::new(
|
||||
from_search_path
|
||||
.chain(from_py_launcher)
|
||||
.chain(from_managed_toolchains),
|
||||
|
@ -1153,7 +1157,7 @@ impl ToolchainPreference {
|
|||
|
||||
match self {
|
||||
ToolchainPreference::OnlyManaged => matches!(source, ToolchainSource::Managed),
|
||||
Self::PreferManaged | Self::PreferSystem | Self::Installed => matches!(
|
||||
Self::Managed | Self::System | Self::Installed => matches!(
|
||||
source,
|
||||
ToolchainSource::Managed
|
||||
| ToolchainSource::SearchPath
|
||||
|
@ -1181,10 +1185,7 @@ impl ToolchainPreference {
|
|||
}
|
||||
|
||||
pub(crate) fn allows_managed(self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::PreferManaged | Self::OnlyManaged | Self::Installed
|
||||
)
|
||||
matches!(self, Self::Managed | Self::OnlyManaged | Self::Installed)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1491,7 +1492,7 @@ impl fmt::Display for ToolchainPreference {
|
|||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
let s = match self {
|
||||
Self::OnlyManaged => "managed toolchains",
|
||||
Self::PreferManaged | Self::Installed | Self::PreferSystem => {
|
||||
Self::Managed | Self::Installed | Self::System => {
|
||||
if cfg!(windows) {
|
||||
"managed toolchains, system path, or `py` launcher"
|
||||
} else {
|
||||
|
|
|
@ -88,9 +88,7 @@ impl Toolchain {
|
|||
let request = request.unwrap_or_default();
|
||||
|
||||
// Perform a fetch aggressively if managed toolchains are preferred
|
||||
if matches!(preference, ToolchainPreference::PreferManaged)
|
||||
&& toolchain_fetch.is_automatic()
|
||||
{
|
||||
if matches!(preference, ToolchainPreference::Managed) && toolchain_fetch.is_automatic() {
|
||||
if let Some(request) = PythonDownloadRequest::try_from_request(&request) {
|
||||
return Self::fetch(request, client_builder, cache).await;
|
||||
}
|
||||
|
|
|
@ -711,7 +711,7 @@ pub fn python_toolchains_for_versions(
|
|||
if let Ok(toolchain) = Toolchain::find(
|
||||
&ToolchainRequest::parse(python_version),
|
||||
EnvironmentPreference::OnlySystem,
|
||||
ToolchainPreference::PreferManaged,
|
||||
ToolchainPreference::Managed,
|
||||
&cache,
|
||||
) {
|
||||
toolchain.into_interpreter().sys_executable().to_owned()
|
||||
|
|
14
uv.schema.json
generated
14
uv.schema.json
generated
|
@ -1218,35 +1218,35 @@
|
|||
"ToolchainPreference": {
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "Only use managed toolchains, never use system toolchains.",
|
||||
"description": "Only use managed toolchains; never use system toolchains.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"only-managed"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Prefer installed toolchains, only download managed toolchains if no system toolchain is found.",
|
||||
"description": "Prefer installed toolchains, only download managed toolchains if no system toolchain is found.\n\nInstalled managed toolchains are still preferred over system toolchains.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"installed"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Prefer managed toolchains over system toolchains, even if one needs to be downloaded.",
|
||||
"description": "Prefer managed toolchains over system toolchains, even if fetching is required.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"prefer-managed"
|
||||
"managed"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Prefer system toolchains, only use managed toolchains if no system toolchain is found.",
|
||||
"description": "Prefer system toolchains over managed toolchains.\n\nIf a system toolchain cannot be found, a managed toolchain can be used.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"prefer-system"
|
||||
"system"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Only use system toolchains, never use managed toolchains.",
|
||||
"description": "Only use system toolchains; never use managed toolchains.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"only-system"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue