Skip to content

make uv version lock and sync #13317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 65 additions & 3 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,6 @@ pub enum Commands {
/// Clear the cache, removing all entries or those linked to specific packages.
#[command(hide = true)]
Clean(CleanArgs),
/// Read or update the project's version.
Version(VersionArgs),
/// Generate shell completion
#[command(alias = "--generate-shell-completion", hide = true)]
GenerateShellCompletion(GenerateShellCompletionArgs),
Expand Down Expand Up @@ -525,29 +523,91 @@ pub struct HelpArgs {
pub command: Option<Vec<String>>,
}

#[derive(Args, Debug)]
#[derive(Args)]
#[command(group = clap::ArgGroup::new("operation"))]
#[allow(clippy::struct_excessive_bools)]
pub struct VersionArgs {
/// Set the project version to this value
///
/// To update the project using semantic versioning components instead, use `--bump`.
#[arg(group = "operation")]
pub value: Option<String>,

/// Update the project version using the given semantics
#[arg(group = "operation", long)]
pub bump: Option<VersionBump>,

/// Don't write a new version to the `pyproject.toml`
///
/// Instead, the version will be displayed.
#[arg(long)]
pub dry_run: bool,

/// Only show the version
///
/// By default, uv will show the project name before the version.
#[arg(long)]
pub short: bool,

/// The format of the output
#[arg(long, value_enum, default_value = "text")]
pub output_format: VersionFormat,

/// Avoid syncing the virtual environment after re-locking the project.
#[arg(long, env = EnvVars::UV_NO_SYNC, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")]
pub no_sync: bool,

/// Prefer the active virtual environment over the project's virtual environment.
///
/// If the project virtual environment is active or no virtual environment is active, this has
/// no effect.
#[arg(long, overrides_with = "no_active")]
pub active: bool,

/// Prefer project's virtual environment over an active environment.
///
/// This is the default behavior.
#[arg(long, overrides_with = "active", hide = true)]
pub no_active: bool,

/// Assert that the `uv.lock` will remain unchanged.
///
/// Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated,
/// uv will exit with an error.
#[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])]
pub locked: bool,

/// Update the version without re-locking the project.
///
/// The project environment will not be synced.
#[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["locked", "upgrade", "no_sources"])]
pub frozen: bool,

#[command(flatten)]
pub installer: ResolverInstallerArgs,

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

#[command(flatten)]
pub refresh: RefreshArgs,

/// Update the version of a specific package in the workspace.
#[arg(long, conflicts_with = "isolated")]
pub package: Option<PackageName>,

/// The Python interpreter to use for resolving and syncing.
///
/// See `uv help python` for details on Python discovery and supported request formats.
#[arg(
long,
short,
env = EnvVars::UV_PYTHON,
verbatim_doc_comment,
help_heading = "Python options",
value_parser = parse_maybe_string,
)]
pub python: Option<Maybe<String>>,
}

#[derive(Debug, Copy, Clone, PartialEq, clap::ValueEnum)]
Expand Down Expand Up @@ -819,6 +879,8 @@ pub enum ProjectCommand {
after_long_help = ""
)]
Remove(RemoveArgs),
/// Read or update the project's version.
Version(VersionArgs),
/// Update the project's environment.
///
/// Syncing ensures that all project dependencies are installed and up-to-date with the
Expand Down
3 changes: 1 addition & 2 deletions crates/uv/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub(crate) use project::remove::remove;
pub(crate) use project::run::{RunCommand, run};
pub(crate) use project::sync::sync;
pub(crate) use project::tree::tree;
pub(crate) use project::version::{project_version, self_version};
pub(crate) use publish::publish;
pub(crate) use python::dir::dir as python_dir;
pub(crate) use python::find::find as python_find;
Expand Down Expand Up @@ -56,7 +57,6 @@ use uv_normalize::PackageName;
use uv_python::PythonEnvironment;
use uv_scripts::Pep723Script;
pub(crate) use venv::venv;
pub(crate) use version::{project_version, self_version};

use crate::printer::Printer;

Expand All @@ -77,7 +77,6 @@ mod run;
mod self_update;
mod tool;
mod venv;
mod version;

#[derive(Copy, Clone)]
pub(crate) enum ExitStatus {
Expand Down
1 change: 1 addition & 0 deletions crates/uv/src/commands/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub(crate) mod remove;
pub(crate) mod run;
pub(crate) mod sync;
pub(crate) mod tree;
pub(crate) mod version;

#[derive(thiserror::Error, Debug)]
pub(crate) enum ProjectError {
Expand Down
Loading
Loading