mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-29 03:02:55 +00:00
Retain and respect settings in tool upgrades (#5937)
## Summary We now persist the `ResolverInstallerOptions` when writing out a tool receipt. When upgrading, we grab the saved options, and merge with the command-line arguments and user-level filesystem settings (CLI > receipt > filesystem).
This commit is contained in:
parent
44f94524f3
commit
f89403f4f6
27 changed files with 604 additions and 131 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use std::{fmt::Debug, num::NonZeroUsize, path::PathBuf};
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use distribution_types::{FlatIndexLocation, IndexUrl};
|
||||
use install_wheel_rs::linker::LinkMode;
|
||||
|
|
@ -212,7 +212,9 @@ pub struct ResolverOptions {
|
|||
/// Shared settings, relevant to all operations that must resolve and install dependencies. The
|
||||
/// union of [`InstallerOptions`] and [`ResolverOptions`].
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone, Default, Deserialize, CombineOptions, OptionsMetadata)]
|
||||
#[derive(
|
||||
Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, CombineOptions, OptionsMetadata,
|
||||
)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub struct ResolverInstallerOptions {
|
||||
|
|
@ -1243,3 +1245,90 @@ impl From<ResolverInstallerOptions> for InstallerOptions {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The options persisted alongside an installed tool.
|
||||
///
|
||||
/// A mirror of [`ResolverInstallerOptions`], without upgrades and reinstalls, which shouldn't be
|
||||
/// persisted in a tool receipt.
|
||||
#[derive(
|
||||
Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, CombineOptions, OptionsMetadata,
|
||||
)]
|
||||
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub struct ToolOptions {
|
||||
pub index_url: Option<IndexUrl>,
|
||||
pub extra_index_url: Option<Vec<IndexUrl>>,
|
||||
pub no_index: Option<bool>,
|
||||
pub find_links: Option<Vec<FlatIndexLocation>>,
|
||||
pub index_strategy: Option<IndexStrategy>,
|
||||
pub keyring_provider: Option<KeyringProviderType>,
|
||||
pub resolution: Option<ResolutionMode>,
|
||||
pub prerelease: Option<PrereleaseMode>,
|
||||
pub config_settings: Option<ConfigSettings>,
|
||||
pub no_build_isolation: Option<bool>,
|
||||
pub no_build_isolation_package: Option<Vec<PackageName>>,
|
||||
pub exclude_newer: Option<ExcludeNewer>,
|
||||
pub link_mode: Option<LinkMode>,
|
||||
pub compile_bytecode: Option<bool>,
|
||||
pub no_sources: Option<bool>,
|
||||
pub no_build: Option<bool>,
|
||||
pub no_build_package: Option<Vec<PackageName>>,
|
||||
pub no_binary: Option<bool>,
|
||||
pub no_binary_package: Option<Vec<PackageName>>,
|
||||
}
|
||||
|
||||
impl From<ResolverInstallerOptions> for ToolOptions {
|
||||
fn from(value: ResolverInstallerOptions) -> Self {
|
||||
Self {
|
||||
index_url: value.index_url,
|
||||
extra_index_url: value.extra_index_url,
|
||||
no_index: value.no_index,
|
||||
find_links: value.find_links,
|
||||
index_strategy: value.index_strategy,
|
||||
keyring_provider: value.keyring_provider,
|
||||
resolution: value.resolution,
|
||||
prerelease: value.prerelease,
|
||||
config_settings: value.config_settings,
|
||||
no_build_isolation: value.no_build_isolation,
|
||||
no_build_isolation_package: value.no_build_isolation_package,
|
||||
exclude_newer: value.exclude_newer,
|
||||
link_mode: value.link_mode,
|
||||
compile_bytecode: value.compile_bytecode,
|
||||
no_sources: value.no_sources,
|
||||
no_build: value.no_build,
|
||||
no_build_package: value.no_build_package,
|
||||
no_binary: value.no_binary,
|
||||
no_binary_package: value.no_binary_package,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ToolOptions> for ResolverInstallerOptions {
|
||||
fn from(value: ToolOptions) -> Self {
|
||||
Self {
|
||||
index_url: value.index_url,
|
||||
extra_index_url: value.extra_index_url,
|
||||
no_index: value.no_index,
|
||||
find_links: value.find_links,
|
||||
index_strategy: value.index_strategy,
|
||||
keyring_provider: value.keyring_provider,
|
||||
resolution: value.resolution,
|
||||
prerelease: value.prerelease,
|
||||
config_settings: value.config_settings,
|
||||
no_build_isolation: value.no_build_isolation,
|
||||
no_build_isolation_package: value.no_build_isolation_package,
|
||||
exclude_newer: value.exclude_newer,
|
||||
link_mode: value.link_mode,
|
||||
compile_bytecode: value.compile_bytecode,
|
||||
no_sources: value.no_sources,
|
||||
upgrade: None,
|
||||
upgrade_package: None,
|
||||
reinstall: None,
|
||||
reinstall_package: None,
|
||||
no_build: value.no_build,
|
||||
no_build_package: value.no_build_package,
|
||||
no_binary: value.no_binary,
|
||||
no_binary_package: value.no_binary_package,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue