Skip to content

Commit 3574f30

Browse files
committed
Remove --upgrade, --no-upgrade, and --upgrade-package from uv tool upgrade
1 parent de2e9cd commit 3574f30

File tree

3 files changed

+229
-12
lines changed

3 files changed

+229
-12
lines changed

crates/uv-cli/src/lib.rs

+181-1
Original file line numberDiff line numberDiff line change
@@ -3847,8 +3847,188 @@ pub struct ToolUpgradeArgs {
38473847
)]
38483848
pub python: Option<Maybe<String>>,
38493849

3850+
// The following is equivalent to flattening `ResolverInstallerArgs`, with the `--upgrade`,
3851+
// and `--upgrade-package` options hidden, and the `--no-upgrade` option removed.
3852+
/// Allow package upgrades, ignoring pinned versions in any existing output file. Implies
3853+
/// `--refresh`.
3854+
#[arg(hide = true, long, short = 'U', help_heading = "Resolver options")]
3855+
pub upgrade: bool,
3856+
3857+
/// Allow upgrades for a specific package, ignoring pinned versions in any existing output
3858+
/// file. Implies `--refresh-package`.
3859+
#[arg(hide = true, long, short = 'P', help_heading = "Resolver options")]
3860+
pub upgrade_package: Vec<Requirement<VerbatimParsedUrl>>,
3861+
38503862
#[command(flatten)]
3851-
pub installer: ResolverInstallerArgs,
3863+
pub index_args: IndexArgs,
3864+
3865+
/// Reinstall all packages, regardless of whether they're already installed. Implies
3866+
/// `--refresh`.
3867+
#[arg(
3868+
long,
3869+
alias = "force-reinstall",
3870+
overrides_with("no_reinstall"),
3871+
help_heading = "Installer options"
3872+
)]
3873+
pub reinstall: bool,
3874+
3875+
#[arg(
3876+
long,
3877+
overrides_with("reinstall"),
3878+
hide = true,
3879+
help_heading = "Installer options"
3880+
)]
3881+
pub no_reinstall: bool,
3882+
3883+
/// Reinstall a specific package, regardless of whether it's already installed. Implies
3884+
/// `--refresh-package`.
3885+
#[arg(long, help_heading = "Installer options")]
3886+
pub reinstall_package: Vec<PackageName>,
3887+
3888+
/// The strategy to use when resolving against multiple index URLs.
3889+
///
3890+
/// By default, uv will stop at the first index on which a given package is available, and
3891+
/// limit resolutions to those present on that first index (`first-match`). This prevents
3892+
/// "dependency confusion" attacks, whereby an attacker can upload a malicious package under the
3893+
/// same name to an alternate index.
3894+
#[arg(
3895+
long,
3896+
value_enum,
3897+
env = EnvVars::UV_INDEX_STRATEGY,
3898+
help_heading = "Index options"
3899+
)]
3900+
pub index_strategy: Option<IndexStrategy>,
3901+
3902+
/// Attempt to use `keyring` for authentication for index URLs.
3903+
///
3904+
/// At present, only `--keyring-provider subprocess` is supported, which configures uv to
3905+
/// use the `keyring` CLI to handle authentication.
3906+
///
3907+
/// Defaults to `disabled`.
3908+
#[arg(
3909+
long,
3910+
value_enum,
3911+
env = EnvVars::UV_KEYRING_PROVIDER,
3912+
help_heading = "Index options"
3913+
)]
3914+
pub keyring_provider: Option<KeyringProviderType>,
3915+
3916+
/// The strategy to use when selecting between the different compatible versions for a given
3917+
/// package requirement.
3918+
///
3919+
/// By default, uv will use the latest compatible version of each package (`highest`).
3920+
#[arg(
3921+
long,
3922+
value_enum,
3923+
env = EnvVars::UV_RESOLUTION,
3924+
help_heading = "Resolver options"
3925+
)]
3926+
pub resolution: Option<ResolutionMode>,
3927+
3928+
/// The strategy to use when considering pre-release versions.
3929+
///
3930+
/// By default, uv will accept pre-releases for packages that _only_ publish pre-releases,
3931+
/// along with first-party requirements that contain an explicit pre-release marker in the
3932+
/// declared specifiers (`if-necessary-or-explicit`).
3933+
#[arg(
3934+
long,
3935+
value_enum,
3936+
env = EnvVars::UV_PRERELEASE,
3937+
help_heading = "Resolver options"
3938+
)]
3939+
pub prerelease: Option<PrereleaseMode>,
3940+
3941+
#[arg(long, hide = true)]
3942+
pub pre: bool,
3943+
3944+
/// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
3945+
#[arg(
3946+
long,
3947+
short = 'C',
3948+
alias = "config-settings",
3949+
help_heading = "Build options"
3950+
)]
3951+
pub config_setting: Option<Vec<ConfigSettingEntry>>,
3952+
3953+
/// Disable isolation when building source distributions.
3954+
///
3955+
/// Assumes that build dependencies specified by PEP 518 are already installed.
3956+
#[arg(
3957+
long,
3958+
overrides_with("build_isolation"),
3959+
help_heading = "Build options",
3960+
env = EnvVars::UV_NO_BUILD_ISOLATION,
3961+
value_parser = clap::builder::BoolishValueParser::new(),
3962+
)]
3963+
pub no_build_isolation: bool,
3964+
3965+
/// Disable isolation when building source distributions for a specific package.
3966+
///
3967+
/// Assumes that the packages' build dependencies specified by PEP 518 are already installed.
3968+
#[arg(long, help_heading = "Build options")]
3969+
pub no_build_isolation_package: Vec<PackageName>,
3970+
3971+
#[arg(
3972+
long,
3973+
overrides_with("no_build_isolation"),
3974+
hide = true,
3975+
help_heading = "Build options"
3976+
)]
3977+
pub build_isolation: bool,
3978+
3979+
/// Limit candidate packages to those that were uploaded prior to the given date.
3980+
///
3981+
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
3982+
/// format (e.g., `2006-12-02`) in your system's configured time zone.
3983+
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
3984+
pub exclude_newer: Option<ExcludeNewer>,
3985+
3986+
/// The method to use when installing packages from the global cache.
3987+
///
3988+
/// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
3989+
/// Windows.
3990+
#[arg(
3991+
long,
3992+
value_enum,
3993+
env = EnvVars::UV_LINK_MODE,
3994+
help_heading = "Installer options"
3995+
)]
3996+
pub link_mode: Option<uv_install_wheel::linker::LinkMode>,
3997+
3998+
/// Compile Python files to bytecode after installation.
3999+
///
4000+
/// By default, uv does not compile Python (`.py`) files to bytecode (`__pycache__/*.pyc`);
4001+
/// instead, compilation is performed lazily the first time a module is imported. For use-cases
4002+
/// in which start time is critical, such as CLI applications and Docker containers, this option
4003+
/// can be enabled to trade longer installation times for faster start times.
4004+
///
4005+
/// When enabled, uv will process the entire site-packages directory (including packages that
4006+
/// are not being modified by the current operation) for consistency. Like pip, it will also
4007+
/// ignore errors.
4008+
#[arg(
4009+
long,
4010+
alias = "compile",
4011+
overrides_with("no_compile_bytecode"),
4012+
help_heading = "Installer options",
4013+
env = EnvVars::UV_COMPILE_BYTECODE,
4014+
value_parser = clap::builder::BoolishValueParser::new(),
4015+
)]
4016+
pub compile_bytecode: bool,
4017+
4018+
#[arg(
4019+
long,
4020+
alias = "no-compile",
4021+
overrides_with("compile_bytecode"),
4022+
hide = true,
4023+
help_heading = "Installer options"
4024+
)]
4025+
pub no_compile_bytecode: bool,
4026+
4027+
/// Ignore the `tool.uv.sources` table when resolving dependencies. Used to lock against the
4028+
/// standards-compliant, publishable package metadata, as opposed to using any local or Git
4029+
/// sources.
4030+
#[arg(long, help_heading = "Resolver options")]
4031+
pub no_sources: bool,
38524032

38534033
#[command(flatten)]
38544034
pub build: BuildOptionsArgs,

crates/uv/src/settings.rs

+48-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use uv_cache::{CacheArgs, Refresh};
99
use uv_cli::comma::CommaSeparatedRequirements;
1010
use uv_cli::{
1111
options::{flag, resolver_installer_options, resolver_options},
12-
AuthorFrom, BuildArgs, ExportArgs, PublishArgs, PythonDirArgs, ToolUpgradeArgs,
12+
AuthorFrom, BuildArgs, ExportArgs, PublishArgs, PythonDirArgs, ResolverInstallerArgs,
13+
ToolUpgradeArgs,
1314
};
1415
use uv_cli::{
1516
AddArgs, ColorChoice, ExternalCommand, GlobalArgs, InitArgs, ListFormat, LockArgs, Maybe,
@@ -544,19 +545,59 @@ impl ToolUpgradeSettings {
544545
let ToolUpgradeArgs {
545546
name,
546547
python,
548+
upgrade,
549+
upgrade_package,
550+
index_args,
547551
all,
548-
mut installer,
552+
reinstall,
553+
no_reinstall,
554+
reinstall_package,
555+
index_strategy,
556+
keyring_provider,
557+
resolution,
558+
prerelease,
559+
pre,
560+
config_setting,
561+
no_build_isolation,
562+
no_build_isolation_package,
563+
build_isolation,
564+
exclude_newer,
565+
link_mode,
566+
compile_bytecode,
567+
no_compile_bytecode,
568+
no_sources,
549569
build,
550570
} = args;
551571

552-
if installer.upgrade {
553-
// If `--upgrade` was passed explicitly, warn.
572+
if upgrade {
554573
warn_user_once!("`--upgrade` is enabled by default on `uv tool upgrade`");
555-
} else if installer.upgrade_package.is_empty() {
556-
// If neither `--upgrade` nor `--upgrade-package` were passed in, assume `--upgrade`.
557-
installer.upgrade = true;
558574
}
559575

576+
// Enable `--upgrade` by default.
577+
let installer = ResolverInstallerArgs {
578+
index_args,
579+
upgrade: upgrade_package.is_empty(),
580+
no_upgrade: false,
581+
upgrade_package,
582+
reinstall,
583+
no_reinstall,
584+
reinstall_package,
585+
index_strategy,
586+
keyring_provider,
587+
resolution,
588+
prerelease,
589+
pre,
590+
config_setting,
591+
no_build_isolation,
592+
no_build_isolation_package,
593+
build_isolation,
594+
exclude_newer,
595+
link_mode,
596+
compile_bytecode,
597+
no_compile_bytecode,
598+
no_sources,
599+
};
600+
560601
let args = resolver_installer_options(installer, build);
561602
let filesystem = filesystem.map(FilesystemOptions::into_options);
562603
let install_mirrors = filesystem

docs/reference/cli.md

-4
Original file line numberDiff line numberDiff line change
@@ -3741,10 +3741,6 @@ uv tool upgrade [OPTIONS] <NAME>...
37413741

37423742
<li><code>lowest-direct</code>: Resolve the lowest compatible version of any direct dependencies, and the highest compatible version of any transitive dependencies</li>
37433743
</ul>
3744-
</dd><dt><code>--upgrade</code>, <code>-U</code></dt><dd><p>Allow package upgrades, ignoring pinned versions in any existing output file. Implies <code>--refresh</code></p>
3745-
3746-
</dd><dt><code>--upgrade-package</code>, <code>-P</code> <i>upgrade-package</i></dt><dd><p>Allow upgrades for a specific package, ignoring pinned versions in any existing output file. Implies <code>--refresh-package</code></p>
3747-
37483744
</dd><dt><code>--verbose</code>, <code>-v</code></dt><dd><p>Use verbose output.</p>
37493745

37503746
<p>You can configure fine-grained logging using the <code>RUST_LOG</code> environment variable. (&lt;https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives&gt;)</p>

0 commit comments

Comments
 (0)