2024-04-19 16:29:57 -05:00
use std ::ffi ::OsString ;
2024-10-10 14:10:17 -04:00
use std ::ops ::{ Deref , DerefMut } ;
2024-04-12 09:37:51 -04:00
use std ::path ::PathBuf ;
use std ::str ::FromStr ;
2024-06-24 13:16:22 +03:00
use anyhow ::{ anyhow , Result } ;
2024-08-28 18:43:52 +02:00
use clap ::builder ::styling ::{ AnsiColor , Effects , Style } ;
use clap ::builder ::Styles ;
2024-04-12 09:37:51 -04:00
use clap ::{ Args , Parser , Subcommand } ;
2024-10-15 15:24:23 -07:00
2024-09-24 17:33:06 +02:00
use url ::Url ;
2024-04-12 09:37:51 -04:00
use uv_cache ::CacheArgs ;
2024-04-16 11:48:37 -05:00
use uv_configuration ::{
2024-08-29 13:46:42 -04:00
ConfigSettingEntry , ExportFormat , IndexStrategy , KeyringProviderType , PackageNameSpecifier ,
2024-10-16 12:19:59 +00:00
ProjectBuildBackend , TargetTriple , TrustedHost , TrustedPublishing , VersionControlSystem ,
2024-04-16 11:48:37 -05:00
} ;
2024-10-15 16:56:24 -07:00
use uv_distribution_types ::{ Index , IndexUrl , Origin , PipExtraIndex , PipFindLinks , PipIndex } ;
2024-10-16 16:38:11 -05:00
use uv_normalize ::{ ExtraName , GroupName , PackageName } ;
2024-10-01 20:15:32 -04:00
use uv_pep508 ::Requirement ;
use uv_pypi_types ::VerbatimParsedUrl ;
2024-08-09 13:10:19 -05:00
use uv_python ::{ PythonDownloads , PythonPreference , PythonVersion } ;
2024-12-13 16:05:07 -05:00
use uv_resolver ::{ AnnotationStyle , ExcludeNewer , ForkStrategy , PrereleaseMode , ResolutionMode } ;
2024-10-14 21:48:13 +00:00
use uv_static ::EnvVars ;
2024-04-12 09:37:51 -04:00
2024-11-08 15:13:30 -05:00
pub mod comma ;
2024-06-24 13:16:22 +03:00
pub mod compat ;
pub mod options ;
pub mod version ;
#[ derive(Debug, Clone, Copy, clap::ValueEnum) ]
pub enum VersionFormat {
/// Display the version as plain text.
Text ,
/// Display the version as JSON.
Json ,
}
#[ derive(Debug, Default, Clone, clap::ValueEnum) ]
pub enum ListFormat {
/// Display the list of packages in a human-readable table.
#[ default ]
Columns ,
/// Display the list of packages in a `pip freeze`-like format, with one package per line
/// alongside its version.
Freeze ,
/// Display the list of packages in a machine-readable JSON format.
Json ,
}
fn extra_name_with_clap_error ( arg : & str ) -> Result < ExtraName > {
ExtraName ::from_str ( arg ) . map_err ( | _err | {
anyhow! (
" Extra names must start and end with a letter or digit and may only \
contain -, _, ., and alphanumeric characters "
)
} )
}
2024-04-12 09:37:51 -04:00
2024-08-28 18:43:52 +02:00
// Configures Clap v3-style help menu colors
const STYLES : Styles = Styles ::styled ( )
. header ( AnsiColor ::Green . on_default ( ) . effects ( Effects ::BOLD ) )
. usage ( AnsiColor ::Green . on_default ( ) . effects ( Effects ::BOLD ) )
. literal ( AnsiColor ::Cyan . on_default ( ) . effects ( Effects ::BOLD ) )
. placeholder ( AnsiColor ::Cyan . on_default ( ) ) ;
2024-04-12 09:37:51 -04:00
#[ derive(Parser) ]
2024-08-01 23:01:22 +08:00
#[ command(name = " uv " , author, long_version = crate::version::version()) ]
2024-07-03 12:36:38 -04:00
#[ command(about = " An extremely fast Python package manager. " ) ]
2024-04-12 09:37:51 -04:00
#[ command(propagate_version = true) ]
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help` for more details. " ,
after_long_help = " " ,
disable_help_flag = true,
2024-08-01 23:01:22 +08:00
disable_help_subcommand = true,
disable_version_flag = true
2024-07-09 13:43:13 -04:00
) ]
2024-08-28 18:43:52 +02:00
#[ command(styles=STYLES) ]
2024-04-12 09:37:51 -04:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct Cli {
2024-04-12 09:37:51 -04:00
#[ command(subcommand) ]
2024-07-03 19:06:15 +02:00
pub command : Box < Commands > ,
2024-04-12 09:37:51 -04:00
2024-09-17 05:27:19 +02:00
#[ command(flatten) ]
pub top_level : TopLevelArgs ,
}
#[ derive(Parser) ]
#[ command(disable_help_flag = true, disable_version_flag = true) ]
pub struct TopLevelArgs {
2024-04-15 16:29:53 -04:00
#[ command(flatten) ]
2024-08-01 23:01:22 +08:00
pub cache_args : Box < CacheArgs > ,
2024-04-15 16:29:53 -04:00
#[ command(flatten) ]
2024-08-01 23:01:22 +08:00
pub global_args : Box < GlobalArgs > ,
2024-04-17 13:32:29 -04:00
2024-05-08 14:49:52 -04:00
/// The path to a `uv.toml` file to use for configuration.
2024-08-06 20:50:29 -05:00
///
/// While uv configuration can be included in a `pyproject.toml` file, it is
/// not allowed in this context.
2024-08-01 23:01:22 +08:00
#[ arg(
global = true,
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_CONFIG_FILE,
2024-08-01 23:01:22 +08:00
help_heading = " Global options "
) ]
2024-06-24 13:16:22 +03:00
pub config_file : Option < PathBuf > ,
2024-07-09 13:12:01 -04:00
2024-08-06 20:50:29 -05:00
/// Avoid discovering configuration files (`pyproject.toml`, `uv.toml`).
///
/// Normally, configuration files are discovered in the current directory,
2024-07-25 19:58:36 -04:00
/// parent directories, or user configuration directories.
2024-10-14 21:48:13 +00:00
#[ arg(global = true, long, env = EnvVars::UV_NO_CONFIG, value_parser = clap::builder::BoolishValueParser::new(), help_heading = " Global options " ) ]
2024-07-25 19:58:36 -04:00
pub no_config : bool ,
2024-08-06 20:50:29 -05:00
/// Display the concise help for this command.
2024-08-01 23:01:22 +08:00
#[ arg(global = true, short, long, action = clap::ArgAction::HelpShort, help_heading = " Global options " ) ]
2024-07-09 13:12:01 -04:00
help : Option < bool > ,
2024-08-01 23:01:22 +08:00
2024-08-06 20:50:29 -05:00
/// Display the uv version.
2024-08-01 23:01:22 +08:00
#[ arg(global = true, short = 'V', long, action = clap::ArgAction::Version, help_heading = " Global options " ) ]
version : Option < bool > ,
2024-04-15 16:29:53 -04:00
}
#[ derive(Parser, Debug, Clone) ]
2024-08-01 23:01:22 +08:00
#[ command(next_help_heading = " Global options " , next_display_order = 1000) ]
2024-04-18 00:37:38 -04:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct GlobalArgs {
2024-08-06 20:50:29 -05:00
/// Whether to prefer uv-managed or system Python installations.
///
/// By default, uv prefers using Python versions it manages. However, it
/// will use system Python installations if a uv-managed Python is not
/// installed. This option allows prioritizing or ignoring system Python
/// installations.
2024-08-01 23:01:22 +08:00
#[ arg(
global = true,
long,
help_heading = " Python options " ,
2024-08-22 10:57:36 -05:00
display_order = 700,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON_PREFERENCE
2024-08-01 23:01:22 +08:00
) ]
pub python_preference : Option < PythonPreference > ,
2024-08-22 18:19:03 -05:00
#[ allow(clippy::doc_markdown) ]
/// Allow automatically downloading Python when required. [env: "UV_PYTHON_DOWNLOADS=auto"]
2024-08-22 08:29:09 -05:00
#[ arg(global = true, long, help_heading = " Python options " , hide = true) ]
2024-08-09 13:10:19 -05:00
pub allow_python_downloads : bool ,
2024-08-22 18:19:03 -05:00
#[ allow(clippy::doc_markdown) ]
/// Disable automatic downloads of Python. [env: "UV_PYTHON_DOWNLOADS=never"]
2024-08-22 08:29:09 -05:00
#[ arg(global = true, long, help_heading = " Python options " ) ]
2024-08-09 13:10:19 -05:00
pub no_python_downloads : bool ,
/// Deprecated version of [`Self::python_downloads`].
#[ arg(global = true, long, hide = true) ]
pub python_fetch : Option < PythonDownloads > ,
2024-08-01 23:01:22 +08:00
2024-04-12 09:37:51 -04:00
/// Do not print any output.
#[ arg(global = true, long, short, conflicts_with = " verbose " ) ]
2024-06-24 13:16:22 +03:00
pub quiet : bool ,
2024-04-12 09:37:51 -04:00
/// Use verbose output.
///
/// You can configure fine-grained logging using the `RUST_LOG` environment variable.
/// (<https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives>)
#[ arg(global = true, action = clap::ArgAction::Count, long, short, conflicts_with = " quiet " ) ]
2024-06-24 13:16:22 +03:00
pub verbose : u8 ,
2024-04-12 09:37:51 -04:00
2024-08-06 20:50:29 -05:00
/// Disable colors.
///
/// Provided for compatibility with `pip`, use `--color` instead.
2024-04-12 09:37:51 -04:00
#[ arg(global = true, long, hide = true, conflicts_with = " color " ) ]
2024-06-24 13:16:22 +03:00
pub no_color : bool ,
2024-04-12 09:37:51 -04:00
2025-01-05 21:18:16 -05:00
/// Control the use of color in output.
///
/// By default, uv will automatically detect support for colors when writing to a terminal.
2024-04-12 09:37:51 -04:00
#[ arg(
global = true,
long,
value_enum,
2024-04-23 17:13:17 -05:00
conflicts_with = " no_color " ,
value_name = " COLOR_CHOICE "
2024-04-12 09:37:51 -04:00
) ]
2024-10-21 22:34:49 +05:30
pub color : Option < ColorChoice > ,
2024-04-12 09:37:51 -04:00
/// Whether to load TLS certificates from the platform's native certificate store.
///
2024-07-16 16:50:04 -04:00
/// By default, uv loads certificates from the bundled `webpki-roots` crate. The
/// `webpki-roots` are a reliable set of trust roots from Mozilla, and including them in uv
2024-04-12 09:37:51 -04:00
/// improves portability and performance (especially on macOS).
///
/// However, in some cases, you may want to use the platform's native certificate store,
/// especially if you're relying on a corporate trust root (e.g., for a mandatory proxy) that's
/// included in your system's certificate store.
2024-10-14 21:48:13 +00:00
#[ arg(global = true, long, env = EnvVars::UV_NATIVE_TLS, value_parser = clap::builder::BoolishValueParser::new(), overrides_with( " no_native_tls " )) ]
2024-06-24 13:16:22 +03:00
pub native_tls : bool ,
2024-04-18 00:37:38 -04:00
#[ arg(global = true, long, overrides_with( " native_tls " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_native_tls : bool ,
2024-04-22 15:41:15 -05:00
2024-08-06 20:50:29 -05:00
/// Disable network access.
///
/// When disabled, uv will only use locally cached data and locally available files.
2024-12-11 09:32:58 -06:00
#[ arg(global = true, long, overrides_with( " no_offline " ), env = EnvVars::UV_OFFLINE, value_parser = clap::builder::BoolishValueParser::new()) ]
2024-06-24 13:16:22 +03:00
pub offline : bool ,
2024-05-21 20:09:05 -04:00
#[ arg(global = true, long, overrides_with( " offline " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_offline : bool ,
2024-07-01 21:54:24 -04:00
2024-11-07 14:18:13 -06:00
/// Allow insecure connections to a host.
///
/// Can be provided multiple times.
///
/// Expects to receive either a hostname (e.g., `localhost`), a host-port pair (e.g.,
/// `localhost:8080`), or a URL (e.g., `https://localhost`).
///
/// WARNING: Hosts included in this list will not be verified against the system's certificate
/// store. Only use `--allow-insecure-host` in a secure network with verified sources, as it
/// bypasses SSL verification and could expose you to MITM attacks.
#[ arg(
global = true,
long,
alias = " trusted-host " ,
env = EnvVars::UV_INSECURE_HOST,
value_delimiter = ' ',
value_parser = parse_insecure_host,
) ]
pub allow_insecure_host : Option < Vec < Maybe < TrustedHost > > > ,
2024-04-22 15:41:15 -05:00
/// Whether to enable experimental, preview features.
2024-08-06 20:50:29 -05:00
///
/// Preview features may change without warning.
2024-10-14 21:48:13 +00:00
#[ arg(global = true, long, hide = true, env = EnvVars::UV_PREVIEW, value_parser = clap::builder::BoolishValueParser::new(), overrides_with( " no_preview " )) ]
2024-06-24 13:16:22 +03:00
pub preview : bool ,
2024-04-22 15:41:15 -05:00
#[ arg(global = true, long, overrides_with( " preview " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_preview : bool ,
2024-05-13 13:51:32 -04:00
2024-08-06 20:50:29 -05:00
/// Avoid discovering a `pyproject.toml` or `uv.toml` file.
///
/// Normally, configuration files are discovered in the current directory,
/// parent directories, or user configuration directories.
///
/// This option is deprecated in favor of `--no-config`.
2024-07-30 18:40:38 -04:00
#[ arg(global = true, long, hide = true) ]
2024-06-24 13:16:22 +03:00
pub isolated : bool ,
2024-06-13 20:14:23 -07:00
/// Show the resolved settings for the current command.
2024-08-06 20:50:29 -05:00
///
/// This option is used for debugging and development purposes.
2024-06-13 20:14:23 -07:00
#[ arg(global = true, long, hide = true) ]
2024-06-24 13:16:22 +03:00
pub show_settings : bool ,
2024-07-16 23:48:57 +02:00
2024-08-06 20:50:29 -05:00
/// Hide all progress outputs.
///
/// For example, spinners or progress bars.
2024-10-27 12:14:12 -07:00
#[ arg(global = true, long, env = EnvVars::UV_NO_PROGRESS, value_parser = clap::builder::BoolishValueParser::new()) ]
2024-07-16 23:48:57 +02:00
pub no_progress : bool ,
2024-07-29 19:43:55 -04:00
2024-12-04 01:29:33 +00:00
/// Skip writing `uv` installer metadata files (e.g., `INSTALLER`, `REQUESTED`, and `direct_url.json`) to site-packages `.dist-info` directories.
#[ arg(global = true, long, hide = true, env = EnvVars::UV_NO_INSTALLER_METADATA, value_parser = clap::builder::BoolishValueParser::new()) ]
pub no_installer_metadata : bool ,
2024-07-29 19:43:55 -04:00
/// Change to the given directory prior to running the command.
2024-09-24 11:45:33 -05:00
///
/// Relative paths are resolved with the given directory as the base.
///
/// See `--project` to only change the project root directory.
#[ arg(global = true, long) ]
2024-07-29 19:43:55 -04:00
pub directory : Option < PathBuf > ,
2024-09-21 16:19:49 -04:00
/// Run the command within the given project directory.
///
/// All `pyproject.toml`, `uv.toml`, and `.python-version` files will be discovered by walking
/// up the directory tree from the project root, as will the project's virtual environment
/// (`.venv`).
///
/// Other command-line arguments (such as relative paths) will be resolved relative
/// to the current working directory.
///
2024-09-24 11:45:33 -05:00
/// See `--directory` to change the working directory entirely.
///
2024-09-21 16:19:49 -04:00
/// This setting has no effect when used in the `uv pip` interface.
#[ arg(global = true, long) ]
pub project : Option < PathBuf > ,
2024-04-12 09:37:51 -04:00
}
2024-06-13 20:14:23 -07:00
#[ derive(Debug, Copy, Clone, clap::ValueEnum) ]
2024-06-24 13:16:22 +03:00
pub enum ColorChoice {
2024-04-12 09:37:51 -04:00
/// Enables colored output only when the output is going to a terminal or TTY with support.
Auto ,
/// Enables colored output regardless of the detected environment.
Always ,
/// Disables colored output.
Never ,
}
2024-12-09 15:15:17 +01:00
impl ColorChoice {
/// Combine self (higher priority) with an [`anstream::ColorChoice`] (lower priority).
///
/// This method allows prioritizing the user choice, while using the inferred choice for a
/// stream as default.
#[ must_use ]
pub fn and_colorchoice ( self , next : anstream ::ColorChoice ) -> Self {
match self {
Self ::Auto = > match next {
anstream ::ColorChoice ::Auto = > Self ::Auto ,
anstream ::ColorChoice ::Always | anstream ::ColorChoice ::AlwaysAnsi = > Self ::Always ,
anstream ::ColorChoice ::Never = > Self ::Never ,
} ,
Self ::Always | Self ::Never = > self ,
}
}
}
2024-04-12 09:37:51 -04:00
impl From < ColorChoice > for anstream ::ColorChoice {
fn from ( value : ColorChoice ) -> Self {
match value {
ColorChoice ::Auto = > Self ::Auto ,
ColorChoice ::Always = > Self ::Always ,
ColorChoice ::Never = > Self ::Never ,
}
}
}
#[ derive(Subcommand) ]
#[ allow(clippy::large_enum_variant) ]
2024-06-24 13:16:22 +03:00
pub enum Commands {
2024-08-06 16:18:05 -05:00
/// Manage Python projects.
#[ command(flatten) ]
Project ( Box < ProjectCommand > ) ,
2024-08-09 14:46:21 -05:00
2024-08-20 11:12:08 -05:00
/// Run and install commands provided by Python packages.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help tool` for more details. " ,
after_long_help = " "
) ]
2024-05-21 15:51:30 -04:00
Tool ( ToolNamespace ) ,
2024-08-07 11:37:10 -05:00
2024-08-20 11:12:08 -05:00
/// Manage Python versions and installations
2024-08-07 11:37:10 -05:00
///
2024-08-22 09:22:55 -05:00
/// Generally, uv first searches for Python in a virtual environment, either active or in a
2024-09-24 04:15:06 +08:00
/// `.venv` directory in the current working directory or any parent directory. If a virtual
2024-08-22 09:22:55 -05:00
/// environment is not required, uv will then search for a Python interpreter. Python
/// interpreters are found by searching for Python executables in the `PATH` environment
/// variable.
2024-08-07 11:37:10 -05:00
///
2024-11-07 14:08:49 -06:00
/// On Windows, the registry is also searched for Python executables.
2024-08-07 11:37:10 -05:00
///
2024-08-22 09:22:55 -05:00
/// By default, uv will download Python if a version cannot be found. This behavior can be
/// disabled with the `--no-python-downloads` flag or the `python-downloads` setting.
2024-08-07 11:37:10 -05:00
///
/// The `--python` option allows requesting a different interpreter.
///
/// The following Python version request formats are supported:
///
/// - `<version>` e.g. `3`, `3.12`, `3.12.3`
/// - `<version-specifier>` e.g. `>=3.12,<3.13`
/// - `<implementation>` e.g. `cpython` or `cp`
/// - `<implementation>@<version>` e.g. `cpython@3.12`
/// - `<implementation><version>` e.g. `cpython3.12` or `cp312`
/// - `<implementation><version-specifier>` e.g. `cpython>=3.12,<3.13`
2024-08-22 09:22:55 -05:00
/// - `<implementation>-<version>-<os>-<arch>-<libc>` e.g. `cpython-3.12.3-macos-aarch64-none`
2024-08-07 11:37:10 -05:00
///
2024-08-22 09:22:55 -05:00
/// Additionally, a specific system Python interpreter can often be requested with:
2024-08-07 11:37:10 -05:00
///
/// - `<executable-path>` e.g. `/opt/homebrew/bin/python3`
/// - `<executable-name>` e.g. `mypython3`
/// - `<install-dir>` e.g. `/some/environment/`
///
2024-08-22 09:22:55 -05:00
/// When the `--python` option is used, normal discovery rules apply but discovered interpreters
/// are checked for compatibility with the request, e.g., if `pypy` is requested, uv will first
/// check if the virtual environment contains a PyPy interpreter then check if each executable
/// in the path is a PyPy interpreter.
2024-08-09 14:46:21 -05:00
///
2024-08-22 09:22:55 -05:00
/// uv supports discovering CPython, PyPy, and GraalPy interpreters. Unsupported interpreters
/// will be skipped during discovery. If an unsupported interpreter implementation is requested,
/// uv will exit with an error.
2024-08-07 11:37:10 -05:00
#[ clap(verbatim_doc_comment) ]
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help python` for more details. " ,
after_long_help = " "
) ]
2024-07-03 08:44:29 -04:00
Python ( PythonNamespace ) ,
2024-08-06 16:18:05 -05:00
/// Manage Python packages with a pip-compatible interface.
#[ command(
2024-08-21 19:53:54 +12:00
after_help = " Use `uv help pip` for more details. " ,
2024-08-06 16:18:05 -05:00
after_long_help = " "
) ]
Pip ( PipNamespace ) ,
2024-04-12 09:37:51 -04:00
/// Create a virtual environment.
2024-08-09 12:15:22 -05:00
///
/// By default, creates a virtual environment named `.venv` in the working
/// directory. An alternative path may be provided positionally.
///
2024-09-03 14:22:30 -05:00
/// If in a project, the default environment name can be changed with
/// the `UV_PROJECT_ENVIRONMENT` environment variable; this only applies
/// when run from the project root directory.
///
2024-08-09 12:15:22 -05:00
/// If a virtual environment exists at the target path, it will be removed
/// and a new, empty virtual environment will be created.
///
/// When using uv, the virtual environment does not need to be activated. uv
/// will find a virtual environment (named `.venv`) in the working directory
/// or any parent directories.
2024-07-09 13:43:13 -04:00
#[ command(
alias = " virtualenv " ,
alias = " v " ,
after_help = " Use `uv help venv` for more details. " ,
after_long_help = " "
) ]
2024-04-12 09:37:51 -04:00
Venv ( VenvArgs ) ,
2024-09-04 11:23:46 -04:00
/// Build Python packages into source distributions and wheels.
///
2024-09-04 11:30:32 -04:00
/// `uv build` accepts a path to a directory or source distribution,
/// which defaults to the current working directory.
///
/// By default, if passed a directory, `uv build` will build a source
/// distribution ("sdist") from the source directory, and a binary
2024-09-24 04:15:06 +08:00
/// distribution ("wheel") from the source distribution.
2024-09-04 11:23:46 -04:00
///
/// `uv build --sdist` can be used to build only the source distribution,
/// `uv build --wheel` can be used to build only the binary distribution,
/// and `uv build --sdist --wheel` can be used to build both distributions
/// from source.
2024-09-04 11:30:32 -04:00
///
/// If passed a source distribution, `uv build --wheel` will build a wheel
2024-09-24 04:15:06 +08:00
/// from the source distribution.
2024-09-04 11:23:46 -04:00
#[ command(
after_help = " Use `uv help build` for more details. " ,
after_long_help = " "
) ]
Build ( BuildArgs ) ,
2024-09-24 17:33:06 +02:00
/// Upload distributions to an index.
Publish ( PublishArgs ) ,
2024-09-24 19:23:17 +02:00
/// The implementation of the build backend.
///
/// These commands are not directly exposed to the user, instead users invoke their build
/// frontend (PEP 517) which calls the Python shims which calls back into uv with this method.
#[ command(hide = true) ]
BuildBackend {
#[ command(subcommand) ]
command : BuildBackendCommand ,
} ,
2024-08-06 16:18:05 -05:00
/// Manage uv's cache.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help cache` for more details. " ,
after_long_help = " "
) ]
2024-04-12 09:37:51 -04:00
Cache ( CacheNamespace ) ,
2024-07-16 16:50:04 -04:00
/// Manage the uv executable.
2024-04-16 22:07:27 -04:00
#[ command(name = " self " ) ]
2024-04-12 09:37:51 -04:00
Self_ ( SelfNamespace ) ,
/// Clear the cache, removing all entries or those linked to specific packages.
2024-04-16 22:07:27 -04:00
#[ command(hide = true) ]
2024-04-12 09:37:51 -04:00
Clean ( CleanArgs ) ,
/// Display uv's version
Version {
#[ arg(long, value_enum, default_value = " text " ) ]
output_format : VersionFormat ,
} ,
/// Generate shell completion
2024-04-16 22:07:27 -04:00
#[ command(alias = " --generate-shell-completion " , hide = true) ]
2024-08-18 03:34:34 +09:00
GenerateShellCompletion ( GenerateShellCompletionArgs ) ,
2024-07-09 13:43:13 -04:00
/// Display documentation for a command.
2024-08-01 01:10:57 +08:00
// To avoid showing the global options when displaying help for the help command, we are
// responsible for maintaining the options using the `after_help`.
2024-07-09 13:43:13 -04:00
#[ command(help_template = " \
{about-with-newline}
2024-08-01 01:10:57 +08:00
{usage-heading} {usage}{after-help}
" ,
after_help = format!( " \
{heading}Options:{heading:#}
2024-09-24 04:15:06 +08:00
{option}--no-pager{option:#} Disable pager when printing help
2024-08-01 01:10:57 +08:00
" ,
heading = Style::new().bold().underline(),
option = Style::new().bold(),
),
) ]
2024-07-09 13:43:13 -04:00
Help ( HelpArgs ) ,
}
#[ derive(Args, Debug) ]
pub struct HelpArgs {
2024-07-12 18:11:50 +02:00
/// Disable pager when printing help
#[ arg(long) ]
pub no_pager : bool ,
2024-07-09 13:43:13 -04:00
pub command : Option < Vec < String > > ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Args) ]
2024-06-24 13:16:22 +03:00
pub struct SelfNamespace {
2024-04-16 22:07:27 -04:00
#[ command(subcommand) ]
2024-06-24 13:16:22 +03:00
pub command : SelfCommand ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Subcommand) ]
2024-06-24 13:16:22 +03:00
pub enum SelfCommand {
2024-09-10 15:35:31 +02:00
/// Update uv.
Update ( SelfUpdateArgs ) ,
}
#[ derive(Args, Debug) ]
pub struct SelfUpdateArgs {
/// Update to the specified version. If not provided, uv will update to the latest version.
pub target_version : Option < String > ,
2024-09-13 03:27:54 +08:00
/// A GitHub token for authentication.
/// A token is not required but can be used to reduce the chance of encountering rate limits.
2024-10-14 21:48:13 +00:00
#[ arg(long, env = EnvVars::UV_GITHUB_TOKEN) ]
2024-09-13 03:27:54 +08:00
pub token : Option < String > ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Args) ]
2024-06-13 18:43:18 -07:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct CacheNamespace {
2024-04-16 22:07:27 -04:00
#[ command(subcommand) ]
2024-06-24 13:16:22 +03:00
pub command : CacheCommand ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Subcommand) ]
2024-06-24 13:16:22 +03:00
pub enum CacheCommand {
2024-04-12 09:37:51 -04:00
/// Clear the cache, removing all entries or those linked to specific packages.
Clean ( CleanArgs ) ,
/// Prune all unreachable objects from the cache.
2024-07-24 15:34:19 -04:00
Prune ( PruneArgs ) ,
2024-04-12 09:37:51 -04:00
/// Show the cache directory.
2024-08-19 15:51:45 -05:00
///
///
2024-09-24 04:15:06 +08:00
/// By default, the cache is stored in `$XDG_CACHE_HOME/uv` or `$HOME/.cache/uv` on Unix and
2024-08-23 21:34:08 +03:30
/// `%LOCALAPPDATA%\uv\cache` on Windows.
2024-08-19 15:51:45 -05:00
///
/// When `--no-cache` is used, the cache is stored in a temporary directory and discarded when
/// the process exits.
///
/// An alternative cache directory may be specified via the `cache-dir` setting, the
/// `--cache-dir` option, or the `$UV_CACHE_DIR` environment variable.
///
/// Note that it is important for performance for the cache directory to be located on the same
/// file system as the Python environment uv is operating on.
2024-04-12 09:37:51 -04:00
Dir ,
}
2024-06-13 20:14:23 -07:00
#[ derive(Args, Debug) ]
2024-04-12 09:37:51 -04:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct CleanArgs {
2024-04-12 09:37:51 -04:00
/// The packages to remove from the cache.
2024-06-24 13:16:22 +03:00
pub package : Vec < PackageName > ,
2024-04-12 09:37:51 -04:00
}
2024-07-24 15:34:19 -04:00
#[ derive(Args, Debug) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct PruneArgs {
/// Optimize the cache for persistence in a continuous integration environment, like GitHub
/// Actions.
///
/// By default, uv caches both the wheels that it builds from source and the pre-built wheels
/// that it downloads directly, to enable high-performance package installation. In some
/// scenarios, though, persisting pre-built wheels may be undesirable. For example, in GitHub
/// Actions, it's faster to omit pre-built wheels from the cache and instead have re-download
/// them on each run. However, it typically _is_ faster to cache wheels that are built from
/// source, since the wheel building process can be expensive, especially for extension
/// modules.
///
/// In `--ci` mode, uv will prune any pre-built wheels from the cache, but retain any wheels
/// that were built from source.
#[ arg(long) ]
pub ci : bool ,
}
2024-04-12 09:37:51 -04:00
#[ derive(Args) ]
2024-06-13 18:43:18 -07:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct PipNamespace {
2024-04-16 22:07:27 -04:00
#[ command(subcommand) ]
2024-06-24 13:16:22 +03:00
pub command : PipCommand ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Subcommand) ]
2024-06-24 13:16:22 +03:00
pub enum PipCommand {
2024-04-12 09:37:51 -04:00
/// Compile a `requirements.in` file to a `requirements.txt` file.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help pip compile` for more details. " ,
after_long_help = " "
) ]
2024-04-12 09:37:51 -04:00
Compile ( PipCompileArgs ) ,
2024-06-23 12:03:49 -04:00
/// Sync an environment with a `requirements.txt` file.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help pip sync` for more details. " ,
after_long_help = " "
) ]
2024-07-09 20:09:13 -07:00
Sync ( Box < PipSyncArgs > ) ,
2024-06-23 12:03:49 -04:00
/// Install packages into an environment.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help pip install` for more details. " ,
after_long_help = " "
) ]
2024-04-12 09:37:51 -04:00
Install ( PipInstallArgs ) ,
2024-06-23 12:03:49 -04:00
/// Uninstall packages from an environment.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help pip uninstall` for more details. " ,
after_long_help = " "
) ]
2024-04-12 09:37:51 -04:00
Uninstall ( PipUninstallArgs ) ,
2024-07-02 16:44:57 -07:00
/// List, in requirements format, packages installed in an environment.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help pip freeze` for more details. " ,
after_long_help = " "
) ]
2024-04-12 09:37:51 -04:00
Freeze ( PipFreezeArgs ) ,
2024-07-02 16:44:57 -07:00
/// List, in tabular format, packages installed in an environment.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help pip list` for more details. " ,
after_long_help = " "
) ]
2024-04-12 09:37:51 -04:00
List ( PipListArgs ) ,
/// Show information about one or more installed packages.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help pip show` for more details. " ,
after_long_help = " "
) ]
2024-04-12 09:37:51 -04:00
Show ( PipShowArgs ) ,
2024-06-23 12:03:49 -04:00
/// Display the dependency tree for an environment.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help pip tree` for more details. " ,
after_long_help = " "
) ]
2024-06-21 15:48:30 -04:00
Tree ( PipTreeArgs ) ,
2024-04-12 09:37:51 -04:00
/// Verify installed packages have compatible dependencies.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help pip check` for more details. " ,
after_long_help = " "
) ]
2024-04-12 09:37:51 -04:00
Check ( PipCheckArgs ) ,
}
2024-06-11 19:18:16 -07:00
#[ derive(Subcommand) ]
2024-06-24 13:16:22 +03:00
pub enum ProjectCommand {
2024-08-20 11:12:08 -05:00
/// Run a command or script.
2024-08-07 08:26:24 -05:00
///
/// Ensures that the command runs in a Python environment.
///
2024-10-10 14:10:17 -04:00
/// When used with a file ending in `.py` or an HTTP(S) URL, the file
/// will be treated as a script and run with a Python interpreter,
/// i.e., `uv run file.py` is equivalent to `uv run python file.py`.
/// For URLs, the script is temporarily downloaded before execution. If
/// the script contains inline dependency metadata, it will be installed
/// into an isolated, ephemeral environment. When used with `-`, the
/// input will be read from stdin, and treated as a Python script.
2024-08-07 08:26:24 -05:00
///
/// When used in a project, the project environment will be created and
/// updated before invoking the command.
///
/// When used outside a project, if a virtual environment can be found in
/// the current directory or a parent directory, the command will be run in
/// that environment. Otherwise, the command will be run in the environment
/// of the discovered interpreter.
///
/// Arguments following the command (or script) are not interpreted as
/// arguments to uv. All options to uv must be provided before the command,
/// e.g., `uv run --verbose foo`. A `--` can be used to separate the command
/// from uv options for clarity, e.g., `uv run --python 3.12 -- python`.
2024-07-09 13:43:13 -04:00
#[ command(
after_help = " Use `uv help run` for more details. " ,
after_long_help = " "
) ]
2024-06-11 19:18:16 -07:00
Run ( RunArgs ) ,
2024-08-20 11:12:08 -05:00
/// Create a new project.
2024-08-07 11:26:00 -05:00
///
/// Follows the `pyproject.toml` specification.
///
/// If a `pyproject.toml` already exists at the target, uv will exit with an
/// error.
///
/// If a `pyproject.toml` is found in any of the parent directories of the
/// target path, the project will be added as a workspace member of
/// the parent.
///
/// Some project state is not created until needed, e.g., the project
/// virtual environment (`.venv`) and lockfile (`uv.lock`) are lazily
/// created during the first sync.
2024-08-06 16:18:05 -05:00
Init ( InitArgs ) ,
2024-08-20 11:12:08 -05:00
/// Add dependencies to the project.
2024-08-08 10:52:38 -05:00
///
/// Dependencies are added to the project's `pyproject.toml` file.
///
2024-08-16 18:16:42 -05:00
/// If a given dependency exists already, it will be updated to the new version specifier unless
/// it includes markers that differ from the existing specifier in which case another entry for
2024-08-23 09:45:39 +02:00
/// the dependency will be added.
2024-08-08 10:52:38 -05:00
///
2024-08-16 18:16:42 -05:00
/// If no constraint or URL is provided for a dependency, a lower bound is added equal to the
/// latest compatible version of the package, e.g., `>=1.2.3`, unless `--frozen` is provided, in
/// which case no resolution is performed.
2024-08-08 10:52:38 -05:00
///
2024-08-16 18:16:42 -05:00
/// The lockfile and project environment will be updated to reflect the added dependencies. To
/// skip updating the lockfile, use `--frozen`. To skip updating the environment, use
/// `--no-sync`.
2024-08-08 10:52:38 -05:00
///
2024-08-16 18:16:42 -05:00
/// If any of the requested dependencies cannot be found, uv will exit with an error, unless the
/// `--frozen` flag is provided, in which case uv will add the dependencies verbatim without
/// checking that they exist or are compatible with the project.
///
/// uv will search for a project in the current directory or any parent directory. If a project
/// cannot be found, uv will exit with an error.
2024-07-09 13:43:13 -04:00
#[ command(
2024-08-06 16:18:05 -05:00
after_help = " Use `uv help add` for more details. " ,
2024-07-09 13:43:13 -04:00
after_long_help = " "
) ]
2024-08-06 16:18:05 -05:00
Add ( AddArgs ) ,
2024-08-20 11:12:08 -05:00
/// Remove dependencies from the project.
2024-08-08 10:52:38 -05:00
///
/// Dependencies are removed from the project's `pyproject.toml` file.
///
2024-08-16 18:16:42 -05:00
/// If multiple entries exist for a given dependency, i.e., each with different markers, all of
/// the entries will be removed.
///
2024-08-08 10:52:38 -05:00
/// The lockfile and project environment will be updated to reflect the
/// removed dependencies. To skip updating the lockfile, use `--frozen`. To
/// skip updating the environment, use `--no-sync`.
///
/// If any of the requested dependencies are not present in the project, uv
/// will exit with an error.
///
/// If a package has been manually installed in the environment, i.e., with
/// `uv pip install`, it will not be removed by `uv remove`.
///
/// uv will search for a project in the current directory or any parent
/// directory. If a project cannot be found, uv will exit with an error.
2024-07-09 13:43:13 -04:00
#[ command(
2024-08-06 16:18:05 -05:00
after_help = " Use `uv help remove` for more details. " ,
2024-07-09 13:43:13 -04:00
after_long_help = " "
) ]
2024-08-06 16:18:05 -05:00
Remove ( RemoveArgs ) ,
2024-08-20 11:12:08 -05:00
/// Update the project's environment.
2024-08-09 14:46:32 -05:00
///
2024-08-20 11:01:07 -05:00
/// Syncing ensures that all project dependencies are installed and up-to-date with the
/// lockfile.
2024-08-09 14:46:32 -05:00
///
2024-08-20 11:01:07 -05:00
/// By default, an exact sync is performed: uv removes packages that are not declared as
/// dependencies of the project. Use the `--inexact` flag to keep extraneous packages. Note that
/// if an extraneous package conflicts with a project dependency, it will still be removed.
/// Additionally, if `--no-build-isolation` is used, uv will not remove extraneous packages to
/// avoid removing possible build dependencies.
2024-08-09 14:46:32 -05:00
///
2024-08-20 11:01:07 -05:00
/// If the project virtual environment (`.venv`) does not exist, it will be created.
2024-08-09 14:46:32 -05:00
///
2024-08-20 11:01:07 -05:00
/// The project is re-locked before syncing unless the `--locked` or `--frozen` flag is
/// provided.
///
/// uv will search for a project in the current directory or any parent directory. If a project
/// cannot be found, uv will exit with an error.
2024-08-19 12:52:52 -05:00
///
/// Note that, when installing from a lockfile, uv will not provide warnings for yanked package
/// versions.
2024-07-09 13:43:13 -04:00
#[ command(
2024-08-06 16:18:05 -05:00
after_help = " Use `uv help sync` for more details. " ,
2024-07-09 13:43:13 -04:00
after_long_help = " "
) ]
2024-08-06 16:18:05 -05:00
Sync ( SyncArgs ) ,
2024-08-20 11:12:08 -05:00
/// Update the project's lockfile.
2024-08-09 08:51:03 -05:00
///
/// If the project lockfile (`uv.lock`) does not exist, it will be created.
/// If a lockfile is present, its contents will be used as preferences for
/// the resolution.
///
/// If there are no changes to the project's dependencies, locking will have
/// no effect unless the `--upgrade` flag is provided.
2024-07-09 13:43:13 -04:00
#[ command(
2024-08-06 16:18:05 -05:00
after_help = " Use `uv help lock` for more details. " ,
2024-07-09 13:43:13 -04:00
after_long_help = " "
) ]
2024-08-06 16:18:05 -05:00
Lock ( LockArgs ) ,
2024-08-29 13:46:42 -04:00
/// Export the project's lockfile to an alternate format.
///
/// At present, only `requirements-txt` is supported.
///
/// The project is re-locked before exporting unless the `--locked` or `--frozen` flag is
/// provided.
///
/// uv will search for a project in the current directory or any parent directory. If a project
/// cannot be found, uv will exit with an error.
///
/// If operating in a workspace, the root will be exported by default; however, a specific
/// member can be selected using the `--package` option.
#[ command(
after_help = " Use `uv help export` for more details. " ,
after_long_help = " "
) ]
Export ( ExportArgs ) ,
2024-08-20 11:12:08 -05:00
/// Display the project's dependency tree.
2024-07-08 14:07:48 -04:00
Tree ( TreeArgs ) ,
2024-06-11 19:18:16 -07:00
}
2024-04-12 09:37:51 -04:00
/// A re-implementation of `Option`, used to avoid Clap's automatic `Option` flattening in
/// [`parse_index_url`].
#[ derive(Debug, Clone) ]
2024-06-24 13:16:22 +03:00
pub enum Maybe < T > {
2024-04-12 09:37:51 -04:00
Some ( T ) ,
None ,
}
impl < T > Maybe < T > {
2024-06-24 13:16:22 +03:00
pub fn into_option ( self ) -> Option < T > {
2024-04-12 09:37:51 -04:00
match self {
Maybe ::Some ( value ) = > Some ( value ) ,
Maybe ::None = > None ,
}
}
2024-10-15 15:57:26 -07:00
pub fn is_some ( & self ) -> bool {
matches! ( self , Maybe ::Some ( _ ) )
}
2024-04-12 09:37:51 -04:00
}
2024-10-15 16:56:24 -07:00
/// Parse an `--index-url` argument into an [`PipIndex`], mapping the empty string to `None`.
fn parse_index_url ( input : & str ) -> Result < Maybe < PipIndex > , String > {
2024-04-12 09:37:51 -04:00
if input . is_empty ( ) {
Ok ( Maybe ::None )
} else {
2024-10-15 16:56:24 -07:00
IndexUrl ::from_str ( input )
. map ( Index ::from_index_url )
. map ( | index | Index {
origin : Some ( Origin ::Cli ) ,
.. index
} )
. map ( PipIndex ::from )
. map ( Maybe ::Some )
. map_err ( | err | err . to_string ( ) )
}
}
/// Parse an `--extra-index-url` argument into an [`PipExtraIndex`], mapping the empty string to `None`.
fn parse_extra_index_url ( input : & str ) -> Result < Maybe < PipExtraIndex > , String > {
if input . is_empty ( ) {
Ok ( Maybe ::None )
} else {
IndexUrl ::from_str ( input )
. map ( Index ::from_extra_index_url )
. map ( | index | Index {
origin : Some ( Origin ::Cli ) ,
.. index
} )
. map ( PipExtraIndex ::from )
. map ( Maybe ::Some )
. map_err ( | err | err . to_string ( ) )
}
}
/// Parse a `--find-links` argument into an [`PipFindLinks`], mapping the empty string to `None`.
fn parse_find_links ( input : & str ) -> Result < Maybe < PipFindLinks > , String > {
if input . is_empty ( ) {
Ok ( Maybe ::None )
} else {
IndexUrl ::from_str ( input )
. map ( Index ::from_find_links )
. map ( | index | Index {
origin : Some ( Origin ::Cli ) ,
.. index
} )
. map ( PipFindLinks ::from )
. map ( Maybe ::Some )
. map_err ( | err | err . to_string ( ) )
2024-04-12 09:37:51 -04:00
}
}
2024-10-15 16:56:24 -07:00
/// Parse an `--index` argument into an [`Index`], mapping the empty string to `None`.
fn parse_index ( input : & str ) -> Result < Maybe < Index > , String > {
2024-10-15 15:24:23 -07:00
if input . is_empty ( ) {
Ok ( Maybe ::None )
} else {
match Index ::from_str ( input ) {
Ok ( index ) = > Ok ( Maybe ::Some ( Index {
default : false ,
2024-10-15 16:56:24 -07:00
origin : Some ( Origin ::Cli ) ,
2024-10-15 15:24:23 -07:00
.. index
} ) ) ,
Err ( err ) = > Err ( err . to_string ( ) ) ,
}
}
}
2024-10-15 16:56:24 -07:00
/// Parse a `--default-index` argument into an [`Index`], mapping the empty string to `None`.
fn parse_default_index ( input : & str ) -> Result < Maybe < Index > , String > {
2024-10-15 15:24:23 -07:00
if input . is_empty ( ) {
Ok ( Maybe ::None )
} else {
match Index ::from_str ( input ) {
Ok ( index ) = > Ok ( Maybe ::Some ( Index {
default : true ,
2024-10-15 16:56:24 -07:00
origin : Some ( Origin ::Cli ) ,
2024-10-15 15:24:23 -07:00
.. index
} ) ) ,
Err ( err ) = > Err ( err . to_string ( ) ) ,
}
}
}
2024-08-27 09:36:50 -04:00
/// Parse a string into an [`Url`], mapping the empty string to `None`.
fn parse_insecure_host ( input : & str ) -> Result < Maybe < TrustedHost > , String > {
if input . is_empty ( ) {
Ok ( Maybe ::None )
} else {
match TrustedHost ::from_str ( input ) {
Ok ( host ) = > Ok ( Maybe ::Some ( host ) ) ,
Err ( err ) = > Err ( err . to_string ( ) ) ,
}
}
}
2024-06-07 15:03:08 -07:00
/// Parse a string into a [`PathBuf`]. The string can represent a file, either as a path or a
/// `file://` URL.
fn parse_file_path ( input : & str ) -> Result < PathBuf , String > {
if input . starts_with ( " file:// " ) {
let url = match url ::Url ::from_str ( input ) {
Ok ( url ) = > url ,
Err ( err ) = > return Err ( err . to_string ( ) ) ,
} ;
url . to_file_path ( )
. map_err ( | ( ) | " invalid file URL " . to_string ( ) )
2024-04-20 23:32:28 +02:00
} else {
2024-08-21 11:17:49 -04:00
Ok ( PathBuf ::from ( input ) )
2024-04-20 23:32:28 +02:00
}
}
2024-06-07 15:03:08 -07:00
/// Parse a string into a [`PathBuf`], mapping the empty string to `None`.
fn parse_maybe_file_path ( input : & str ) -> Result < Maybe < PathBuf > , String > {
if input . is_empty ( ) {
Ok ( Maybe ::None )
} else {
parse_file_path ( input ) . map ( Maybe ::Some )
}
}
2024-10-04 07:32:03 -04:00
// Parse a string, mapping the empty string to `None`.
#[ allow(clippy::unnecessary_wraps) ]
fn parse_maybe_string ( input : & str ) -> Result < Maybe < String > , String > {
if input . is_empty ( ) {
Ok ( Maybe ::None )
} else {
Ok ( Maybe ::Some ( input . to_string ( ) ) )
}
}
2024-04-12 09:37:51 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct PipCompileArgs {
2024-04-12 09:37:51 -04:00
/// Include all packages listed in the given `requirements.in` files.
///
2024-08-19 11:53:28 -05:00
/// If a `pyproject.toml`, `setup.py`, or `setup.cfg` file is provided, uv will extract the
/// requirements for the relevant project.
2024-06-09 19:48:39 -07:00
///
/// If `-` is provided, then requirements will be read from stdin.
2024-08-19 11:53:28 -05:00
///
/// The order of the requirements files and the requirements in them is used to determine
/// priority during resolution.
2024-06-07 15:03:08 -07:00
#[ arg(required(true), value_parser = parse_file_path) ]
2024-06-24 13:16:22 +03:00
pub src_file : Vec < PathBuf > ,
2024-04-12 09:37:51 -04:00
/// Constrain versions using the given requirements files.
///
/// Constraints files are `requirements.txt`-like files that only control the _version_ of a
/// requirement that's installed. However, including a package in a constraints file will _not_
/// trigger the installation of that package.
///
/// This is equivalent to pip's `--constraint` option.
2024-11-20 10:31:23 -05:00
#[ arg(long, short, alias = " constraint " , env = EnvVars::UV_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path) ]
pub constraints : Vec < Maybe < PathBuf > > ,
2024-04-12 09:37:51 -04:00
/// Override versions using the given requirements files.
///
/// Overrides files are `requirements.txt`-like files that force a specific version of a
/// requirement to be installed, regardless of the requirements declared by any constituent
/// package, and regardless of whether this would be considered an invalid resolution.
///
/// While constraints are _additive_, in that they're combined with the requirements of the
/// constituent packages, overrides are _absolute_, in that they completely replace the
/// requirements of the constituent packages.
2024-11-20 10:31:23 -05:00
#[ arg(long, alias = " override " , env = EnvVars::UV_OVERRIDE, value_delimiter = ' ', value_parser = parse_maybe_file_path) ]
pub overrides : Vec < Maybe < PathBuf > > ,
2024-04-12 09:37:51 -04:00
2024-08-02 04:15:58 +02:00
/// Constrain build dependencies using the given requirements files when building source
/// distributions.
///
/// Constraints files are `requirements.txt`-like files that only control the _version_ of a
/// requirement that's installed. However, including a package in a constraints file will _not_
/// trigger the installation of that package.
2024-11-20 10:31:23 -05:00
#[ arg(long, short, alias = " build-constraint " , env = EnvVars::UV_BUILD_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path) ]
pub build_constraints : Vec < Maybe < PathBuf > > ,
2024-08-02 04:15:58 +02:00
2024-10-22 10:18:16 -04:00
/// Include optional dependencies from the specified extra name; may be provided more than once.
2024-07-16 17:14:27 -04:00
///
2024-06-09 19:48:39 -07:00
/// Only applies to `pyproject.toml`, `setup.py`, and `setup.cfg` sources.
2024-04-16 22:07:27 -04:00
#[ arg(long, conflicts_with = " all_extras " , value_parser = extra_name_with_clap_error) ]
2024-06-24 13:16:22 +03:00
pub extra : Option < Vec < ExtraName > > ,
2024-04-12 09:37:51 -04:00
/// Include all optional dependencies.
2024-07-16 17:14:27 -04:00
///
2024-06-09 19:48:39 -07:00
/// Only applies to `pyproject.toml`, `setup.py`, and `setup.cfg` sources.
2024-04-16 22:07:27 -04:00
#[ arg(long, conflicts_with = " extra " ) ]
2024-06-24 13:16:22 +03:00
pub all_extras : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " all_extras " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_all_extras : bool ,
2024-04-17 14:16:09 -04:00
2024-06-13 17:56:38 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub resolver : ResolverArgs ,
2024-06-13 17:56:38 -07:00
2024-06-13 18:43:18 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub refresh : RefreshArgs ,
2024-06-13 18:43:18 -07:00
2024-04-12 09:37:51 -04:00
/// Ignore package dependencies, instead only add those packages explicitly listed
/// on the command line to the resulting the requirements file.
2024-04-16 22:07:27 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub no_deps : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_deps " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub deps : bool ,
2024-04-17 14:16:09 -04:00
2024-04-12 09:37:51 -04:00
/// Write the compiled requirements to the given `requirements.txt` file.
2024-07-16 17:14:27 -04:00
///
/// If the file already exists, the existing versions will be preferred when resolving
/// dependencies, unless `--upgrade` is also specified.
2024-04-16 22:07:27 -04:00
#[ arg(long, short) ]
2024-06-24 13:16:22 +03:00
pub output_file : Option < PathBuf > ,
2024-04-12 09:37:51 -04:00
/// Include extras in the output file.
///
2024-07-16 16:50:04 -04:00
/// By default, uv strips extras, as any packages pulled in by the extras are already included
2024-04-12 09:37:51 -04:00
/// as dependencies in the output file directly. Further, output files generated with
/// `--no-strip-extras` cannot be used as constraints files in `install` and `sync` invocations.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " strip_extras " )) ]
2024-06-24 13:16:22 +03:00
pub no_strip_extras : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_strip_extras " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub strip_extras : bool ,
2024-04-17 14:16:09 -04:00
2024-06-25 16:55:58 -04:00
/// Include environment markers in the output file.
///
2024-07-16 16:50:04 -04:00
/// By default, uv strips environment markers, as the resolution generated by `compile` is
2024-06-25 16:55:58 -04:00
/// only guaranteed to be correct for the target environment.
#[ arg(long, overrides_with( " strip_markers " )) ]
pub no_strip_markers : bool ,
#[ arg(long, overrides_with( " no_strip_markers " ), hide = true) ]
pub strip_markers : bool ,
2024-04-12 09:37:51 -04:00
/// Exclude comment annotations indicating the source of each package.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " annotate " )) ]
2024-06-24 13:16:22 +03:00
pub no_annotate : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_annotate " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub annotate : bool ,
2024-04-17 14:16:09 -04:00
2024-04-12 09:37:51 -04:00
/// Exclude the comment header at the top of the generated output file.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " header " )) ]
2024-06-24 13:16:22 +03:00
pub no_header : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_header " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub header : bool ,
2024-04-17 14:16:09 -04:00
2024-07-16 17:14:27 -04:00
/// The style of the annotation comments included in the output file, used to indicate the
/// source of each package.
2024-04-17 13:03:29 -04:00
///
/// Defaults to `split`.
#[ arg(long, value_enum) ]
2024-06-24 13:16:22 +03:00
pub annotation_style : Option < AnnotationStyle > ,
2024-04-12 09:37:51 -04:00
2024-07-16 17:14:27 -04:00
/// The header comment to include at the top of the output file generated by `uv pip compile`.
///
/// Used to reflect custom build scripts and commands that wrap `uv pip compile`.
2024-10-14 21:48:13 +00:00
#[ arg(long, env = EnvVars::UV_CUSTOM_COMPILE_COMMAND) ]
2024-06-24 13:16:22 +03:00
pub custom_compile_command : Option < String > ,
2024-04-12 09:37:51 -04:00
2024-08-07 11:37:10 -05:00
/// The Python interpreter to use during resolution.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// A Python interpreter is required for building source distributions to
/// determine package metadata when there are not wheels.
///
/// The interpreter is also used to determine the default minimum Python
/// version, unless `--python-version` is provided.
///
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-10-04 07:32:03 -04:00
#[ arg(long, verbatim_doc_comment, help_heading = " Python options " , value_parser = parse_maybe_string) ]
pub python : Option < Maybe < String > > ,
2024-04-18 00:55:49 -04:00
2024-07-16 17:14:27 -04:00
/// Install packages into the system Python environment.
2024-04-18 00:55:49 -04:00
///
2024-07-16 16:50:04 -04:00
/// By default, uv uses the virtual environment in the current working directory or any parent
2024-04-18 00:55:49 -04:00
/// directory, falling back to searching for a Python executable in `PATH`. The `--system`
2024-07-16 16:50:04 -04:00
/// option instructs uv to avoid using a virtual environment Python and restrict its search to
2024-04-18 00:55:49 -04:00
/// the system path.
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_SYSTEM_PYTHON,
2024-04-19 20:48:55 +08:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-04-18 00:55:49 -04:00
overrides_with( " no_system " )
) ]
2024-06-24 13:16:22 +03:00
pub system : bool ,
2024-04-18 00:55:49 -04:00
2024-06-12 17:22:34 -07:00
#[ arg(long, overrides_with( " system " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_system : bool ,
2024-04-12 09:37:51 -04:00
/// Include distribution hashes in the output file.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_generate_hashes " )) ]
2024-06-24 13:16:22 +03:00
pub generate_hashes : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " generate_hashes " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_generate_hashes : bool ,
2024-04-17 14:16:09 -04:00
2024-04-12 09:37:51 -04:00
/// Don't build source distributions.
///
2024-07-16 16:39:22 -04:00
/// When enabled, resolving will not run arbitrary Python code. The cached wheels of
/// already-built source distributions will be reused, but operations that require building
/// distributions will exit with an error.
2024-04-12 09:37:51 -04:00
///
/// Alias for `--only-binary :all:`.
2024-06-13 08:59:03 -05:00
#[ arg(
long,
conflicts_with = " no_binary " ,
conflicts_with = " only_binary " ,
overrides_with( " build " )
) ]
2024-06-24 13:16:22 +03:00
pub no_build : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-06-13 08:59:03 -05:00
conflicts_with = " no_binary " ,
2024-04-17 14:16:09 -04:00
conflicts_with = " only_binary " ,
overrides_with( " no_build " ),
hide = true
) ]
2024-06-24 13:16:22 +03:00
pub build : bool ,
2024-04-17 14:16:09 -04:00
2024-06-13 08:59:03 -05:00
/// Don't install pre-built wheels.
///
2024-07-16 16:39:22 -04:00
/// The given packages will be built and installed from source. The resolver will still use
/// pre-built wheels to extract package metadata, if available.
2024-06-13 08:59:03 -05:00
///
/// Multiple packages may be provided. Disable binaries for all packages with `:all:`.
/// Clear previously specified packages with `:none:`.
#[ arg(long, conflicts_with = " no_build " ) ]
2024-06-24 13:16:22 +03:00
pub no_binary : Option < Vec < PackageNameSpecifier > > ,
2024-06-13 08:59:03 -05:00
2024-04-12 09:37:51 -04:00
/// Only use pre-built wheels; don't build source distributions.
///
/// When enabled, resolving will not run code from the given packages. The cached wheels of already-built
/// source distributions will be reused, but operations that require building distributions will
/// exit with an error.
///
/// Multiple packages may be provided. Disable binaries for all packages with `:all:`.
/// Clear previously specified packages with `:none:`.
2024-04-16 22:07:27 -04:00
#[ arg(long, conflicts_with = " no_build " ) ]
2024-06-24 13:16:22 +03:00
pub only_binary : Option < Vec < PackageNameSpecifier > > ,
2024-04-12 09:37:51 -04:00
2024-08-07 11:37:10 -05:00
/// The Python version to use for resolution.
///
/// For example, `3.8` or `3.8.17`.
///
/// Defaults to the version of the Python interpreter used for resolution.
///
/// Defines the minimum Python version that must be supported by the
/// resolved requirements.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// If a patch version is omitted, the minimum patch version is assumed. For
/// example, `3.8` is mapped to `3.8.0`.
2024-08-01 11:55:11 -05:00
#[ arg(long, short, help_heading = " Python options " ) ]
2024-06-24 13:16:22 +03:00
pub python_version : Option < PythonVersion > ,
2024-04-12 09:37:51 -04:00
2024-04-18 22:57:41 -04:00
/// The platform for which requirements should be resolved.
///
/// Represented as a "target triple", a string that describes the target platform in terms of
/// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
2024-09-06 19:25:46 -04:00
/// `aarch64-apple-darwin`.
2024-04-18 22:57:41 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub python_platform : Option < TargetTriple > ,
2024-04-18 22:57:41 -04:00
2024-06-25 17:28:50 -04:00
/// Perform a universal resolution, attempting to generate a single `requirements.txt` output
2024-06-27 14:41:45 -04:00
/// file that is compatible with all operating systems, architectures, and Python
/// implementations.
///
/// In universal mode, the current Python version (or user-provided `--python-version`) will be
/// treated as a lower bound. For example, `--universal --python-version 3.7` would produce a
/// universal resolution for Python 3.7 and later.
2024-07-17 17:54:21 +02:00
///
/// Implies `--no-strip-markers`.
2024-06-27 14:51:44 -04:00
#[ arg(
long,
overrides_with( " no_universal " ),
2024-07-17 17:54:21 +02:00
conflicts_with( " python_platform " ),
conflicts_with( " strip_markers " )
2024-06-27 14:51:44 -04:00
) ]
2024-06-25 17:28:50 -04:00
pub universal : bool ,
#[ arg(long, overrides_with( " universal " ), hide = true) ]
pub no_universal : bool ,
2024-04-12 09:37:51 -04:00
/// Specify a package to omit from the output resolution. Its dependencies will still be
/// included in the resolution. Equivalent to pip-compile's `--unsafe-package` option.
2024-04-16 22:07:27 -04:00
#[ arg(long, alias = " unsafe-package " ) ]
2024-06-24 13:16:22 +03:00
pub no_emit_package : Option < Vec < PackageName > > ,
2024-04-12 09:37:51 -04:00
/// Include `--index-url` and `--extra-index-url` entries in the generated output file.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_emit_index_url " )) ]
2024-06-24 13:16:22 +03:00
pub emit_index_url : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " emit_index_url " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_emit_index_url : bool ,
2024-04-17 14:16:09 -04:00
2024-04-12 09:37:51 -04:00
/// Include `--find-links` entries in the generated output file.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_emit_find_links " )) ]
2024-06-24 13:16:22 +03:00
pub emit_find_links : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " emit_find_links " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_emit_find_links : bool ,
2024-04-17 14:16:09 -04:00
2024-06-24 15:25:01 +03:00
/// Include `--no-binary` and `--only-binary` entries in the generated output file.
#[ arg(long, overrides_with( " no_emit_build_options " )) ]
pub emit_build_options : bool ,
#[ arg(long, overrides_with( " emit_build_options " ), hide = true) ]
pub no_emit_build_options : bool ,
2024-04-12 09:37:51 -04:00
/// Whether to emit a marker string indicating when it is known that the
/// resulting set of pinned dependencies is valid.
///
/// The pinned dependencies may be valid even when the marker expression is
/// false, but when the expression is true, the requirements are known to
/// be correct.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_emit_marker_expression " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub emit_marker_expression : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " emit_marker_expression " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_emit_marker_expression : bool ,
2024-04-17 14:16:09 -04:00
2024-04-12 09:37:51 -04:00
/// Include comment annotations indicating the index used to resolve each package (e.g.,
/// `# from https://pypi.org/simple`).
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_emit_index_annotation " )) ]
2024-06-24 13:16:22 +03:00
pub emit_index_annotation : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " emit_index_annotation " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_emit_index_annotation : bool ,
2024-04-17 14:16:09 -04:00
2024-04-12 09:37:51 -04:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub compat_args : compat ::PipCompileCompatArgs ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct PipSyncArgs {
2024-04-12 09:37:51 -04:00
/// Include all packages listed in the given `requirements.txt` files.
2024-06-09 19:48:39 -07:00
///
2024-07-16 16:50:04 -04:00
/// If a `pyproject.toml`, `setup.py`, or `setup.cfg` file is provided, uv will
2024-06-09 19:48:39 -07:00
/// extract the requirements for the relevant project.
///
/// If `-` is provided, then requirements will be read from stdin.
2024-06-07 15:03:08 -07:00
#[ arg(required(true), value_parser = parse_file_path) ]
2024-06-24 13:16:22 +03:00
pub src_file : Vec < PathBuf > ,
2024-04-12 09:37:51 -04:00
2024-05-22 12:30:54 -04:00
/// Constrain versions using the given requirements files.
///
/// Constraints files are `requirements.txt`-like files that only control the _version_ of a
/// requirement that's installed. However, including a package in a constraints file will _not_
/// trigger the installation of that package.
///
/// This is equivalent to pip's `--constraint` option.
2024-11-20 10:31:23 -05:00
#[ arg(long, short, alias = " constraint " , env = EnvVars::UV_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path) ]
pub constraints : Vec < Maybe < PathBuf > > ,
2024-05-22 12:30:54 -04:00
2024-08-02 04:15:58 +02:00
/// Constrain build dependencies using the given requirements files when building source
/// distributions.
///
/// Constraints files are `requirements.txt`-like files that only control the _version_ of a
/// requirement that's installed. However, including a package in a constraints file will _not_
/// trigger the installation of that package.
2024-11-20 10:31:23 -05:00
#[ arg(long, short, alias = " build-constraint " , env = EnvVars::UV_BUILD_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path) ]
pub build_constraints : Vec < Maybe < PathBuf > > ,
2024-08-02 04:15:58 +02:00
2024-06-13 17:56:38 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub installer : InstallerArgs ,
2024-06-13 17:56:38 -07:00
2024-06-13 18:43:18 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub refresh : RefreshArgs ,
2024-06-13 18:43:18 -07:00
2024-04-12 09:37:51 -04:00
/// Require a matching hash for each requirement.
///
2024-11-17 17:57:54 -08:00
/// By default, uv will verify any available hashes in the requirements file, but will not
/// require that all requirements have an associated hash.
///
/// When `--require-hashes` is enabled, _all_ requirements must include a hash or set of hashes,
/// and _all_ requirements must either be pinned to exact versions (e.g., `==1.0.0`), or be
/// specified via direct URL.
2024-04-12 09:37:51 -04:00
///
/// Hash-checking mode introduces a number of additional constraints:
2024-07-16 17:14:27 -04:00
///
2024-04-12 09:37:51 -04:00
/// - Git dependencies are not supported.
/// - Editable installs are not supported.
/// - Local dependencies are not supported, unless they point to a specific wheel (`.whl`) or
/// source archive (`.zip`, `.tar.gz`), as opposed to a directory.
2024-07-17 17:25:31 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_REQUIRE_HASHES,
2024-07-17 17:25:31 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
overrides_with( " no_require_hashes " ),
) ]
2024-06-24 13:16:22 +03:00
pub require_hashes : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " require_hashes " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_require_hashes : bool ,
2024-04-17 14:16:09 -04:00
2024-11-17 17:57:54 -08:00
#[ arg(long, overrides_with( " no_verify_hashes " ), hide = true) ]
pub verify_hashes : bool ,
/// Disable validation of hashes in the requirements file.
2024-07-17 17:25:31 -04:00
///
2024-11-17 17:57:54 -08:00
/// By default, uv will verify any available hashes in the requirements file, but will not
/// require that all requirements have an associated hash. To enforce hash validation, use
/// `--require-hashes`.
2024-07-17 17:25:31 -04:00
#[ arg(
long,
2024-11-17 17:57:54 -08:00
env = EnvVars::UV_NO_VERIFY_HASHES,
2024-07-17 17:25:31 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-11-17 17:57:54 -08:00
overrides_with( " verify_hashes " ),
2024-07-17 17:25:31 -04:00
) ]
pub no_verify_hashes : bool ,
2024-04-12 09:37:51 -04:00
/// The Python interpreter into which packages should be installed.
///
2024-09-04 11:23:46 -04:00
/// By default, syncing requires a virtual environment. A path to an
2024-08-07 11:37:10 -05:00
/// alternative Python can be provided, but it is only recommended in
/// continuous integration (CI) environments and should be used with
/// caution, as it can modify the system Python installation.
///
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-04-12 09:37:51 -04:00
2024-07-16 17:14:27 -04:00
/// Install packages into the system Python environment.
2024-04-12 09:37:51 -04:00
///
2024-07-16 16:50:04 -04:00
/// By default, uv installs into the virtual environment in the current working directory or
/// any parent directory. The `--system` option instructs uv to instead use the first Python
2024-04-12 09:37:51 -04:00
/// found in the system `PATH`.
///
/// WARNING: `--system` is intended for use in continuous integration (CI) environments and
/// should be used with caution, as it can modify the system Python installation.
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_SYSTEM_PYTHON,
2024-04-18 00:37:38 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-04-17 14:16:09 -04:00
overrides_with( " no_system " )
) ]
2024-06-24 13:16:22 +03:00
pub system : bool ,
2024-04-12 09:37:51 -04:00
2024-06-12 17:22:34 -07:00
#[ arg(long, overrides_with( " system " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_system : bool ,
2024-04-17 14:16:09 -04:00
2024-07-16 16:50:04 -04:00
/// Allow uv to modify an `EXTERNALLY-MANAGED` Python installation.
2024-04-12 09:37:51 -04:00
///
/// WARNING: `--break-system-packages` is intended for use in continuous integration (CI)
/// environments, when installing into Python installations that are managed by an external
/// package manager, like `apt`. It should be used with caution, as such Python installations
2024-07-16 16:50:04 -04:00
/// explicitly recommend against modifications by other package managers (like uv or `pip`).
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_BREAK_SYSTEM_PACKAGES,
2024-04-18 00:37:38 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-04-17 14:16:09 -04:00
overrides_with( " no_break_system_packages " )
) ]
2024-06-24 13:16:22 +03:00
pub break_system_packages : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " break_system_packages " )) ]
2024-06-24 13:16:22 +03:00
pub no_break_system_packages : bool ,
2024-04-17 14:16:09 -04:00
2024-07-16 17:14:27 -04:00
/// Install packages into the specified directory, rather than into the virtual or system Python
/// environment. The packages will be installed at the top-level of the directory.
2024-06-06 16:15:28 -04:00
#[ arg(long, conflicts_with = " prefix " ) ]
2024-06-24 13:16:22 +03:00
pub target : Option < PathBuf > ,
2024-04-25 19:15:39 -04:00
2024-06-06 16:15:28 -04:00
/// Install packages into `lib`, `bin`, and other top-level folders under the specified
2024-07-16 17:14:27 -04:00
/// directory, as if a virtual environment were present at that location.
2024-06-06 16:15:28 -04:00
///
/// In general, prefer the use of `--python` to install into an alternate environment, as
/// scripts and other artifacts installed via `--prefix` will reference the installing
/// interpreter, rather than any interpreter added to the `--prefix` directory, rendering them
/// non-portable.
#[ arg(long, conflicts_with = " target " ) ]
2024-06-24 13:16:22 +03:00
pub prefix : Option < PathBuf > ,
2024-06-06 16:15:28 -04:00
2024-04-12 09:37:51 -04:00
/// Don't build source distributions.
///
2024-07-16 16:39:22 -04:00
/// When enabled, resolving will not run arbitrary Python code. The cached wheels of
/// already-built source distributions will be reused, but operations that require building
/// distributions will exit with an error.
2024-04-12 09:37:51 -04:00
///
/// Alias for `--only-binary :all:`.
2024-04-17 14:16:09 -04:00
#[ arg(
long,
conflicts_with = " no_binary " ,
conflicts_with = " only_binary " ,
overrides_with( " build " )
) ]
2024-06-24 13:16:22 +03:00
pub no_build : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(
long,
conflicts_with = " no_binary " ,
conflicts_with = " only_binary " ,
overrides_with( " no_build " ),
hide = true
) ]
2024-06-24 13:16:22 +03:00
pub build : bool ,
2024-04-17 14:16:09 -04:00
2024-04-12 09:37:51 -04:00
/// Don't install pre-built wheels.
///
2024-07-16 16:39:22 -04:00
/// The given packages will be built and installed from source. The resolver will still use
/// pre-built wheels to extract package metadata, if available.
2024-04-12 09:37:51 -04:00
///
/// Multiple packages may be provided. Disable binaries for all packages with `:all:`.
/// Clear previously specified packages with `:none:`.
2024-04-16 22:07:27 -04:00
#[ arg(long, conflicts_with = " no_build " ) ]
2024-06-24 13:16:22 +03:00
pub no_binary : Option < Vec < PackageNameSpecifier > > ,
2024-04-12 09:37:51 -04:00
/// Only use pre-built wheels; don't build source distributions.
///
/// When enabled, resolving will not run code from the given packages. The cached wheels of already-built
/// source distributions will be reused, but operations that require building distributions will
/// exit with an error.
///
/// Multiple packages may be provided. Disable binaries for all packages with `:all:`.
/// Clear previously specified packages with `:none:`.
2024-04-16 22:07:27 -04:00
#[ arg(long, conflicts_with = " no_build " ) ]
2024-06-24 13:16:22 +03:00
pub only_binary : Option < Vec < PackageNameSpecifier > > ,
2024-04-12 09:37:51 -04:00
2024-07-02 09:14:27 -04:00
/// Allow sync of empty requirements, which will clear the environment of all packages.
#[ arg(long, overrides_with( " no_allow_empty_requirements " )) ]
pub allow_empty_requirements : bool ,
#[ arg(long, overrides_with( " allow_empty_requirements " )) ]
pub no_allow_empty_requirements : bool ,
2024-04-22 19:31:55 -04:00
/// The minimum Python version that should be supported by the requirements (e.g.,
/// `3.7` or `3.7.9`).
///
2024-06-03 11:34:12 -04:00
/// If a patch version is omitted, the minimum patch version is assumed. For example, `3.7` is
/// mapped to `3.7.0`.
2024-04-22 19:31:55 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub python_version : Option < PythonVersion > ,
2024-04-22 19:31:55 -04:00
/// The platform for which requirements should be installed.
///
/// Represented as a "target triple", a string that describes the target platform in terms of
/// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
2024-09-06 19:25:46 -04:00
/// `aarch64-apple-darwin`.
2024-04-22 19:31:55 -04:00
///
2024-04-22 22:42:30 -04:00
/// WARNING: When specified, uv will select wheels that are compatible with the _target_
/// platform; as a result, the installed distributions may not be compatible with the _current_
/// platform. Conversely, any distributions that are built from source may be incompatible with
2024-05-22 12:15:17 -04:00
/// the _target_ platform, as they will be built for the _current_ platform. The
2024-04-22 22:42:30 -04:00
/// `--python-platform` option is intended for advanced use cases.
2024-04-22 19:31:55 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub python_platform : Option < TargetTriple > ,
2024-04-22 19:31:55 -04:00
2024-10-24 07:21:56 -05:00
/// Validate the Python environment after completing the installation, to detect packages with
2024-04-12 09:37:51 -04:00
/// missing dependencies or other issues.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_strict " )) ]
2024-06-24 13:16:22 +03:00
pub strict : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " strict " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_strict : bool ,
2024-04-17 14:16:09 -04:00
2024-05-22 12:15:17 -04:00
/// Perform a dry run, i.e., don't actually install anything but resolve the dependencies and
/// print the resulting plan.
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub dry_run : bool ,
2024-05-22 12:15:17 -04:00
2024-04-12 09:37:51 -04:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub compat_args : compat ::PipSyncCompatArgs ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Args) ]
#[ command(group = clap::ArgGroup::new( " sources " ).required(true).multiple(true)) ]
2024-08-16 23:57:45 +02:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct PipInstallArgs {
2024-04-12 09:37:51 -04:00
/// Install all listed packages.
2024-08-19 11:53:28 -05:00
///
/// The order of the packages is used to determine priority during resolution.
2024-04-16 22:07:27 -04:00
#[ arg(group = " sources " ) ]
2024-06-24 13:16:22 +03:00
pub package : Vec < String > ,
2024-04-12 09:37:51 -04:00
2024-06-09 19:48:39 -07:00
/// Install all packages listed in the given `requirements.txt` files.
///
2024-07-16 16:50:04 -04:00
/// If a `pyproject.toml`, `setup.py`, or `setup.cfg` file is provided, uv will
2024-06-09 19:48:39 -07:00
/// extract the requirements for the relevant project.
///
/// If `-` is provided, then requirements will be read from stdin.
2024-11-20 10:31:23 -05:00
#[ arg(long, short, alias = " requirement " , group = " sources " , value_parser = parse_file_path) ]
pub requirements : Vec < PathBuf > ,
2024-04-12 09:37:51 -04:00
/// Install the editable package based on the provided local file path.
2024-04-16 22:07:27 -04:00
#[ arg(long, short, group = " sources " ) ]
2024-06-24 13:16:22 +03:00
pub editable : Vec < String > ,
2024-04-12 09:37:51 -04:00
/// Constrain versions using the given requirements files.
///
/// Constraints files are `requirements.txt`-like files that only control the _version_ of a
/// requirement that's installed. However, including a package in a constraints file will _not_
/// trigger the installation of that package.
///
/// This is equivalent to pip's `--constraint` option.
2024-11-20 10:31:23 -05:00
#[ arg(long, short, alias = " constraint " , env = EnvVars::UV_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path) ]
pub constraints : Vec < Maybe < PathBuf > > ,
2024-04-12 09:37:51 -04:00
/// Override versions using the given requirements files.
///
/// Overrides files are `requirements.txt`-like files that force a specific version of a
/// requirement to be installed, regardless of the requirements declared by any constituent
/// package, and regardless of whether this would be considered an invalid resolution.
///
/// While constraints are _additive_, in that they're combined with the requirements of the
/// constituent packages, overrides are _absolute_, in that they completely replace the
/// requirements of the constituent packages.
2024-11-20 10:31:23 -05:00
#[ arg(long, alias = " override " , env = EnvVars::UV_OVERRIDE, value_delimiter = ' ', value_parser = parse_maybe_file_path) ]
pub overrides : Vec < Maybe < PathBuf > > ,
2024-04-12 09:37:51 -04:00
2024-08-02 04:15:58 +02:00
/// Constrain build dependencies using the given requirements files when building source
/// distributions.
///
/// Constraints files are `requirements.txt`-like files that only control the _version_ of a
/// requirement that's installed. However, including a package in a constraints file will _not_
/// trigger the installation of that package.
2024-11-20 10:31:23 -05:00
#[ arg(long, short, alias = " build-constraint " , env = EnvVars::UV_BUILD_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path) ]
pub build_constraints : Vec < Maybe < PathBuf > > ,
2024-08-02 04:15:58 +02:00
2024-10-22 10:18:16 -04:00
/// Include optional dependencies from the specified extra name; may be provided more than once.
2024-07-16 17:14:27 -04:00
///
2024-06-09 19:48:39 -07:00
/// Only applies to `pyproject.toml`, `setup.py`, and `setup.cfg` sources.
2024-04-16 22:07:27 -04:00
#[ arg(long, conflicts_with = " all_extras " , value_parser = extra_name_with_clap_error) ]
2024-06-24 13:16:22 +03:00
pub extra : Option < Vec < ExtraName > > ,
2024-04-12 09:37:51 -04:00
/// Include all optional dependencies.
2024-07-16 17:14:27 -04:00
///
2024-06-09 19:48:39 -07:00
/// Only applies to `pyproject.toml`, `setup.py`, and `setup.cfg` sources.
2024-04-17 14:16:09 -04:00
#[ arg(long, conflicts_with = " extra " , overrides_with = " no_all_extras " ) ]
2024-06-24 13:16:22 +03:00
pub all_extras : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " all_extras " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_all_extras : bool ,
2024-04-17 14:16:09 -04:00
2024-06-13 17:56:38 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub installer : ResolverInstallerArgs ,
2024-06-13 17:56:38 -07:00
2024-06-13 18:43:18 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub refresh : RefreshArgs ,
2024-04-12 09:37:51 -04:00
/// Ignore package dependencies, instead only installing those packages explicitly listed
/// on the command line or in the requirements files.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " deps " )) ]
2024-06-24 13:16:22 +03:00
pub no_deps : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_deps " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub deps : bool ,
2024-04-17 14:16:09 -04:00
2024-04-12 09:37:51 -04:00
/// Require a matching hash for each requirement.
///
2024-11-17 17:57:54 -08:00
/// By default, uv will verify any available hashes in the requirements file, but will not
/// require that all requirements have an associated hash.
///
/// When `--require-hashes` is enabled, _all_ requirements must include a hash or set of hashes,
/// and _all_ requirements must either be pinned to exact versions (e.g., `==1.0.0`), or be
/// specified via direct URL.
2024-04-12 09:37:51 -04:00
///
/// Hash-checking mode introduces a number of additional constraints:
2024-07-16 17:14:27 -04:00
///
2024-04-12 09:37:51 -04:00
/// - Git dependencies are not supported.
/// - Editable installs are not supported.
/// - Local dependencies are not supported, unless they point to a specific wheel (`.whl`) or
/// source archive (`.zip`, `.tar.gz`), as opposed to a directory.
2024-06-03 10:27:35 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_REQUIRE_HASHES,
2024-06-03 10:27:35 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
overrides_with( " no_require_hashes " ),
) ]
2024-06-24 13:16:22 +03:00
pub require_hashes : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " require_hashes " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_require_hashes : bool ,
2024-04-17 14:16:09 -04:00
2024-11-17 17:57:54 -08:00
#[ arg(long, overrides_with( " no_verify_hashes " ), hide = true) ]
pub verify_hashes : bool ,
/// Disable validation of hashes in the requirements file.
2024-07-17 17:25:31 -04:00
///
2024-11-17 17:57:54 -08:00
/// By default, uv will verify any available hashes in the requirements file, but will not
/// require that all requirements have an associated hash. To enforce hash validation, use
/// `--require-hashes`.
2024-07-17 17:25:31 -04:00
#[ arg(
long,
2024-11-17 17:57:54 -08:00
env = EnvVars::UV_NO_VERIFY_HASHES,
2024-07-17 17:25:31 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-11-17 17:57:54 -08:00
overrides_with( " verify_hashes " ),
2024-07-17 17:25:31 -04:00
) ]
pub no_verify_hashes : bool ,
2024-04-12 09:37:51 -04:00
/// The Python interpreter into which packages should be installed.
///
2024-09-04 11:23:46 -04:00
/// By default, installation requires a virtual environment. A path to an
2024-08-07 11:37:10 -05:00
/// alternative Python can be provided, but it is only recommended in
/// continuous integration (CI) environments and should be used with
/// caution, as it can modify the system Python installation.
///
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-04-12 09:37:51 -04:00
2024-07-16 17:14:27 -04:00
/// Install packages into the system Python environment.
2024-04-12 09:37:51 -04:00
///
2024-07-16 16:50:04 -04:00
/// By default, uv installs into the virtual environment in the current working directory or
/// any parent directory. The `--system` option instructs uv to instead use the first Python
2024-04-12 09:37:51 -04:00
/// found in the system `PATH`.
///
/// WARNING: `--system` is intended for use in continuous integration (CI) environments and
/// should be used with caution, as it can modify the system Python installation.
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_SYSTEM_PYTHON,
2024-04-18 00:37:38 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-04-17 14:16:09 -04:00
overrides_with( " no_system " )
) ]
2024-06-24 13:16:22 +03:00
pub system : bool ,
2024-04-12 09:37:51 -04:00
2024-06-12 17:22:34 -07:00
#[ arg(long, overrides_with( " system " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_system : bool ,
2024-04-17 14:16:09 -04:00
2024-07-16 16:50:04 -04:00
/// Allow uv to modify an `EXTERNALLY-MANAGED` Python installation.
2024-04-12 09:37:51 -04:00
///
/// WARNING: `--break-system-packages` is intended for use in continuous integration (CI)
/// environments, when installing into Python installations that are managed by an external
/// package manager, like `apt`. It should be used with caution, as such Python installations
2024-07-16 16:50:04 -04:00
/// explicitly recommend against modifications by other package managers (like uv or `pip`).
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_BREAK_SYSTEM_PACKAGES,
2024-04-18 00:37:38 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-04-17 14:16:09 -04:00
overrides_with( " no_break_system_packages " )
) ]
2024-06-24 13:16:22 +03:00
pub break_system_packages : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " break_system_packages " )) ]
2024-06-24 13:16:22 +03:00
pub no_break_system_packages : bool ,
2024-04-17 14:16:09 -04:00
2024-07-16 17:14:27 -04:00
/// Install packages into the specified directory, rather than into the virtual or system Python
/// environment. The packages will be installed at the top-level of the directory.
2024-06-06 16:15:28 -04:00
#[ arg(long, conflicts_with = " prefix " ) ]
2024-06-24 13:16:22 +03:00
pub target : Option < PathBuf > ,
2024-04-25 19:15:39 -04:00
2024-06-06 16:15:28 -04:00
/// Install packages into `lib`, `bin`, and other top-level folders under the specified
2024-07-16 17:14:27 -04:00
/// directory, as if a virtual environment were present at that location.
2024-06-06 16:15:28 -04:00
///
/// In general, prefer the use of `--python` to install into an alternate environment, as
/// scripts and other artifacts installed via `--prefix` will reference the installing
/// interpreter, rather than any interpreter added to the `--prefix` directory, rendering them
/// non-portable.
#[ arg(long, conflicts_with = " target " ) ]
2024-06-24 13:16:22 +03:00
pub prefix : Option < PathBuf > ,
2024-06-06 16:15:28 -04:00
2024-04-12 09:37:51 -04:00
/// Don't build source distributions.
///
2024-07-16 16:39:22 -04:00
/// When enabled, resolving will not run arbitrary Python code. The cached wheels of
/// already-built source distributions will be reused, but operations that require building
/// distributions will exit with an error.
2024-04-12 09:37:51 -04:00
///
/// Alias for `--only-binary :all:`.
2024-04-17 14:16:09 -04:00
#[ arg(
long,
conflicts_with = " no_binary " ,
conflicts_with = " only_binary " ,
overrides_with( " build " )
) ]
2024-06-24 13:16:22 +03:00
pub no_build : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(
long,
conflicts_with = " no_binary " ,
conflicts_with = " only_binary " ,
overrides_with( " no_build " ),
hide = true
) ]
2024-06-24 13:16:22 +03:00
pub build : bool ,
2024-04-17 14:16:09 -04:00
2024-04-12 09:37:51 -04:00
/// Don't install pre-built wheels.
///
2024-07-16 16:39:22 -04:00
/// The given packages will be built and installed from source. The resolver will still use
/// pre-built wheels to extract package metadata, if available.
2024-04-12 09:37:51 -04:00
///
/// Multiple packages may be provided. Disable binaries for all packages with `:all:`.
/// Clear previously specified packages with `:none:`.
2024-04-16 22:07:27 -04:00
#[ arg(long, conflicts_with = " no_build " ) ]
2024-06-24 13:16:22 +03:00
pub no_binary : Option < Vec < PackageNameSpecifier > > ,
2024-04-12 09:37:51 -04:00
/// Only use pre-built wheels; don't build source distributions.
///
/// When enabled, resolving will not run code from the given packages. The cached wheels of already-built
/// source distributions will be reused, but operations that require building distributions will
/// exit with an error.
///
/// Multiple packages may be provided. Disable binaries for all packages with `:all:`.
/// Clear previously specified packages with `:none:`.
2024-04-16 22:07:27 -04:00
#[ arg(long, conflicts_with = " no_build " ) ]
2024-06-24 13:16:22 +03:00
pub only_binary : Option < Vec < PackageNameSpecifier > > ,
2024-04-12 09:37:51 -04:00
2024-04-22 19:31:55 -04:00
/// The minimum Python version that should be supported by the requirements (e.g.,
/// `3.7` or `3.7.9`).
///
2024-06-03 11:34:12 -04:00
/// If a patch version is omitted, the minimum patch version is assumed. For example, `3.7` is
/// mapped to `3.7.0`.
2024-04-22 19:31:55 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub python_version : Option < PythonVersion > ,
2024-04-22 19:31:55 -04:00
/// The platform for which requirements should be installed.
///
/// Represented as a "target triple", a string that describes the target platform in terms of
/// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
2024-09-06 19:25:46 -04:00
/// `aarch64-apple-darwin`.
2024-04-22 19:31:55 -04:00
///
2024-04-22 22:42:30 -04:00
/// WARNING: When specified, uv will select wheels that are compatible with the _target_
/// platform; as a result, the installed distributions may not be compatible with the _current_
/// platform. Conversely, any distributions that are built from source may be incompatible with
2024-05-22 12:15:17 -04:00
/// the _target_ platform, as they will be built for the _current_ platform. The
2024-04-22 22:42:30 -04:00
/// `--python-platform` option is intended for advanced use cases.
2024-04-22 19:31:55 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub python_platform : Option < TargetTriple > ,
2024-04-22 19:31:55 -04:00
2024-10-09 15:31:28 +02:00
/// Do not remove extraneous packages present in the environment.
#[ arg(long, overrides_with( " exact " ), alias = " no-exact " , hide = true) ]
pub inexact : bool ,
/// Perform an exact sync, removing extraneous packages.
///
/// By default, installing will make the minimum necessary changes to satisfy the requirements.
/// When enabled, uv will update the environment to exactly match the requirements, removing
/// packages that are not included in the requirements.
#[ arg(long, overrides_with( " inexact " )) ]
pub exact : bool ,
2024-10-24 07:21:56 -05:00
/// Validate the Python environment after completing the installation, to detect packages with
2024-04-12 09:37:51 -04:00
/// missing dependencies or other issues.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_strict " )) ]
2024-06-24 13:16:22 +03:00
pub strict : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " strict " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_strict : bool ,
2024-04-17 14:16:09 -04:00
2024-04-12 09:37:51 -04:00
/// Perform a dry run, i.e., don't actually install anything but resolve the dependencies and
/// print the resulting plan.
2024-04-16 22:07:27 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub dry_run : bool ,
2024-05-03 08:18:36 -04:00
2024-05-07 16:59:53 +02:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub compat_args : compat ::PipInstallCompatArgs ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Args) ]
#[ command(group = clap::ArgGroup::new( " sources " ).required(true).multiple(true)) ]
2024-08-16 23:57:45 +02:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct PipUninstallArgs {
2024-04-12 09:37:51 -04:00
/// Uninstall all listed packages.
2024-04-16 22:07:27 -04:00
#[ arg(group = " sources " ) ]
2024-06-24 13:16:22 +03:00
pub package : Vec < String > ,
2024-04-12 09:37:51 -04:00
/// Uninstall all packages listed in the given requirements files.
2024-11-20 10:31:23 -05:00
#[ arg(long, short, alias = " requirement " , group = " sources " , value_parser = parse_file_path) ]
pub requirements : Vec < PathBuf > ,
2024-04-12 09:37:51 -04:00
/// The Python interpreter from which packages should be uninstalled.
///
2024-09-04 11:23:46 -04:00
/// By default, uninstallation requires a virtual environment. A path to an
2024-08-07 11:37:10 -05:00
/// alternative Python can be provided, but it is only recommended in
/// continuous integration (CI) environments and should be used with
/// caution, as it can modify the system Python installation.
///
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-04-12 09:37:51 -04:00
/// Attempt to use `keyring` for authentication for remote requirements files.
///
2024-07-16 16:50:04 -04:00
/// At present, only `--keyring-provider subprocess` is supported, which configures uv to
2024-06-12 17:18:22 -07:00
/// use the `keyring` CLI to handle authentication.
2024-04-17 13:03:29 -04:00
///
/// Defaults to `disabled`.
2024-10-14 21:48:13 +00:00
#[ arg(long, value_enum, env = EnvVars::UV_KEYRING_PROVIDER) ]
2024-06-24 13:16:22 +03:00
pub keyring_provider : Option < KeyringProviderType > ,
2024-04-12 09:37:51 -04:00
/// Use the system Python to uninstall packages.
///
2024-07-16 16:50:04 -04:00
/// By default, uv uninstalls from the virtual environment in the current working directory or
/// any parent directory. The `--system` option instructs uv to instead use the first Python
2024-04-12 09:37:51 -04:00
/// found in the system `PATH`.
///
/// WARNING: `--system` is intended for use in continuous integration (CI) environments and
/// should be used with caution, as it can modify the system Python installation.
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_SYSTEM_PYTHON,
2024-04-18 00:37:38 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-04-17 14:16:09 -04:00
overrides_with( " no_system " )
) ]
2024-06-24 13:16:22 +03:00
pub system : bool ,
2024-04-12 09:37:51 -04:00
2024-06-12 17:22:34 -07:00
#[ arg(long, overrides_with( " system " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_system : bool ,
2024-04-17 14:16:09 -04:00
2024-07-16 16:50:04 -04:00
/// Allow uv to modify an `EXTERNALLY-MANAGED` Python installation.
2024-04-12 09:37:51 -04:00
///
/// WARNING: `--break-system-packages` is intended for use in continuous integration (CI)
/// environments, when installing into Python installations that are managed by an external
/// package manager, like `apt`. It should be used with caution, as such Python installations
2024-07-16 16:50:04 -04:00
/// explicitly recommend against modifications by other package managers (like uv or `pip`).
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_BREAK_SYSTEM_PACKAGES,
2024-04-18 00:37:38 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-04-17 14:16:09 -04:00
overrides_with( " no_break_system_packages " )
) ]
2024-06-24 13:16:22 +03:00
pub break_system_packages : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " break_system_packages " )) ]
2024-06-24 13:16:22 +03:00
pub no_break_system_packages : bool ,
2024-04-17 14:16:09 -04:00
2024-06-06 16:15:28 -04:00
/// Uninstall packages from the specified `--target` directory.
#[ arg(long, conflicts_with = " prefix " ) ]
2024-06-24 13:16:22 +03:00
pub target : Option < PathBuf > ,
2024-06-06 16:15:28 -04:00
/// Uninstall packages from the specified `--prefix` directory.
#[ arg(long, conflicts_with = " target " ) ]
2024-06-24 13:16:22 +03:00
pub prefix : Option < PathBuf > ,
2024-06-30 19:43:23 -04:00
2024-12-02 02:57:47 +00:00
/// Perform a dry run, i.e., don't actually uninstall anything but print the resulting plan.
#[ arg(long) ]
pub dry_run : bool ,
2024-06-30 19:43:23 -04:00
#[ command(flatten) ]
pub compat_args : compat ::PipGlobalCompatArgs ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct PipFreezeArgs {
2024-04-12 09:37:51 -04:00
/// Exclude any editable packages from output.
2024-04-16 22:07:27 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub exclude_editable : bool ,
2024-04-12 09:37:51 -04:00
2024-07-16 17:14:27 -04:00
/// Validate the Python environment, to detect packages with missing dependencies and other
2024-04-12 09:37:51 -04:00
/// issues.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_strict " )) ]
2024-06-24 13:16:22 +03:00
pub strict : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " strict " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_strict : bool ,
2024-04-17 14:16:09 -04:00
2024-04-12 09:37:51 -04:00
/// The Python interpreter for which packages should be listed.
///
2024-08-07 11:37:10 -05:00
/// By default, uv lists packages in a virtual environment but will show
/// packages in a system Python environment if no virtual environment is
/// found.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-04-12 09:37:51 -04:00
2024-08-07 11:37:10 -05:00
/// List packages in the system Python environment.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// Disables discovery of virtual environments.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery.
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_SYSTEM_PYTHON,
2024-04-18 00:37:38 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-04-17 14:16:09 -04:00
overrides_with( " no_system " )
) ]
2024-06-24 13:16:22 +03:00
pub system : bool ,
2024-04-17 14:16:09 -04:00
2024-06-12 17:22:34 -07:00
#[ arg(long, overrides_with( " system " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_system : bool ,
2024-06-30 19:43:23 -04:00
#[ command(flatten) ]
pub compat_args : compat ::PipGlobalCompatArgs ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct PipListArgs {
2024-04-12 09:37:51 -04:00
/// Only include editable projects.
2024-04-16 22:07:27 -04:00
#[ arg(short, long) ]
2024-06-24 13:16:22 +03:00
pub editable : bool ,
2024-04-12 09:37:51 -04:00
/// Exclude any editable packages from output.
2024-07-27 20:26:46 +08:00
#[ arg(long, conflicts_with = " editable " ) ]
2024-06-24 13:16:22 +03:00
pub exclude_editable : bool ,
2024-04-12 09:37:51 -04:00
/// Exclude the specified package(s) from the output.
2024-04-16 22:07:27 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub r#exclude : Vec < PackageName > ,
2024-04-12 09:37:51 -04:00
/// Select the output format between: `columns` (default), `freeze`, or `json`.
2024-04-16 22:07:27 -04:00
#[ arg(long, value_enum, default_value_t = ListFormat::default()) ]
2024-06-24 13:16:22 +03:00
pub format : ListFormat ,
2024-04-12 09:37:51 -04:00
2024-11-06 21:32:30 -05:00
/// List outdated packages.
///
/// The latest version of each package will be shown alongside the installed version. Up-to-date
/// packages will be omitted from the output.
#[ arg(long, overrides_with( " no_outdated " )) ]
pub outdated : bool ,
#[ arg(long, overrides_with( " outdated " ), hide = true) ]
pub no_outdated : bool ,
2024-07-16 17:14:27 -04:00
/// Validate the Python environment, to detect packages with missing dependencies and other
2024-04-12 09:37:51 -04:00
/// issues.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_strict " )) ]
2024-06-24 13:16:22 +03:00
pub strict : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " strict " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_strict : bool ,
2024-04-17 14:16:09 -04:00
2024-11-08 09:52:32 -05:00
#[ command(flatten) ]
pub fetch : FetchArgs ,
2024-04-12 09:37:51 -04:00
/// The Python interpreter for which packages should be listed.
///
2024-08-07 11:37:10 -05:00
/// By default, uv lists packages in a virtual environment but will show
/// packages in a system Python environment if no virtual environment is
/// found.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-04-12 09:37:51 -04:00
2024-08-07 11:37:10 -05:00
/// List packages in the system Python environment.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// Disables discovery of virtual environments.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery.
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_SYSTEM_PYTHON,
2024-04-18 00:37:38 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-04-17 14:16:09 -04:00
overrides_with( " no_system " )
) ]
2024-06-24 13:16:22 +03:00
pub system : bool ,
2024-04-16 14:31:01 +01:00
2024-06-12 17:22:34 -07:00
#[ arg(long, overrides_with( " system " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_system : bool ,
2024-04-17 14:16:09 -04:00
2024-04-16 14:31:01 +01:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub compat_args : compat ::PipListCompatArgs ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct PipCheckArgs {
2024-08-07 11:37:10 -05:00
/// The Python interpreter for which packages should be checked.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// By default, uv checks packages in a virtual environment but will check
/// packages in a system Python environment if no virtual environment is
/// found.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-04-12 09:37:51 -04:00
2024-08-07 11:37:10 -05:00
/// Check packages in the system Python environment.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// Disables discovery of virtual environments.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery.
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_SYSTEM_PYTHON,
2024-04-18 00:37:38 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-04-17 14:16:09 -04:00
overrides_with( " no_system " )
) ]
2024-06-24 13:16:22 +03:00
pub system : bool ,
2024-04-17 14:16:09 -04:00
2024-06-12 17:22:34 -07:00
#[ arg(long, overrides_with( " system " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_system : bool ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct PipShowArgs {
2024-04-12 09:37:51 -04:00
/// The package(s) to display.
2024-06-24 13:16:22 +03:00
pub package : Vec < PackageName > ,
2024-04-12 09:37:51 -04:00
2024-07-16 17:14:27 -04:00
/// Validate the Python environment, to detect packages with missing dependencies and other
2024-04-12 09:37:51 -04:00
/// issues.
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " no_strict " )) ]
2024-06-24 13:16:22 +03:00
pub strict : bool ,
2024-04-12 09:37:51 -04:00
2024-04-17 14:16:09 -04:00
#[ arg(long, overrides_with( " strict " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_strict : bool ,
2024-04-17 14:16:09 -04:00
2024-10-21 00:13:41 +08:00
/// Show the full list of installed files for each package.
#[ arg(short, long) ]
pub files : bool ,
2024-08-07 11:37:10 -05:00
/// The Python interpreter to find the package in.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// By default, uv looks for packages in a virtual environment but will look
/// for packages in a system Python environment if no virtual environment is
/// found.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-04-12 09:37:51 -04:00
2024-08-07 11:37:10 -05:00
/// Show a package in the system Python environment.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// Disables discovery of virtual environments.
2024-04-12 09:37:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery.
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_SYSTEM_PYTHON,
2024-04-18 00:37:38 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-04-17 14:16:09 -04:00
overrides_with( " no_system " )
) ]
2024-06-24 13:16:22 +03:00
pub system : bool ,
2024-04-17 14:16:09 -04:00
2024-06-12 17:22:34 -07:00
#[ arg(long, overrides_with( " system " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_system : bool ,
2024-06-30 19:43:23 -04:00
#[ command(flatten) ]
pub compat_args : compat ::PipGlobalCompatArgs ,
2024-04-12 09:37:51 -04:00
}
2024-06-21 15:48:30 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct PipTreeArgs {
2024-08-05 14:51:18 -04:00
/// Show the version constraint(s) imposed on each package.
#[ arg(long) ]
pub show_version_specifiers : bool ,
2024-07-08 14:07:48 -04:00
#[ command(flatten) ]
pub tree : DisplayTreeArgs ,
2024-07-01 12:58:28 -04:00
2024-07-16 17:14:27 -04:00
/// Validate the Python environment, to detect packages with missing dependencies and other
2024-06-21 15:48:30 -04:00
/// issues.
#[ arg(long, overrides_with( " no_strict " )) ]
2024-06-24 13:16:22 +03:00
pub strict : bool ,
2024-06-21 15:48:30 -04:00
#[ arg(long, overrides_with( " strict " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_strict : bool ,
2024-06-21 15:48:30 -04:00
2024-12-27 12:03:06 -05:00
#[ command(flatten) ]
pub fetch : FetchArgs ,
2024-06-21 15:48:30 -04:00
/// The Python interpreter for which packages should be listed.
///
2024-08-07 11:37:10 -05:00
/// By default, uv lists packages in a virtual environment but will show
/// packages in a system Python environment if no virtual environment is
/// found.
2024-06-21 15:48:30 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-06-21 15:48:30 -04:00
2024-08-07 11:37:10 -05:00
/// List packages in the system Python environment.
2024-06-21 15:48:30 -04:00
///
2024-08-07 11:37:10 -05:00
/// Disables discovery of virtual environments.
2024-06-21 15:48:30 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery.
2024-06-21 15:48:30 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_SYSTEM_PYTHON,
2024-06-21 15:48:30 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
overrides_with( " no_system " )
) ]
2024-06-24 13:16:22 +03:00
pub system : bool ,
2024-06-21 15:48:30 -04:00
2024-11-11 21:32:31 -05:00
#[ arg(long, overrides_with( " system " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_system : bool ,
2024-06-30 19:43:23 -04:00
#[ command(flatten) ]
pub compat_args : compat ::PipGlobalCompatArgs ,
2024-06-21 15:48:30 -04:00
}
2024-09-04 11:23:46 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct BuildArgs {
2024-09-04 11:30:32 -04:00
/// The directory from which distributions should be built, or a source
/// distribution archive to build into a wheel.
2024-09-04 11:23:46 -04:00
///
/// Defaults to the current working directory.
#[ arg(value_parser = parse_file_path) ]
2024-09-04 11:30:32 -04:00
pub src : Option < PathBuf > ,
2024-09-04 11:23:46 -04:00
2024-09-04 11:52:21 -04:00
/// Build a specific package in the workspace.
///
/// The workspace will be discovered from the provided source directory, or the current
/// directory if no source directory is provided.
///
/// If the workspace member does not exist, uv will exit with an error.
2024-11-01 21:55:08 -04:00
#[ arg(long, conflicts_with( " all_packages " )) ]
2024-09-04 11:52:21 -04:00
pub package : Option < PackageName > ,
2024-09-27 04:46:06 +02:00
/// Builds all packages in the workspace.
///
/// The workspace will be discovered from the provided source directory, or the current
/// directory if no source directory is provided.
///
/// If the workspace member does not exist, uv will exit with an error.
2024-11-01 21:55:08 -04:00
#[ arg(long, alias = " all " , conflicts_with( " package " )) ]
pub all_packages : bool ,
2024-09-27 04:46:06 +02:00
2024-09-04 11:23:46 -04:00
/// The output directory to which distributions should be written.
///
2024-09-04 11:30:32 -04:00
/// Defaults to the `dist` subdirectory within the source directory, or the
/// directory containing the source distribution archive.
2024-09-04 11:23:46 -04:00
#[ arg(long, short, value_parser = parse_file_path) ]
pub out_dir : Option < PathBuf > ,
/// Build a source distribution ("sdist") from the given directory.
#[ arg(long) ]
pub sdist : bool ,
/// Build a binary distribution ("wheel") from the given directory.
#[ arg(long) ]
pub wheel : bool ,
2024-12-04 09:52:27 +01:00
/// When using the uv build backend, list the files that would be included when building.
///
/// Skips building the actual distribution, except when the source distribution is needed to
/// build the wheel. The file list is collected directly without a PEP 517 environment. It only
/// works with the uv build backend, there is no PEP 517 file list build hook.
///
/// This option can be combined with `--sdist` and `--wheel` for inspecting different build
/// paths.
// Hidden while in preview.
#[ arg(long, hide = true) ]
pub list : bool ,
2024-09-26 18:39:47 -05:00
#[ arg(long, overrides_with( " no_build_logs " ), hide = true) ]
pub build_logs : bool ,
/// Hide logs from the build backend.
2024-12-04 12:22:01 -06:00
#[ arg(long, overrides_with( " build_logs " )) ]
2024-09-26 18:39:47 -05:00
pub no_build_logs : bool ,
2024-12-02 16:37:50 +01:00
/// Always build through PEP 517, don't use the fast path for the uv build backend.
///
/// By default, uv won't create a PEP 517 build environment for packages using the uv build
/// backend, but use a fast path that calls into the build backend directly. This option forces
/// always using PEP 517.
2024-12-04 09:52:27 +01:00
#[ arg(long, conflicts_with = " list " ) ]
2024-12-03 11:15:54 +01:00
pub force_pep517 : bool ,
2024-12-02 16:37:50 +01:00
2024-09-05 14:46:36 -04:00
/// Constrain build dependencies using the given requirements files when building
/// distributions.
///
/// Constraints files are `requirements.txt`-like files that only control the _version_ of a
/// build dependency that's installed. However, including a package in a constraints file will
/// _not_ trigger the inclusion of that package on its own.
2024-11-20 10:31:23 -05:00
#[ arg(long, short, alias = " build-constraint " , env = EnvVars::UV_BUILD_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path) ]
pub build_constraints : Vec < Maybe < PathBuf > > ,
2024-09-05 14:46:36 -04:00
2024-11-17 17:57:54 -08:00
/// Require a matching hash for each requirement.
///
/// By default, uv will verify any available hashes in the requirements file, but will not
/// require that all requirements have an associated hash.
2024-09-05 15:22:03 -04:00
///
2024-11-17 17:57:54 -08:00
/// When `--require-hashes` is enabled, _all_ requirements must include a hash or set of hashes,
/// and _all_ requirements must either be pinned to exact versions (e.g., `==1.0.0`), or be
/// specified via direct URL.
2024-09-05 15:22:03 -04:00
///
/// Hash-checking mode introduces a number of additional constraints:
///
/// - Git dependencies are not supported.
/// - Editable installs are not supported.
/// - Local dependencies are not supported, unless they point to a specific wheel (`.whl`) or
/// source archive (`.zip`, `.tar.gz`), as opposed to a directory.
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_REQUIRE_HASHES,
2024-09-05 15:22:03 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
overrides_with( " no_require_hashes " ),
) ]
pub require_hashes : bool ,
#[ arg(long, overrides_with( " require_hashes " ), hide = true) ]
pub no_require_hashes : bool ,
2024-11-17 17:57:54 -08:00
#[ arg(long, overrides_with( " no_verify_hashes " ), hide = true) ]
pub verify_hashes : bool ,
/// Disable validation of hashes in the requirements file.
2024-09-05 15:22:03 -04:00
///
2024-11-17 17:57:54 -08:00
/// By default, uv will verify any available hashes in the requirements file, but will not
/// require that all requirements have an associated hash. To enforce hash validation, use
/// `--require-hashes`.
2024-09-05 15:22:03 -04:00
#[ arg(
long,
2024-11-17 17:57:54 -08:00
env = EnvVars::UV_NO_VERIFY_HASHES,
2024-09-05 15:22:03 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-11-17 17:57:54 -08:00
overrides_with( " verify_hashes " ),
2024-09-05 15:22:03 -04:00
) ]
pub no_verify_hashes : bool ,
2024-09-04 11:23:46 -04:00
/// The Python interpreter to use for the build environment.
///
/// By default, builds are executed in isolated virtual environments. The
/// discovered interpreter will be used to create those environments, and
/// will be symlinked or copied in depending on the platform.
///
/// See `uv help python` to view supported request formats.
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-09-04 11:23:46 -04:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-09-04 11:23:46 -04:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-09-04 11:23:46 -04:00
#[ command(flatten) ]
pub resolver : ResolverArgs ,
#[ command(flatten) ]
pub build : BuildOptionsArgs ,
#[ command(flatten) ]
pub refresh : RefreshArgs ,
}
2024-04-12 09:37:51 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct VenvArgs {
2024-04-12 09:37:51 -04:00
/// The Python interpreter to use for the virtual environment.
///
2024-08-07 11:37:10 -05:00
/// During virtual environment creation, uv will not look for Python
/// interpreters in virtual environments.
2024-04-12 09:37:51 -04:00
///
2024-12-11 12:48:35 -06:00
/// See `uv help python` for details on Python discovery and supported
2024-08-07 11:37:10 -05:00
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-04-12 09:37:51 -04:00
2024-08-08 13:32:00 -05:00
/// Ignore virtual environments when searching for the Python interpreter.
///
/// This is the default behavior and has no effect.
2024-04-17 14:16:09 -04:00
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_SYSTEM_PYTHON,
2024-04-18 00:37:38 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-08-08 13:32:00 -05:00
overrides_with( " no_system " ),
hide = true,
2024-04-17 14:16:09 -04:00
) ]
2024-06-24 13:16:22 +03:00
pub system : bool ,
2024-04-12 09:37:51 -04:00
2024-08-08 13:32:00 -05:00
/// This flag is included for compatibility only, it has no effect.
///
/// uv will never search for interpreters in virtual environments when
/// creating a virtual environment.
2024-06-12 17:22:34 -07:00
#[ arg(long, overrides_with( " system " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_system : bool ,
2024-04-17 14:16:09 -04:00
2024-09-03 14:22:30 -05:00
/// Avoid discovering a project or workspace.
///
/// By default, uv searches for projects in the current directory or any parent directory to
/// determine the default path of the virtual environment and check for Python version
/// constraints, if any.
#[ arg(long, alias = " no-workspace " ) ]
pub no_project : bool ,
2024-06-27 16:36:15 +02:00
/// Install seed packages (one or more of: `pip`, `setuptools`, and `wheel`) into the virtual environment.
///
/// Note `setuptools` and `wheel` are not included in Python 3.12+ environments.
2024-04-16 22:07:27 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub seed : bool ,
2024-04-12 09:37:51 -04:00
2024-05-07 13:11:31 -04:00
/// Preserve any existing files or directories at the target path.
2024-05-01 09:34:52 -07:00
///
/// By default, `uv venv` will remove an existing virtual environment at the given path, and
2024-05-07 13:11:31 -04:00
/// exit with an error if the path is non-empty but _not_ a virtual environment. The
/// `--allow-existing` option will instead write to the given path, regardless of its contents,
/// and without clearing it beforehand.
///
/// WARNING: This option can lead to unexpected behavior if the existing virtual environment
/// and the newly-created virtual environment are linked to different Python interpreters.
2024-05-01 09:34:52 -07:00
#[ clap(long) ]
2024-06-24 13:16:22 +03:00
pub allow_existing : bool ,
2024-05-01 09:34:52 -07:00
2024-04-12 09:37:51 -04:00
/// The path to the virtual environment to create.
2024-09-03 14:22:30 -05:00
///
/// Default to `.venv` in the working directory.
///
/// Relative paths are resolved relative to the working directory.
pub path : Option < PathBuf > ,
2024-04-12 09:37:51 -04:00
/// Provide an alternative prompt prefix for the virtual environment.
///
2024-08-09 12:15:22 -05:00
/// By default, the prompt is dependent on whether a path was provided to
/// `uv venv`. If provided (e.g, `uv venv project`), the prompt is set to
/// the directory name. If not provided (`uv venv`), the prompt is set to
/// the current directory's name.
2024-04-12 09:37:51 -04:00
///
2024-08-09 12:15:22 -05:00
/// If "." is provided, the the current directory name will be used
/// regardless of whether a path was provided to `uv venv`.
2024-04-16 22:07:27 -04:00
#[ arg(long, verbatim_doc_comment) ]
2024-06-24 13:16:22 +03:00
pub prompt : Option < String > ,
2024-04-12 09:37:51 -04:00
/// Give the virtual environment access to the system site packages directory.
///
2024-07-16 16:50:04 -04:00
/// Unlike `pip`, when a virtual environment is created with `--system-site-packages`, uv will
2024-04-12 09:37:51 -04:00
/// _not_ take system site packages into account when running commands like `uv pip list` or
/// `uv pip install`. The `--system-site-packages` flag will provide the virtual environment
2024-08-09 12:15:22 -05:00
/// with access to the system site packages directory at runtime, but will not affect the
2024-07-16 16:50:04 -04:00
/// behavior of uv commands.
2024-04-16 22:07:27 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub system_site_packages : bool ,
2024-04-12 09:37:51 -04:00
2024-07-29 01:10:11 +01:00
/// Make the virtual environment relocatable.
///
/// A relocatable virtual environment can be moved around and redistributed without
/// invalidating its associated entrypoint and activation scripts.
///
/// Note that this can only be guaranteed for standard `console_scripts` and `gui_scripts`.
/// Other scripts may be adjusted if they ship with a generic `#!python[w]` shebang,
/// and binaries are left as-is.
///
/// As a result of making the environment relocatable (by way of writing relative, rather than
/// absolute paths), the entrypoints and scripts themselves will _not_ be relocatable. In other
/// words, copying those entrypoints and scripts to a location outside the environment will not
/// work, as they reference paths relative to the environment itself.
#[ arg(long) ]
pub relocatable : bool ,
2024-06-13 17:56:38 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub index_args : IndexArgs ,
2024-04-12 09:37:51 -04:00
/// The strategy to use when resolving against multiple index URLs.
///
2024-07-16 16:50:04 -04:00
/// By default, uv will stop at the first index on which a given package is available, and
2024-12-19 12:40:14 -05:00
/// limit resolutions to those present on that first index (`first-index`). This prevents
2024-10-15 15:24:23 -07:00
/// "dependency confusion" attacks, whereby an attacker can upload a malicious package under the
/// same name to an alternate index.
2024-10-14 21:48:13 +00:00
#[ arg(long, value_enum, env = EnvVars::UV_INDEX_STRATEGY) ]
2024-06-24 13:16:22 +03:00
pub index_strategy : Option < IndexStrategy > ,
2024-04-12 09:37:51 -04:00
2024-04-17 13:03:29 -04:00
/// Attempt to use `keyring` for authentication for index URLs.
2024-04-12 09:37:51 -04:00
///
2024-07-16 16:50:04 -04:00
/// At present, only `--keyring-provider subprocess` is supported, which configures uv to
2024-06-12 17:18:22 -07:00
/// use the `keyring` CLI to handle authentication.
2024-04-17 13:03:29 -04:00
///
/// Defaults to `disabled`.
2024-10-14 21:48:13 +00:00
#[ arg(long, value_enum, env = EnvVars::UV_KEYRING_PROVIDER) ]
2024-06-24 13:16:22 +03:00
pub keyring_provider : Option < KeyringProviderType > ,
2024-04-12 09:37:51 -04:00
/// Limit candidate packages to those that were uploaded prior to the given date.
///
2024-08-19 10:36:00 -07:00
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
/// format (e.g., `2006-12-02`) in your system's configured time zone.
2024-10-14 21:48:13 +00:00
#[ arg(long, env = EnvVars::UV_EXCLUDE_NEWER) ]
2024-06-24 13:16:22 +03:00
pub exclude_newer : Option < ExcludeNewer > ,
2024-04-12 09:37:51 -04:00
2024-06-13 17:56:38 -07:00
/// The method to use when installing packages from the global cache.
///
/// This option is only used for installing seed packages.
///
/// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
/// Windows.
2024-10-14 21:48:13 +00:00
#[ arg(long, value_enum, env = EnvVars::UV_LINK_MODE) ]
2024-10-01 20:45:39 -04:00
pub link_mode : Option < uv_install_wheel ::linker ::LinkMode > ,
2024-06-13 17:56:38 -07:00
2024-04-12 09:37:51 -04:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub compat_args : compat ::VenvCompatArgs ,
2024-04-12 09:37:51 -04:00
}
2024-06-19 10:55:21 -04:00
#[ derive(Parser, Debug, Clone) ]
2024-06-24 13:16:22 +03:00
pub enum ExternalCommand {
2024-06-19 10:55:21 -04:00
#[ command(external_subcommand) ]
Cmd ( Vec < OsString > ) ,
}
impl Deref for ExternalCommand {
type Target = Vec < OsString > ;
fn deref ( & self ) -> & Self ::Target {
match self {
Self ::Cmd ( cmd ) = > cmd ,
}
}
}
2024-10-10 14:10:17 -04:00
impl DerefMut for ExternalCommand {
fn deref_mut ( & mut self ) -> & mut Self ::Target {
match self {
Self ::Cmd ( cmd ) = > cmd ,
}
}
}
2024-06-19 10:55:21 -04:00
impl ExternalCommand {
2024-06-24 13:16:22 +03:00
pub fn split ( & self ) -> ( Option < & OsString > , & [ OsString ] ) {
2024-06-19 10:55:21 -04:00
match self . as_slice ( ) {
[ ] = > ( None , & [ ] ) ,
[ cmd , args @ .. ] = > ( Some ( cmd ) , args ) ,
}
}
}
2024-10-09 03:06:37 +08:00
#[ derive(Debug, Default, Copy, Clone, clap::ValueEnum) ]
pub enum AuthorFrom {
/// Fetch the author information from some sources (e.g., Git) automatically.
#[ default ]
Auto ,
/// Fetch the author information from Git configuration only.
Git ,
/// Do not infer the author information.
None ,
}
2024-07-19 11:11:48 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct InitArgs {
2024-09-25 15:48:01 -07:00
/// The path to use for the project/script.
2024-08-07 11:26:00 -05:00
///
2024-09-25 15:48:01 -07:00
/// Defaults to the current working directory when initializing an app or library;
/// required when initializing a script. Accepts relative and absolute paths.
2024-08-07 11:26:00 -05:00
///
/// If a `pyproject.toml` is found in any of the parent directories of the
/// target path, the project will be added as a workspace member of the
/// parent, unless `--no-workspace` is provided.
2024-09-25 15:48:01 -07:00
#[ arg(required_if_eq( " script " , " true " )) ]
pub path : Option < PathBuf > ,
2024-07-19 11:11:48 -04:00
2024-08-07 11:26:00 -05:00
/// The name of the project.
///
/// Defaults to the name of the directory.
2024-09-25 15:48:01 -07:00
#[ arg(long, conflicts_with = " script " ) ]
2024-07-19 11:11:48 -04:00
pub name : Option < PackageName > ,
2024-08-27 13:42:46 -04:00
/// Create a virtual project, rather than a package.
2024-08-07 11:26:00 -05:00
///
2024-08-27 13:08:09 -05:00
/// This option is deprecated and will be removed in a future release.
#[ arg(long, hide = true, conflicts_with = " package " ) ]
2024-07-25 02:52:33 +08:00
pub r#virtual : bool ,
2024-08-27 13:08:09 -05:00
/// Set up the project to be built as a Python package.
///
/// Defines a `[build-system]` for the project.
///
2024-10-26 22:51:16 +08:00
/// This is the default behavior when using `--lib` or `--build-backend`.
2024-08-27 13:08:09 -05:00
///
/// When using `--app`, this will include a `[project.scripts]` entrypoint and use a `src/`
/// project structure.
#[ arg(long, overrides_with = " no_package " ) ]
pub r#package : bool ,
/// Do not set up the project to be built as a Python package.
///
/// Does not include a `[build-system]` for the project.
///
/// This is the default behavior when using `--app`.
2024-10-26 22:51:16 +08:00
#[ arg(long, overrides_with = " package " , conflicts_with_all = [ " lib " , " build_backend " ] ) ]
2024-08-27 13:08:09 -05:00
pub r#no_package : bool ,
/// Create a project for an application.
///
/// This is the default behavior if `--lib` is not requested.
///
/// This project kind is for web servers, scripts, and command-line interfaces.
///
/// By default, an application is not intended to be built and distributed as a Python package.
/// The `--package` option can be used to create an application that is distributable, e.g., if
/// you want to distribute a command-line interface via PyPI.
2024-09-25 15:48:01 -07:00
#[ arg(long, alias = " application " , conflicts_with_all = [ " lib " , " script " ] ) ]
2024-08-27 13:08:09 -05:00
pub r#app : bool ,
/// Create a project for a library.
///
/// A library is a project that is intended to be built and distributed as a Python package.
2024-09-25 15:48:01 -07:00
#[ arg(long, alias = " library " , conflicts_with_all= [ " app " , " script " ] ) ]
2024-08-27 13:08:09 -05:00
pub r#lib : bool ,
2024-09-25 15:48:01 -07:00
/// Create a script.
///
/// A script is a standalone file with embedded metadata enumerating its dependencies, along
/// with any Python version requirements, as defined in the PEP 723 specification.
///
/// PEP 723 scripts can be executed directly with `uv run`.
///
/// By default, adds a requirement on the system Python version; use `--python` to specify an
/// alternative Python version requirement.
2024-12-27 19:06:51 -05:00
#[ arg(long, conflicts_with_all= [ " app " , " lib " , " package " , " build_backend " , " description " ] ) ]
2024-09-25 15:48:01 -07:00
pub r#script : bool ,
2024-12-27 19:06:51 -05:00
/// Set the project description.
#[ arg(long, conflicts_with = " script " ) ]
pub description : Option < String > ,
2024-09-26 10:40:39 +08:00
/// Initialize a version control system for the project.
///
/// By default, uv will initialize a Git repository (`git`). Use `--vcs none` to explicitly
/// avoid initializing a version control system.
#[ arg(long, value_enum, conflicts_with = " script " ) ]
pub vcs : Option < VersionControlSystem > ,
2024-10-16 12:19:59 +00:00
/// Initialize a build-backend of choice for the project.
2024-10-26 22:51:16 +08:00
///
/// Implicitly sets `--package`.
2024-10-16 12:19:59 +00:00
#[ arg(long, value_enum, conflicts_with_all= [ " script " , " no_package " ] ) ]
pub build_backend : Option < ProjectBuildBackend > ,
2024-07-25 02:52:33 +08:00
/// Do not create a `README.md` file.
2024-07-19 11:11:48 -04:00
#[ arg(long) ]
pub no_readme : bool ,
2024-07-23 12:02:40 -04:00
2024-10-09 03:06:37 +08:00
/// Fill in the `authors` field in the `pyproject.toml`.
///
/// By default, uv will attempt to infer the author information from some sources (e.g., Git) (`auto`).
/// Use `--author-from git` to only infer from Git configuration.
/// Use `--author-from none` to avoid inferring the author information.
#[ arg(long, value_enum) ]
pub author_from : Option < AuthorFrom > ,
2024-09-03 19:43:50 -04:00
/// Do not create a `.python-version` file for the project.
///
/// By default, uv will create a `.python-version` file containing the minor version of
/// the discovered Python interpreter, which will cause subsequent uv commands to use that
/// version.
#[ arg(long) ]
pub no_pin_python : bool ,
2024-08-29 17:40:19 -05:00
/// Avoid discovering a workspace and create a standalone project.
2024-08-07 11:26:00 -05:00
///
/// By default, uv searches for workspaces in the current directory or any
/// parent directory.
2024-08-29 17:40:19 -05:00
#[ arg(long, alias = " no-project " ) ]
2024-07-30 13:40:35 -04:00
pub no_workspace : bool ,
2024-07-23 12:02:40 -04:00
/// The Python interpreter to use to determine the minimum supported Python version.
///
2024-08-07 11:26:00 -05:00
/// See `uv help python` to view supported request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-07-19 11:11:48 -04:00
}
2024-04-17 11:20:43 -05:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct RunArgs {
2024-10-22 10:18:16 -04:00
/// Include optional dependencies from the specified extra name.
2024-07-16 17:14:27 -04:00
///
2024-08-07 08:26:24 -05:00
/// May be provided more than once.
///
/// Optional dependencies are defined via `project.optional-dependencies` in
/// a `pyproject.toml`.
///
/// This option is only available when running in a project.
2024-05-29 15:25:58 -04:00
#[ arg(long, conflicts_with = " all_extras " , value_parser = extra_name_with_clap_error) ]
2024-06-24 13:16:22 +03:00
pub extra : Option < Vec < ExtraName > > ,
2024-05-29 15:25:58 -04:00
/// Include all optional dependencies.
2024-07-16 17:14:27 -04:00
///
2024-08-07 08:26:24 -05:00
/// Optional dependencies are defined via `project.optional-dependencies` in
/// a `pyproject.toml`.
///
/// This option is only available when running in a project.
2024-05-29 15:25:58 -04:00
#[ arg(long, conflicts_with = " extra " ) ]
2024-06-24 13:16:22 +03:00
pub all_extras : bool ,
2024-05-29 15:25:58 -04:00
2024-11-24 10:25:09 +08:00
/// Exclude the specified optional dependencies, if `--all-extras` is supplied.
///
/// May be provided multiple times.
#[ arg(long) ]
pub no_extra : Vec < ExtraName > ,
2024-05-29 15:25:58 -04:00
#[ arg(long, overrides_with( " all_extras " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_all_extras : bool ,
2024-05-29 15:25:58 -04:00
2024-10-25 13:15:32 -05:00
/// Include the development dependency group.
2024-08-07 08:26:24 -05:00
///
2024-10-25 13:15:32 -05:00
/// Development dependencies are defined via `dependency-groups.dev` or
/// `tool.uv.dev-dependencies` in a `pyproject.toml`.
///
/// This option is an alias for `--group dev`.
2024-08-07 08:26:24 -05:00
///
/// This option is only available when running in a project.
2024-06-06 20:06:05 -04:00
#[ arg(long, overrides_with( " no_dev " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub dev : bool ,
2024-06-05 21:40:17 -04:00
2024-10-25 13:15:32 -05:00
/// Omit the development dependency group.
///
/// This option is an alias of `--no-group dev`.
2024-08-07 08:26:24 -05:00
///
/// This option is only available when running in a project.
2024-06-06 20:06:05 -04:00
#[ arg(long, overrides_with( " dev " )) ]
2024-06-24 13:16:22 +03:00
pub no_dev : bool ,
2024-06-05 21:40:17 -04:00
2024-10-25 13:15:32 -05:00
/// Include dependencies from the specified dependency group.
2024-10-18 12:06:25 -05:00
///
/// May be provided multiple times.
#[ arg(long, conflicts_with( " only_group " )) ]
pub group : Vec < GroupName > ,
2024-10-25 13:15:32 -05:00
/// Exclude dependencies from the specified dependency group.
2024-10-22 16:18:29 -04:00
///
/// May be provided multiple times.
#[ arg(long) ]
pub no_group : Vec < GroupName > ,
2024-10-25 13:15:32 -05:00
/// Only include dependencies from the specified dependency group.
2024-10-18 12:06:25 -05:00
///
/// May be provided multiple times.
///
/// The project itself will also be omitted.
#[ arg(long, conflicts_with( " group " )) ]
pub only_group : Vec < GroupName > ,
2024-11-21 00:07:36 +08:00
/// Include dependencies from all dependency groups.
///
/// `--no-group` can be used to exclude specific groups.
#[ arg(long, conflicts_with_all = [ " group " , " only_group " ] ) ]
pub all_groups : bool ,
2024-09-28 23:07:21 +08:00
/// Run a Python module.
///
/// Equivalent to `python -m <module>`.
2024-12-10 12:35:17 -08:00
#[ arg(short, long, conflicts_with_all = [ " script " , " gui_script " ] ) ]
2024-09-28 23:07:21 +08:00
pub module : bool ,
2024-10-25 13:15:32 -05:00
/// Only include the development dependency group.
2024-09-16 16:06:20 -04:00
///
2024-10-25 13:15:32 -05:00
/// Omit other dependencies. The project itself will also be omitted.
///
/// This option is an alias for `--only-group dev`.
2024-09-16 16:06:20 -04:00
#[ arg(long, conflicts_with( " no_dev " )) ]
pub only_dev : bool ,
2024-09-17 10:50:36 -04:00
/// Install any editable dependencies, including the project and any workspace members, as
/// non-editable.
#[ arg(long) ]
pub no_editable : bool ,
2024-12-27 11:43:30 -05:00
/// Do not remove extraneous packages present in the environment.
#[ arg(long, overrides_with( " exact " ), alias = " no-exact " , hide = true) ]
pub inexact : bool ,
/// Perform an exact sync, removing extraneous packages.
///
/// When enabled, uv will remove any extraneous packages from the environment.
/// By default, `uv run` will make the minimum necessary changes to satisfy the requirements.
#[ arg(long, overrides_with( " inexact " )) ]
pub exact : bool ,
2024-11-04 14:26:05 -05:00
/// Load environment variables from a `.env` file.
///
/// Can be provided multiple times, with subsequent files overriding values defined in
/// previous files.
#[ arg(long, env = EnvVars::UV_ENV_FILE) ]
pub env_file : Vec < PathBuf > ,
/// Avoid reading environment variables from a `.env` file.
#[ arg(long, value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_NO_ENV_FILE) ]
pub no_env_file : bool ,
2024-04-17 11:32:04 -05:00
/// The command to run.
2024-08-07 08:26:24 -05:00
///
/// If the path to a Python script (i.e., ending in `.py`), it will be
/// executed with the Python interpreter.
2024-06-19 10:55:21 -04:00
#[ command(subcommand) ]
2024-10-08 21:34:50 +02:00
pub command : Option < ExternalCommand > ,
2024-04-17 11:32:04 -05:00
2024-04-19 09:23:26 -05:00
/// Run with the given packages installed.
2024-08-07 08:26:24 -05:00
///
/// When used in a project, these dependencies will be layered on top of
/// the project environment in a separate, ephemeral environment. These
/// dependencies are allowed to conflict with those specified by the project.
2024-11-08 15:13:30 -05:00
#[ arg(long) ]
pub with : Vec < comma ::CommaSeparatedRequirements > ,
2024-04-19 09:52:04 -05:00
2024-09-28 23:07:21 +08:00
/// Run with the given packages installed as editables.
2024-08-20 14:04:46 -05:00
///
/// When used in a project, these dependencies will be layered on top of
/// the project environment in a separate, ephemeral environment. These
/// dependencies are allowed to conflict with those specified by the project.
2024-11-08 15:13:30 -05:00
#[ arg(long) ]
pub with_editable : Vec < comma ::CommaSeparatedRequirements > ,
2024-08-20 14:04:46 -05:00
2024-07-23 12:51:09 -04:00
/// Run with all packages listed in the given `requirements.txt` files.
///
2024-08-07 08:26:24 -05:00
/// The same environment semantics as `--with` apply.
///
2024-07-23 12:51:09 -04:00
/// Using `pyproject.toml`, `setup.py`, or `setup.cfg` files is not allowed.
2024-10-11 02:19:57 -07:00
#[ arg(long, value_delimiter = ',', value_parser = parse_maybe_file_path) ]
2024-07-23 12:51:09 -04:00
pub with_requirements : Vec < Maybe < PathBuf > > ,
2024-08-15 10:09:02 -04:00
/// Run the command in an isolated virtual environment.
2024-08-07 08:26:24 -05:00
///
/// Usually, the project environment is reused for performance. This option
/// forces a fresh environment to be used for the project, enforcing strict
/// isolation between dependencies and declaration of requirements.
///
/// An editable installation is still used for the project.
///
/// When used with `--with` or `--with-requirements`, the additional
/// dependencies will still be layered in a second environment.
2024-07-30 15:27:47 -04:00
#[ arg(long) ]
pub isolated : bool ,
2024-09-10 17:29:43 -04:00
/// Avoid syncing the virtual environment.
///
/// Implies `--frozen`, as the project dependencies will be ignored (i.e., the lockfile will not
/// be updated, since the environment will not be synced regardless).
2024-11-24 20:18:27 -05:00
#[ arg(long, env = EnvVars::UV_NO_SYNC, value_parser = clap::builder::BoolishValueParser::new()) ]
2024-09-10 17:29:43 -04:00
pub no_sync : bool ,
2024-07-19 09:18:32 -04:00
/// Assert that the `uv.lock` will remain unchanged.
2024-08-07 08:26:24 -05:00
///
2024-08-08 13:21:46 -05:00
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " frozen " ) ]
2024-07-19 09:18:32 -04:00
pub locked : bool ,
2024-08-07 08:26:24 -05:00
/// Run without updating the `uv.lock` file.
///
/// Instead of checking if the lockfile is up-to-date, uses the versions in
/// the lockfile as the source of truth. If the lockfile is missing, uv will
2024-08-09 14:46:32 -05:00
/// exit with an error. If the `pyproject.toml` includes changes to
/// dependencies that have not been included in the lockfile yet, they will
/// not be present in the environment.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " locked " ) ]
2024-07-19 09:18:32 -04:00
pub frozen : bool ,
2024-10-02 07:51:12 -07:00
/// Run the given path as a Python script.
///
/// Using `--script` will attempt to parse the path as a PEP 723 script,
/// irrespective of its extension.
2024-12-10 12:35:17 -08:00
#[ arg(long, short, conflicts_with_all = [ " module " , " gui_script " ] ) ]
2024-10-02 07:51:12 -07:00
pub script : bool ,
2024-12-10 12:35:17 -08:00
/// Run the given path as a Python GUI script.
///
/// Using `--gui-script` will attempt to parse the path as a PEP 723 script and run it with pythonw.exe,
/// irrespective of its extension. Only available on Windows.
#[ arg(long, conflicts_with_all = [ " script " , " module " ] ) ]
pub gui_script : bool ,
2024-06-03 10:27:35 -04:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub installer : ResolverInstallerArgs ,
2024-06-03 10:17:41 -04:00
2024-06-13 21:05:00 -07:00
#[ command(flatten) ]
2024-09-04 11:23:46 -04:00
pub build : BuildOptionsArgs ,
2024-06-13 21:05:00 -07:00
2024-06-13 18:43:18 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub refresh : RefreshArgs ,
2024-06-13 18:43:18 -07:00
2024-11-01 22:16:06 -04:00
/// Run the command with all workspace members installed.
///
/// The workspace's environment (`.venv`) is updated to include all workspace
/// members.
///
/// Any extras or groups specified via `--extra`, `--group`, or related options
/// will be applied to all workspace members.
#[ arg(long, conflicts_with = " package " ) ]
pub all_packages : bool ,
2024-06-26 13:46:07 -04:00
/// Run the command in a specific package in the workspace.
2024-08-07 08:26:24 -05:00
///
2024-08-29 13:46:42 -04:00
/// If the workspace member does not exist, uv will exit with an error.
2024-11-01 22:16:06 -04:00
#[ arg(long, conflicts_with = " all_packages " ) ]
2024-06-26 13:46:07 -04:00
pub package : Option < PackageName > ,
2024-08-07 08:26:24 -05:00
/// Avoid discovering the project or workspace.
///
/// Instead of searching for projects in the current directory and parent
/// directories, run in an isolated, ephemeral environment populated by the
/// `--with` requirements.
///
/// If a virtual environment is active or found in a current or parent
/// directory, it will be used as if there was no project or workspace.
2024-07-30 13:40:35 -04:00
#[ arg(long, alias = " no_workspace " , conflicts_with = " package " ) ]
pub no_project : bool ,
2024-08-07 11:26:00 -05:00
/// The Python interpreter to use for the run environment.
2024-05-08 10:51:51 -04:00
///
2024-08-07 11:26:00 -05:00
/// If the interpreter request is satisfied by a discovered environment, the
/// environment will be used.
2024-08-07 08:26:24 -05:00
///
2024-08-07 11:26:00 -05:00
/// See `uv help python` to view supported request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-07-30 14:11:52 -04:00
/// Whether to show resolver and installer output from any environment modifications.
///
/// By default, environment modifications are omitted, but enabled under `--verbose`.
2024-10-14 21:48:13 +00:00
#[ arg(long, env = EnvVars::UV_SHOW_RESOLUTION, value_parser = clap::builder::BoolishValueParser::new(), hide = true) ]
2024-07-30 14:11:52 -04:00
pub show_resolution : bool ,
2024-05-08 10:51:51 -04:00
}
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct SyncArgs {
2024-10-22 10:18:16 -04:00
/// Include optional dependencies from the specified extra name.
2024-07-16 17:14:27 -04:00
///
2024-08-09 14:46:32 -05:00
/// May be provided more than once.
2024-09-04 10:05:21 -05:00
///
2024-11-14 07:47:25 -05:00
/// When multiple extras or groups are specified that appear in
/// `tool.uv.conflicts`, uv will report an error.
///
2024-09-04 10:05:21 -05:00
/// Note that all optional dependencies are always included in the resolution; this option only
/// affects the selection of packages to install.
2024-05-29 15:25:58 -04:00
#[ arg(long, conflicts_with = " all_extras " , value_parser = extra_name_with_clap_error) ]
2024-06-24 13:16:22 +03:00
pub extra : Option < Vec < ExtraName > > ,
2024-05-29 15:25:58 -04:00
/// Include all optional dependencies.
2024-09-04 10:05:21 -05:00
///
2024-11-14 07:47:25 -05:00
/// When two or more extras are declared as conflicting in
/// `tool.uv.conflicts`, using this flag will always result in an error.
///
2024-09-04 10:05:21 -05:00
/// Note that all optional dependencies are always included in the resolution; this option only
/// affects the selection of packages to install.
2024-05-29 15:25:58 -04:00
#[ arg(long, conflicts_with = " extra " ) ]
2024-06-24 13:16:22 +03:00
pub all_extras : bool ,
2024-05-29 15:25:58 -04:00
2024-11-24 10:25:09 +08:00
/// Exclude the specified optional dependencies, if `--all-extras` is supplied.
///
/// May be provided multiple times.
#[ arg(long) ]
pub no_extra : Vec < ExtraName > ,
2024-05-29 15:25:58 -04:00
#[ arg(long, overrides_with( " all_extras " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub no_all_extras : bool ,
2024-05-29 15:25:58 -04:00
2024-10-25 13:15:32 -05:00
/// Include the development dependency group.
///
/// This option is an alias for `--group dev`.
2024-06-06 20:06:05 -04:00
#[ arg(long, overrides_with( " no_dev " ), hide = true) ]
2024-06-24 13:16:22 +03:00
pub dev : bool ,
2024-06-05 21:40:17 -04:00
2024-10-25 13:15:32 -05:00
/// Omit the development dependency group.
///
/// This option is an alias for `--no-group dev`.
2024-06-06 20:06:05 -04:00
#[ arg(long, overrides_with( " dev " )) ]
2024-06-24 13:16:22 +03:00
pub no_dev : bool ,
2024-06-05 21:40:17 -04:00
2024-10-25 13:15:32 -05:00
/// Only include the development dependency group.
2024-09-16 16:06:20 -04:00
///
2024-10-25 13:15:32 -05:00
/// Omit other dependencies. The project itself will also be omitted.
///
/// This option is an alias for `--only-group dev`.
2024-09-16 16:06:20 -04:00
#[ arg(long, conflicts_with( " no_dev " )) ]
pub only_dev : bool ,
2024-10-25 13:15:32 -05:00
/// Include dependencies from the specified dependency group.
2024-10-16 17:53:25 -05:00
///
2024-11-14 07:47:25 -05:00
/// When multiple extras or groups are specified that appear in
/// `tool.uv.conflicts`, uv will report an error.
///
2024-10-16 17:53:25 -05:00
/// May be provided multiple times.
#[ arg(long, conflicts_with( " only_group " )) ]
pub group : Vec < GroupName > ,
2024-10-25 13:15:32 -05:00
/// Exclude dependencies from the specified dependency group.
2024-10-22 16:18:29 -04:00
///
/// May be provided multiple times.
#[ arg(long) ]
pub no_group : Vec < GroupName > ,
2024-10-25 13:15:32 -05:00
/// Only include dependencies from the specified dependency group.
2024-10-16 17:53:25 -05:00
///
/// May be provided multiple times.
///
/// The project itself will also be omitted.
#[ arg(long, conflicts_with( " group " )) ]
pub only_group : Vec < GroupName > ,
2024-11-21 00:07:36 +08:00
/// Include dependencies from all dependency groups.
///
/// `--no-group` can be used to exclude specific groups.
#[ arg(long, conflicts_with_all = [ " group " , " only_group " ] ) ]
pub all_groups : bool ,
2024-09-17 10:50:36 -04:00
/// Install any editable dependencies, including the project and any workspace members, as
/// non-editable.
#[ arg(long) ]
pub no_editable : bool ,
2024-08-20 11:01:07 -05:00
/// Do not remove extraneous packages present in the environment.
2024-08-09 14:46:32 -05:00
///
2024-08-20 11:01:07 -05:00
/// When enabled, uv will make the minimum necessary changes to satisfy the requirements.
2024-08-26 14:04:58 -04:00
/// By default, syncing will remove any extraneous packages from the environment
2024-08-20 11:01:07 -05:00
#[ arg(long, overrides_with( " exact " ), alias = " no-exact " ) ]
pub inexact : bool ,
/// Perform an exact sync, removing extraneous packages.
#[ arg(long, overrides_with( " inexact " ), hide = true) ]
pub exact : bool ,
2024-06-17 16:24:22 -04:00
2024-08-23 15:19:47 -05:00
/// Do not install the current project.
///
/// By default, the current project is installed into the environment with all of its
/// dependencies. The `--no-install-project` option allows the project to be excluded, but all of
/// its dependencies are still installed. This is particularly useful in situations like
/// building Docker images where installing the project separately from its dependencies
/// allows optimal layer caching.
#[ arg(long) ]
pub no_install_project : bool ,
2024-08-23 15:39:33 -05:00
/// Do not install any workspace members, including the root project.
///
/// By default, all of the workspace members and their dependencies are installed into the
/// environment. The `--no-install-workspace` option allows exclusion of all the workspace
/// members while retaining their dependencies. This is particularly useful in situations like
/// building Docker images where installing the workspace separately from its dependencies
/// allows optimal layer caching.
#[ arg(long) ]
pub no_install_workspace : bool ,
2024-08-23 15:48:04 -05:00
/// Do not install the given package(s).
///
/// By default, all of the project's dependencies are installed into the environment. The
/// `--no-install-package` option allows exclusion of specific packages. Note this can result
/// in a broken environment, and should be used with caution.
#[ arg(long) ]
pub no_install_package : Vec < PackageName > ,
2024-07-19 09:18:32 -04:00
/// Assert that the `uv.lock` will remain unchanged.
2024-08-09 14:46:32 -05:00
///
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " frozen " ) ]
2024-07-19 09:18:32 -04:00
pub locked : bool ,
2024-08-09 14:46:32 -05:00
/// Sync without updating the `uv.lock` file.
///
/// Instead of checking if the lockfile is up-to-date, uses the versions in
/// the lockfile as the source of truth. If the lockfile is missing, uv will
/// exit with an error. If the `pyproject.toml` includes changes to dependencies
/// that have not been included in the lockfile yet, they will not be
/// present in the environment.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " locked " ) ]
2024-07-19 09:18:32 -04:00
pub frozen : bool ,
2024-06-03 10:27:35 -04:00
#[ command(flatten) ]
2024-07-09 15:18:30 -07:00
pub installer : ResolverInstallerArgs ,
2024-06-03 10:17:41 -04:00
2024-06-13 21:05:00 -07:00
#[ command(flatten) ]
2024-09-04 11:23:46 -04:00
pub build : BuildOptionsArgs ,
2024-06-13 21:05:00 -07:00
2024-06-13 18:43:18 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub refresh : RefreshArgs ,
2024-06-13 18:43:18 -07:00
2024-11-01 21:55:08 -04:00
/// Sync all packages in the workspace.
///
/// The workspace's environment (`.venv`) is updated to include all workspace
/// members.
///
/// Any extras or groups specified via `--extra`, `--group`, or related options
/// will be applied to all workspace members.
#[ arg(long, conflicts_with = " package " ) ]
pub all_packages : bool ,
2024-08-09 14:46:32 -05:00
/// Sync for a specific package in the workspace.
///
/// The workspace's environment (`.venv`) is updated to reflect the subset
/// of dependencies declared by the specified workspace member package.
///
2024-08-29 13:46:42 -04:00
/// If the workspace member does not exist, uv will exit with an error.
2024-11-01 21:55:08 -04:00
#[ arg(long, conflicts_with = " all_packages " ) ]
2024-07-31 11:16:48 -04:00
pub package : Option < PackageName > ,
2024-08-07 11:37:10 -05:00
/// The Python interpreter to use for the project environment.
2024-05-08 10:51:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// By default, the first interpreter that meets the project's
/// `requires-python` constraint is used.
///
/// If a Python interpreter in a virtual environment is provided, the
/// packages will not be synced to the given environment. The interpreter
/// will be used to create a virtual environment in the project.
///
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-05-08 10:51:51 -04:00
}
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct LockArgs {
2024-12-08 10:02:00 -06:00
/// Check if the lockfile is up-to-date.
2024-08-09 08:51:03 -05:00
///
2024-12-08 10:02:00 -06:00
/// Asserts that the `uv.lock` would remain unchanged after a resolution. If the lockfile is
/// missing or needs to be updated, uv will exit with an error.
///
/// Equivalent to `--locked`.
#[ arg(long, alias = " locked " , env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " check_exists " ) ]
pub check : bool ,
2024-07-18 14:55:17 -04:00
2024-12-08 10:02:00 -06:00
/// Assert that a `uv.lock` exists without checking if it is up-to-date.
///
/// Equivalent to `--frozen`.
#[ arg(long, alias = " frozen " , env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " check " ) ]
pub check_exists : bool ,
2024-07-18 14:55:17 -04:00
2024-10-23 20:21:55 -07:00
/// Perform a dry run, without writing the lockfile.
///
/// In dry-run mode, uv will resolve the project's dependencies and report on the resulting
/// changes, but will not write the lockfile to disk.
2024-12-08 10:02:00 -06:00
#[ arg(long, conflicts_with = " check_exists " , conflicts_with = " check " ) ]
2024-10-23 20:21:55 -07:00
pub dry_run : bool ,
2024-06-03 10:27:35 -04:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub resolver : ResolverArgs ,
2024-06-03 10:17:41 -04:00
2024-06-13 21:05:00 -07:00
#[ command(flatten) ]
2024-09-04 11:23:46 -04:00
pub build : BuildOptionsArgs ,
2024-06-13 21:05:00 -07:00
2024-06-13 18:43:18 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub refresh : RefreshArgs ,
2024-06-13 18:43:18 -07:00
2024-08-07 11:37:10 -05:00
/// The Python interpreter to use during resolution.
2024-05-08 10:51:51 -04:00
///
2024-08-07 11:37:10 -05:00
/// A Python interpreter is required for building source distributions to
/// determine package metadata when there are not wheels.
///
/// The interpreter is also used as the fallback value for the minimum
/// Python version if `requires-python` is not set.
///
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-04-17 11:20:43 -05:00
}
2024-04-12 09:37:51 -04:00
#[ derive(Args) ]
2024-08-16 23:57:45 +02:00
#[ command(group = clap::ArgGroup::new( " sources " ).required(true).multiple(true)) ]
2024-04-12 09:37:51 -04:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct AddArgs {
2024-07-16 16:39:22 -04:00
/// The packages to add, as PEP 508 requirements (e.g., `ruff==0.5.0`).
2024-08-16 23:57:45 +02:00
#[ arg(group = " sources " ) ]
pub packages : Vec < String > ,
/// Add all packages listed in the given `requirements.txt` files.
2024-11-20 10:31:23 -05:00
#[ arg(long, short, alias = " requirement " , group = " sources " , value_parser = parse_file_path) ]
2024-08-16 23:57:45 +02:00
pub requirements : Vec < PathBuf > ,
2024-06-11 09:21:28 -04:00
2024-10-25 13:15:32 -05:00
/// Add the requirements to the development dependency group.
///
/// This option is an alias for `--group dev`.
2024-10-16 16:38:11 -05:00
#[ arg(long, conflicts_with( " optional " ), conflicts_with( " group " )) ]
2024-06-24 13:16:22 +03:00
pub dev : bool ,
2024-06-14 15:17:29 -04:00
2024-10-22 10:18:16 -04:00
/// Add the requirements to the package's optional dependencies for the specified extra.
2024-08-08 10:52:38 -05:00
///
/// The group may then be activated when installing the project with the
/// `--extra` flag.
///
2024-10-22 10:18:16 -04:00
/// To enable an optional extra for this requirement instead, see `--extra`.
2024-10-16 16:38:11 -05:00
#[ arg(long, conflicts_with( " dev " ), conflicts_with( " group " )) ]
2024-06-27 21:24:21 -04:00
pub optional : Option < ExtraName > ,
2024-10-25 13:15:32 -05:00
/// Add the requirements to the specified dependency group.
2024-10-16 16:38:11 -05:00
///
/// These requirements will not be included in the published metadata for the project.
#[ arg(long, conflicts_with( " dev " ), conflicts_with( " optional " )) ]
pub group : Option < GroupName > ,
2024-08-25 11:01:39 -04:00
/// Add the requirements as editable.
#[ arg(long, overrides_with = " no_editable " ) ]
2024-07-20 21:11:34 +08:00
pub editable : bool ,
2024-08-25 11:01:39 -04:00
#[ arg(long, overrides_with = " editable " , hide = true) ]
2024-07-20 21:11:34 +08:00
pub no_editable : bool ,
2024-06-19 14:20:16 -04:00
2024-07-23 18:03:01 -04:00
/// Add source requirements to `project.dependencies`, rather than `tool.uv.sources`.
2024-06-19 14:20:16 -04:00
///
2024-07-23 18:03:01 -04:00
/// By default, uv will use the `tool.uv.sources` section to record source information for Git,
/// local, editable, and direct URL requirements.
#[ arg(
long,
conflicts_with = " editable " ,
conflicts_with = " no_editable " ,
conflicts_with = " rev " ,
conflicts_with = " tag " ,
conflicts_with = " branch "
) ]
2024-06-26 14:50:04 -04:00
pub raw_sources : bool ,
2024-06-19 14:20:16 -04:00
2024-08-08 10:52:38 -05:00
/// Commit to use when adding a dependency from Git.
2024-07-30 22:40:28 +08:00
#[ arg(long, group = " git-ref " , action = clap::ArgAction::Set) ]
2024-06-24 13:16:22 +03:00
pub rev : Option < String > ,
2024-06-19 14:20:16 -04:00
2024-08-08 10:52:38 -05:00
/// Tag to use when adding a dependency from Git.
2024-07-30 22:40:28 +08:00
#[ arg(long, group = " git-ref " , action = clap::ArgAction::Set) ]
2024-06-24 13:16:22 +03:00
pub tag : Option < String > ,
2024-06-19 14:20:16 -04:00
2024-08-08 10:52:38 -05:00
/// Branch to use when adding a dependency from Git.
2024-07-30 22:40:28 +08:00
#[ arg(long, group = " git-ref " , action = clap::ArgAction::Set) ]
2024-06-24 13:16:22 +03:00
pub branch : Option < String > ,
2024-06-19 14:20:16 -04:00
2024-08-08 10:52:38 -05:00
/// Extras to enable for the dependency.
///
/// May be provided more than once.
///
2024-10-22 10:18:16 -04:00
/// To add this dependency to an optional extra instead, see `--optional`.
2024-06-26 18:36:07 -04:00
#[ arg(long) ]
pub extra : Option < Vec < ExtraName > > ,
2024-09-10 17:29:43 -04:00
/// Avoid syncing the virtual environment.
2024-10-14 21:48:13 +00:00
#[ arg(long, env = EnvVars::UV_NO_SYNC, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " frozen " ) ]
2024-08-07 14:09:10 -04:00
pub no_sync : bool ,
2024-07-19 09:18:32 -04:00
/// Assert that the `uv.lock` will remain unchanged.
2024-08-08 10:52:38 -05:00
///
2024-08-08 13:21:46 -05:00
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " frozen " ) ]
2024-07-19 09:18:32 -04:00
pub locked : bool ,
2024-08-08 13:12:49 -05:00
/// Add dependencies without re-locking the project.
2024-08-08 10:52:38 -05:00
///
2024-08-08 13:12:49 -05:00
/// The project environment will not be synced.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " locked " ) ]
2024-07-19 09:18:32 -04:00
pub frozen : bool ,
2024-06-14 13:42:39 -04:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub installer : ResolverInstallerArgs ,
2024-06-14 13:42:39 -04:00
#[ command(flatten) ]
2024-09-04 11:23:46 -04:00
pub build : BuildOptionsArgs ,
2024-06-14 13:42:39 -04:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub refresh : RefreshArgs ,
2024-06-14 13:42:39 -04:00
2024-06-26 13:46:07 -04:00
/// Add the dependency to a specific package in the workspace.
#[ arg(long, conflicts_with = " isolated " ) ]
pub package : Option < PackageName > ,
2024-08-11 03:40:59 +02:00
/// Add the dependency to the specified Python script, rather than to a project.
///
/// If provided, uv will add the dependency to the script's inline metadata
2024-09-14 03:51:59 +12:00
/// table, in adherence with PEP 723. If no such inline metadata table is present,
2024-08-11 03:40:59 +02:00
/// a new one will be created and added to the script. When executed via `uv run`,
/// uv will create a temporary environment for the script with all inline
/// dependencies installed.
#[ arg(long, conflicts_with = " dev " , conflicts_with = " optional " ) ]
pub script : Option < PathBuf > ,
2024-08-07 11:37:10 -05:00
/// The Python interpreter to use for resolving and syncing.
2024-06-11 09:21:28 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-04-12 09:37:51 -04:00
}
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct RemoveArgs {
2024-08-08 13:12:49 -05:00
/// The names of the dependencies to remove (e.g., `ruff`).
2024-06-11 09:21:28 -04:00
#[ arg(required = true) ]
2025-01-07 08:47:05 -05:00
pub packages : Vec < Requirement < VerbatimParsedUrl > > ,
2024-06-11 09:21:28 -04:00
2024-10-25 13:15:32 -05:00
/// Remove the packages from the development dependency group.
///
/// This option is an alias for `--group dev`.
2024-10-16 16:38:11 -05:00
#[ arg(long, conflicts_with( " optional " ), conflicts_with( " group " )) ]
2024-06-24 13:16:22 +03:00
pub dev : bool ,
2024-06-14 15:17:29 -04:00
2024-10-22 10:18:16 -04:00
/// Remove the packages from the project's optional dependencies for the specified extra.
2024-10-16 16:38:11 -05:00
#[ arg(long, conflicts_with( " dev " ), conflicts_with( " group " )) ]
2024-06-27 21:24:21 -04:00
pub optional : Option < ExtraName > ,
2024-10-25 13:15:32 -05:00
/// Remove the packages from the specified dependency group.
2024-10-16 16:38:11 -05:00
#[ arg(long, conflicts_with( " dev " ), conflicts_with( " optional " )) ]
pub group : Option < GroupName > ,
2024-08-07 14:09:10 -04:00
/// Avoid syncing the virtual environment after re-locking the project.
2024-10-14 21:48:13 +00:00
#[ arg(long, env = EnvVars::UV_NO_SYNC, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " frozen " ) ]
2024-08-07 14:09:10 -04:00
pub no_sync : bool ,
2024-07-19 09:18:32 -04:00
/// Assert that the `uv.lock` will remain unchanged.
2024-08-08 13:12:49 -05:00
///
2024-08-08 13:21:46 -05:00
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " frozen " ) ]
2024-07-19 09:18:32 -04:00
pub locked : bool ,
2024-08-08 13:12:49 -05:00
/// Remove dependencies without re-locking the project.
///
/// The project environment will not be synced.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " locked " ) ]
2024-07-19 09:18:32 -04:00
pub frozen : bool ,
2024-07-09 10:46:31 -07:00
#[ command(flatten) ]
pub installer : ResolverInstallerArgs ,
#[ command(flatten) ]
2024-09-04 11:23:46 -04:00
pub build : BuildOptionsArgs ,
2024-07-09 10:46:31 -07:00
#[ command(flatten) ]
pub refresh : RefreshArgs ,
2024-08-08 13:12:49 -05:00
/// Remove the dependencies from a specific package in the workspace.
2024-06-26 13:46:07 -04:00
#[ arg(long, conflicts_with = " isolated " ) ]
pub package : Option < PackageName > ,
2024-08-11 03:40:59 +02:00
/// Remove the dependency from the specified Python script, rather than from a project.
///
/// If provided, uv will remove the dependency from the script's inline metadata
2024-09-14 03:51:59 +12:00
/// table, in adherence with PEP 723.
2024-08-11 03:40:59 +02:00
#[ arg(long) ]
pub script : Option < PathBuf > ,
2024-08-07 11:37:10 -05:00
/// The Python interpreter to use for resolving and syncing.
2024-06-11 09:21:28 -04:00
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-04-12 09:37:51 -04:00
}
2024-05-21 15:51:30 -04:00
2024-07-08 14:07:48 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct TreeArgs {
2024-08-08 13:21:46 -05:00
/// Show a platform-independent dependency tree.
///
/// Shows resolved package versions for all Python versions and platforms,
/// rather than filtering to those that are relevant for the current
/// environment.
///
/// Multiple versions may be shown for a each package.
2024-08-05 14:51:18 -04:00
#[ arg(long) ]
pub universal : bool ,
2024-07-08 14:07:48 -04:00
#[ command(flatten) ]
pub tree : DisplayTreeArgs ,
2024-10-25 13:15:32 -05:00
/// Include the development dependency group.
///
/// Development dependencies are defined via `dependency-groups.dev` or
/// `tool.uv.dev-dependencies` in a `pyproject.toml`.
2024-10-12 15:10:56 +02:00
///
2024-10-25 13:15:32 -05:00
/// This option is an alias for `--group dev`.
2024-10-12 15:10:56 +02:00
#[ arg(long, overrides_with( " no_dev " ), hide = true) ]
pub dev : bool ,
2024-10-25 13:15:32 -05:00
/// Only include the development dependency group.
2024-10-18 13:02:36 -05:00
///
2024-10-25 13:15:32 -05:00
/// Omit other dependencies. The project itself will also be omitted.
///
/// This option is an alias for `--only-group dev`.
2024-10-18 13:02:36 -05:00
#[ arg(long, conflicts_with( " no_dev " )) ]
pub only_dev : bool ,
2024-10-25 13:15:32 -05:00
/// Omit the development dependency group.
///
/// This option is an alias for `--no-group dev`.
2024-10-12 15:10:56 +02:00
#[ arg(long, overrides_with( " dev " ), conflicts_with = " invert " ) ]
pub no_dev : bool ,
2024-10-25 13:15:32 -05:00
/// Include dependencies from the specified dependency group.
2024-10-18 13:02:36 -05:00
///
/// May be provided multiple times.
#[ arg(long, conflicts_with( " only_group " )) ]
pub group : Vec < GroupName > ,
2024-10-25 13:15:32 -05:00
/// Exclude dependencies from the specified dependency group.
2024-10-22 16:18:29 -04:00
///
/// May be provided multiple times.
#[ arg(long) ]
pub no_group : Vec < GroupName > ,
2024-10-25 13:15:32 -05:00
/// Only include dependencies from the specified dependency group.
2024-10-18 13:02:36 -05:00
///
/// May be provided multiple times.
///
/// The project itself will also be omitted.
#[ arg(long, conflicts_with( " group " )) ]
pub only_group : Vec < GroupName > ,
2024-11-21 00:07:36 +08:00
/// Include dependencies from all dependency groups.
///
/// `--no-group` can be used to exclude specific groups.
#[ arg(long, conflicts_with_all = [ " group " , " only_group " ] ) ]
pub all_groups : bool ,
2024-07-19 09:18:32 -04:00
/// Assert that the `uv.lock` will remain unchanged.
2024-08-08 13:21:46 -05:00
///
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " frozen " ) ]
2024-07-19 09:18:32 -04:00
pub locked : bool ,
2024-08-08 13:21:46 -05:00
/// Display the requirements without locking the project.
///
/// If the lockfile is missing, uv will exit with an error.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " locked " ) ]
2024-07-19 09:18:32 -04:00
pub frozen : bool ,
2024-07-08 14:07:48 -04:00
#[ command(flatten) ]
2024-09-04 11:23:46 -04:00
pub build : BuildOptionsArgs ,
2024-07-08 14:07:48 -04:00
#[ command(flatten) ]
pub resolver : ResolverArgs ,
2024-08-07 11:59:27 -05:00
/// The Python version to use when filtering the tree.
///
/// For example, pass `--python-version 3.10` to display the dependencies
/// that would be included when installing on Python 3.10.
///
/// Defaults to the version of the discovered Python interpreter.
2024-08-05 15:02:35 -04:00
#[ arg(long, conflicts_with = " universal " ) ]
pub python_version : Option < PythonVersion > ,
2024-08-07 11:59:27 -05:00
/// The platform to use when filtering the tree.
2024-08-05 15:02:35 -04:00
///
2024-08-07 11:59:27 -05:00
/// For example, pass `--platform windows` to display the dependencies that
/// would be included when installing on Windows.
///
/// Represented as a "target triple", a string that describes the target
/// platform in terms of its CPU, vendor, and operating system name, like
2024-09-06 19:25:46 -04:00
/// `x86_64-unknown-linux-gnu` or `aarch64-apple-darwin`.
2024-08-05 15:02:35 -04:00
#[ arg(long, conflicts_with = " universal " ) ]
pub python_platform : Option < TargetTriple > ,
2024-08-07 11:59:27 -05:00
/// The Python interpreter to use for locking and filtering.
2024-07-08 14:07:48 -04:00
///
2024-08-07 11:59:27 -05:00
/// By default, the tree is filtered to match the platform as reported by
/// the Python interpreter. Use `--universal` to display the tree for all
/// platforms, or use `--python-version` or `--python-platform` to override
/// a subset of markers.
2024-08-07 11:37:10 -05:00
///
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-07-08 14:07:48 -04:00
}
2024-08-29 13:46:42 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct ExportArgs {
/// The format to which `uv.lock` should be exported.
///
/// At present, only `requirements-txt` is supported.
#[ arg(long, value_enum, default_value_t = ExportFormat::default()) ]
pub format : ExportFormat ,
2024-11-01 22:25:29 -04:00
/// Export the entire workspace.
///
/// The dependencies for all workspace members will be included in the
/// exported requirements file.
///
/// Any extras or groups specified via `--extra`, `--group`, or related options
/// will be applied to all workspace members.
#[ arg(long, conflicts_with = " package " ) ]
pub all_packages : bool ,
2024-08-29 13:46:42 -04:00
/// Export the dependencies for a specific package in the workspace.
///
/// If the workspace member does not exist, uv will exit with an error.
2024-11-01 22:25:29 -04:00
#[ arg(long, conflicts_with = " all_packages " ) ]
2024-08-29 13:46:42 -04:00
pub package : Option < PackageName > ,
2024-11-23 21:11:54 -05:00
/// Prune the given package from the dependency tree.
///
/// Pruned packages will be excluded from the exported requirements file, as will any
/// dependencies that are no longer required after the pruned package is removed.
#[ arg(long, conflicts_with = " all_packages " ) ]
pub prune : Vec < PackageName > ,
2024-10-22 10:18:16 -04:00
/// Include optional dependencies from the specified extra name.
2024-08-29 13:46:42 -04:00
///
/// May be provided more than once.
#[ arg(long, conflicts_with = " all_extras " , value_parser = extra_name_with_clap_error) ]
pub extra : Option < Vec < ExtraName > > ,
/// Include all optional dependencies.
#[ arg(long, conflicts_with = " extra " ) ]
pub all_extras : bool ,
2024-11-24 10:25:09 +08:00
/// Exclude the specified optional dependencies, if `--all-extras` is supplied.
///
/// May be provided multiple times.
#[ arg(long) ]
pub no_extra : Vec < ExtraName > ,
2024-08-29 13:46:42 -04:00
#[ arg(long, overrides_with( " all_extras " ), hide = true) ]
pub no_all_extras : bool ,
2024-10-25 13:15:32 -05:00
/// Include the development dependency group.
///
/// This option is an alias for `--group dev`.
2024-08-29 13:46:42 -04:00
#[ arg(long, overrides_with( " no_dev " ), hide = true) ]
pub dev : bool ,
2024-10-25 13:15:32 -05:00
/// Omit the development dependency group.
///
/// This option is an alias for `--no-group dev`.
2024-08-29 13:46:42 -04:00
#[ arg(long, overrides_with( " dev " )) ]
pub no_dev : bool ,
2024-10-25 13:15:32 -05:00
/// Only include the development dependency group.
2024-09-16 16:06:20 -04:00
///
2024-10-25 13:15:32 -05:00
/// Omit other dependencies. The project itself will also be omitted.
///
/// This option is an alias for `--only-group dev`.
2024-09-16 16:06:20 -04:00
#[ arg(long, conflicts_with( " no_dev " )) ]
pub only_dev : bool ,
2024-10-25 13:15:32 -05:00
/// Include dependencies from the specified dependency group.
2024-10-18 12:06:41 -05:00
///
/// May be provided multiple times.
#[ arg(long, conflicts_with( " only_group " )) ]
pub group : Vec < GroupName > ,
2024-10-25 13:15:32 -05:00
/// Exclude dependencies from the specified dependency group.
2024-10-22 16:18:29 -04:00
///
/// May be provided multiple times.
#[ arg(long) ]
pub no_group : Vec < GroupName > ,
2024-10-25 13:15:32 -05:00
/// Only include dependencies from the specified dependency group.
2024-10-18 12:06:41 -05:00
///
/// May be provided multiple times.
///
/// The project itself will also be omitted.
#[ arg(long, conflicts_with( " group " )) ]
pub only_group : Vec < GroupName > ,
2024-11-21 00:07:36 +08:00
/// Include dependencies from all dependency groups.
///
/// `--no-group` can be used to exclude specific groups.
#[ arg(long, conflicts_with_all = [ " group " , " only_group " ] ) ]
pub all_groups : bool ,
2024-10-10 17:17:44 +02:00
/// Exclude the comment header at the top of the generated output file.
#[ arg(long, overrides_with( " header " )) ]
pub no_header : bool ,
#[ arg(long, overrides_with( " no_header " ), hide = true) ]
pub header : bool ,
2024-09-17 10:50:36 -04:00
/// Install any editable dependencies, including the project and any workspace members, as
/// non-editable.
#[ arg(long) ]
pub no_editable : bool ,
2024-09-02 22:12:29 -04:00
/// Include hashes for all dependencies.
#[ arg(long, overrides_with( " no_hashes " ), hide = true) ]
pub hashes : bool ,
/// Omit hashes in the generated output.
#[ arg(long, overrides_with( " hashes " )) ]
pub no_hashes : bool ,
2024-09-05 20:18:39 -05:00
/// Write the exported requirements to the given file.
2024-09-05 20:53:53 -04:00
#[ arg(long, short) ]
pub output_file : Option < PathBuf > ,
2024-09-05 21:01:46 -04:00
/// Do not emit the current project.
///
/// By default, the current project is included in the exported requirements file with all of its
/// dependencies. The `--no-emit-project` option allows the project to be excluded, but all of
/// its dependencies to remain included.
#[ arg(long, alias = " no-install-project " ) ]
pub no_emit_project : bool ,
/// Do not emit any workspace members, including the root project.
///
/// By default, all workspace members and their dependencies are included in the exported
/// requirements file, with all of their dependencies. The `--no-emit-workspace` option allows
/// exclusion of all the workspace members while retaining their dependencies.
#[ arg(long, alias = " no-install-workspace " ) ]
pub no_emit_workspace : bool ,
/// Do not emit the given package(s).
///
/// By default, all of the project's dependencies are included in the exported requirements
/// file. The `--no-install-package` option allows exclusion of specific packages.
#[ arg(long, alias = " no-install-package " ) ]
pub no_emit_package : Vec < PackageName > ,
2024-08-29 13:46:42 -04:00
/// 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.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " frozen " ) ]
2024-08-29 13:46:42 -04:00
pub locked : bool ,
/// Do not update the `uv.lock` before exporting.
///
/// If a `uv.lock` does not exist, uv will exit with an error.
2024-10-18 13:37:49 -04:00
#[ arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = " locked " ) ]
2024-08-29 13:46:42 -04:00
pub frozen : bool ,
#[ command(flatten) ]
pub resolver : ResolverArgs ,
#[ command(flatten) ]
2024-09-04 11:23:46 -04:00
pub build : BuildOptionsArgs ,
2024-08-29 13:46:42 -04:00
#[ command(flatten) ]
pub refresh : RefreshArgs ,
/// The Python interpreter to use during resolution.
///
/// A Python interpreter is required for building source distributions to
/// determine package metadata when there are not wheels.
///
/// The interpreter is also used as the fallback value for the minimum
/// Python version if `requires-python` is not set.
///
/// See `uv help python` for details on Python discovery and supported
/// request formats.
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-29 13:46:42 -04:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-29 13:46:42 -04:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-08-29 13:46:42 -04:00
}
2024-05-21 15:51:30 -04:00
#[ derive(Args) ]
2024-06-13 18:43:18 -07:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct ToolNamespace {
2024-05-21 15:51:30 -04:00
#[ command(subcommand) ]
2024-06-24 13:16:22 +03:00
pub command : ToolCommand ,
2024-05-21 15:51:30 -04:00
}
#[ derive(Subcommand) ]
2024-06-24 13:16:22 +03:00
pub enum ToolCommand {
2024-08-12 12:35:50 -05:00
/// Run a command provided by a Python package.
///
/// By default, the package to install is assumed to match the command name.
///
/// The name of the command can include an exact version in the format
2024-08-28 12:40:49 -04:00
/// `<package>@<version>`, e.g., `uv tool run ruff@0.3.0`. If more complex
2024-08-12 12:35:50 -05:00
/// version specification is desired or if the command is provided by a
/// different package, use `--from`.
///
/// If the tool was previously installed, i.e., via `uv tool install`, the
/// installed version will be used unless a version is requested or the
/// `--isolated` flag is used.
///
/// `uvx` is provided as a convenient alias for `uv tool run`, their
/// behavior is identical.
///
/// If no command is provided, the installed tools are displayed.
///
/// Packages are installed into an ephemeral virtual environment in the uv
/// cache directory.
2024-10-08 16:43:50 -05:00
#[ command(
after_help = " Use `uvx` as a shortcut for `uv tool run`. \n \n \
Use `uv help tool run` for more details. " ,
after_long_help = " "
) ]
2024-05-21 15:51:30 -04:00
Run ( ToolRunArgs ) ,
2024-08-12 12:35:50 -05:00
/// Hidden alias for `uv tool run` for the `uvx` command
2024-07-03 12:38:54 -04:00
#[ command(
hide = true,
2024-08-12 12:35:50 -05:00
override_usage = " uvx [OPTIONS] [COMMAND] " ,
about = " Run a command provided by a Python package. " ,
2024-08-09 13:24:38 -05:00
after_help = " Use `uv help tool run` for more details. " ,
after_long_help = " "
2024-07-03 12:38:54 -04:00
) ]
Uvx ( ToolRunArgs ) ,
2024-08-12 12:35:50 -05:00
/// Install commands provided by a Python package.
///
/// Packages are installed into an isolated virtual environment in the uv
/// tools directory. The executables are linked the tool executable
/// directory, which is determined according to the XDG standard and can be
/// retrieved with `uv tool dir --bin`.
///
/// If the tool was previously installed, the existing tool will generally
/// be replaced.
2024-06-26 11:24:29 -04:00
Install ( ToolInstallArgs ) ,
2024-08-12 12:35:50 -05:00
/// Upgrade installed tools.
///
/// If a tool was installed with version constraints, they will be respected
/// on upgrade — to upgrade a tool beyond the originally provided
/// constraints, use `uv tool install` again.
///
/// If a tool was installed with specific settings, they will be respected
/// on upgraded. For example, if `--prereleases allow` was provided during
/// installation, it will continue to be respected in upgrades.
2024-08-09 09:37:03 -04:00
#[ command(alias = " update " ) ]
2024-08-08 22:48:14 +02:00
Upgrade ( ToolUpgradeArgs ) ,
2024-06-28 18:00:18 -04:00
/// List installed tools.
List ( ToolListArgs ) ,
2024-06-29 13:50:20 -04:00
/// Uninstall a tool.
Uninstall ( ToolUninstallArgs ) ,
2024-08-12 12:35:50 -05:00
/// Ensure that the tool executable directory is on the `PATH`.
///
/// If the tool executable directory is not present on the `PATH`, uv will
/// attempt to add it to the relevant shell configuration files.
///
/// If the shell configuration files already include a blurb to add the
/// executable directory to the path, but the directory is not present on
/// the `PATH`, uv will exit with an error.
///
/// The tool executable directory is determined according to the XDG standard
/// and can be retrieved with `uv tool dir --bin`.
2024-07-12 18:09:34 -04:00
#[ command(alias = " ensurepath " ) ]
UpdateShell ,
2024-08-12 12:35:50 -05:00
/// Show the path to the uv tools directory.
///
2024-08-19 14:46:19 -05:00
/// The tools directory is used to store environments and metadata for installed tools.
2024-08-12 12:35:50 -05:00
///
2024-08-19 14:46:19 -05:00
/// By default, tools are stored in the uv data directory at `$XDG_DATA_HOME/uv/tools` or
2024-08-23 21:34:08 +03:30
/// `$HOME/.local/share/uv/tools` on Unix and `%APPDATA%\uv\data\tools` on
2024-08-19 14:46:19 -05:00
/// Windows.
///
/// The tool installation directory may be overridden with `$UV_TOOL_DIR`.
///
/// To instead view the directory uv installs executables into, use the `--bin` flag.
2024-07-17 16:30:45 -04:00
Dir ( ToolDirArgs ) ,
2024-05-21 15:51:30 -04:00
}
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct ToolRunArgs {
2024-05-21 15:51:30 -04:00
/// The command to run.
2024-06-27 06:50:15 -04:00
///
2024-08-12 12:35:50 -05:00
/// WARNING: The documentation for [`Self::command`] is not included in help output
2024-06-19 10:55:21 -04:00
#[ command(subcommand) ]
2024-07-30 06:12:31 +08:00
pub command : Option < ExternalCommand > ,
2024-05-21 15:51:30 -04:00
2024-05-22 15:48:54 -04:00
/// Use the given package to provide the command.
///
/// By default, the package name is assumed to match the command name.
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub from : Option < String > ,
2024-05-22 15:48:54 -04:00
2024-07-23 16:06:17 -04:00
/// Run with the given packages installed.
2024-11-08 15:13:30 -05:00
#[ arg(long) ]
pub with : Vec < comma ::CommaSeparatedRequirements > ,
2024-05-22 21:59:04 -04:00
2024-09-18 05:51:34 +09:00
/// Run with the given packages installed as editables
///
/// When used in a project, these dependencies will be layered on top of
/// the uv tool's environment in a separate, ephemeral environment. These
/// dependencies are allowed to conflict with those specified.
2024-11-08 15:13:30 -05:00
#[ arg(long) ]
pub with_editable : Vec < comma ::CommaSeparatedRequirements > ,
2024-09-18 05:51:34 +09:00
2024-07-23 16:06:17 -04:00
/// Run with all packages listed in the given `requirements.txt` files.
2024-10-11 02:19:57 -07:00
#[ arg(long, value_delimiter = ',', value_parser = parse_maybe_file_path) ]
2024-07-23 16:06:17 -04:00
pub with_requirements : Vec < Maybe < PathBuf > > ,
2024-07-30 15:09:53 -04:00
/// Run the tool in an isolated virtual environment, ignoring any already-installed tools.
#[ arg(long) ]
pub isolated : bool ,
2024-06-03 10:27:35 -04:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub installer : ResolverInstallerArgs ,
2024-06-03 10:27:35 -04:00
2024-06-13 21:05:00 -07:00
#[ command(flatten) ]
2024-09-04 11:23:46 -04:00
pub build : BuildOptionsArgs ,
2024-06-13 21:05:00 -07:00
2024-06-13 18:43:18 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub refresh : RefreshArgs ,
2024-06-13 18:43:18 -07:00
2024-06-03 10:27:35 -04:00
/// The Python interpreter to use to build the run environment.
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-07-30 14:11:52 -04:00
/// Whether to show resolver and installer output from any environment modifications.
///
/// By default, environment modifications are omitted, but enabled under `--verbose`.
2024-10-14 21:48:13 +00:00
#[ arg(long, env = EnvVars::UV_SHOW_RESOLUTION, value_parser = clap::builder::BoolishValueParser::new(), hide = true) ]
2024-07-30 14:11:52 -04:00
pub show_resolution : bool ,
2024-09-20 03:27:25 +02:00
#[ arg(long, hide = true) ]
pub generate_shell_completion : Option < clap_complete_command ::Shell > ,
2024-06-03 10:27:35 -04:00
}
2024-06-26 11:24:29 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct ToolInstallArgs {
2024-06-27 08:35:00 -04:00
/// The package to install commands from.
pub package : String ,
2024-06-26 11:24:29 -04:00
2024-07-26 22:30:15 +02:00
#[ arg(short, long) ]
pub editable : bool ,
2024-06-27 08:35:00 -04:00
/// The package to install commands from.
2024-06-26 11:24:29 -04:00
///
2024-06-27 08:35:00 -04:00
/// This option is provided for parity with `uv tool run`, but is redundant with `package`.
#[ arg(long, hide = true) ]
2024-06-26 11:24:29 -04:00
pub from : Option < String > ,
/// Include the following extra requirements.
2024-11-08 15:13:30 -05:00
#[ arg(long) ]
pub with : Vec < comma ::CommaSeparatedRequirements > ,
/// Include the given packages as editables.
#[ arg(long) ]
pub with_editable : Vec < comma ::CommaSeparatedRequirements > ,
2024-06-26 11:24:29 -04:00
2024-07-23 16:06:17 -04:00
/// Run all requirements listed in the given `requirements.txt` files.
2024-10-11 02:19:57 -07:00
#[ arg(long, value_delimiter = ',', value_parser = parse_maybe_file_path) ]
2024-07-23 16:06:17 -04:00
pub with_requirements : Vec < Maybe < PathBuf > > ,
2024-12-02 20:14:41 -05:00
/// Constrain versions using the given requirements files.
///
/// Constraints files are `requirements.txt`-like files that only control the _version_ of a
/// requirement that's installed. However, including a package in a constraints file will _not_
/// trigger the installation of that package.
///
/// This is equivalent to pip's `--constraint` option.
#[ arg(long, short, alias = " constraint " , env = EnvVars::UV_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path) ]
pub constraints : Vec < Maybe < PathBuf > > ,
/// Override versions using the given requirements files.
///
/// Overrides files are `requirements.txt`-like files that force a specific version of a
/// requirement to be installed, regardless of the requirements declared by any constituent
/// package, and regardless of whether this would be considered an invalid resolution.
///
/// While constraints are _additive_, in that they're combined with the requirements of the
/// constituent packages, overrides are _absolute_, in that they completely replace the
/// requirements of the constituent packages.
#[ arg(long, alias = " override " , env = EnvVars::UV_OVERRIDE, value_delimiter = ' ', value_parser = parse_maybe_file_path) ]
pub overrides : Vec < Maybe < PathBuf > > ,
2024-06-26 11:24:29 -04:00
#[ command(flatten) ]
pub installer : ResolverInstallerArgs ,
#[ command(flatten) ]
2024-09-04 11:23:46 -04:00
pub build : BuildOptionsArgs ,
2024-06-26 11:24:29 -04:00
#[ command(flatten) ]
pub refresh : RefreshArgs ,
2024-06-26 16:03:01 -04:00
/// Force installation of the tool.
///
/// Will replace any existing entry points with the same name in the executable directory.
#[ arg(long) ]
pub force : bool ,
2024-06-26 11:24:29 -04:00
/// The Python interpreter to use to build the tool environment.
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` for details on Python discovery and supported
/// request formats.
2024-08-01 11:55:11 -05:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-08-01 11:55:11 -05:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-08-01 11:55:11 -05:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-06-26 11:24:29 -04:00
}
2024-06-28 18:00:18 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-07-17 19:11:13 -04:00
pub struct ToolListArgs {
/// Whether to display the path to each tool environment and installed executable.
#[ arg(long) ]
pub show_paths : bool ,
2024-08-14 00:21:44 +08:00
2024-09-05 10:15:18 +08:00
/// Whether to display the version specifier(s) used to install each tool.
#[ arg(long) ]
pub show_version_specifiers : bool ,
2024-08-14 00:21:44 +08:00
// Hide unused global Python options.
#[ arg(long, hide = true) ]
pub python_preference : Option < PythonPreference > ,
2024-09-05 10:15:18 +08:00
2024-08-14 00:21:44 +08:00
#[ arg(long, hide = true) ]
pub no_python_downloads : bool ,
2024-07-17 19:11:13 -04:00
}
2024-06-28 18:00:18 -04:00
2024-07-17 16:30:45 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct ToolDirArgs {
/// Show the directory into which `uv tool` will install executables.
///
/// By default, `uv tool dir` shows the directory into which the tool Python environments
/// themselves are installed, rather than the directory containing the linked executables.
2024-08-19 10:02:10 -05:00
///
/// The tool executable directory is determined according to the XDG standard and is derived
/// from the following environment variables, in order of preference:
///
/// - `$UV_TOOL_BIN_DIR`
/// - `$XDG_BIN_HOME`
/// - `$XDG_DATA_HOME/../bin`
/// - `$HOME/.local/bin`
#[ arg(long, verbatim_doc_comment) ]
2024-07-17 16:30:45 -04:00
pub bin : bool ,
}
2024-06-29 13:50:20 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct ToolUninstallArgs {
2024-07-02 15:30:40 -04:00
/// The name of the tool to uninstall.
2024-07-09 12:26:17 -07:00
#[ arg(required = true) ]
2024-09-05 14:24:13 +02:00
pub name : Vec < PackageName > ,
2024-07-09 12:26:17 -07:00
/// Uninstall all tools.
#[ arg(long, conflicts_with( " name " )) ]
pub all : bool ,
2024-06-29 13:50:20 -04:00
}
2024-08-08 22:48:14 +02:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct ToolUpgradeArgs {
2024-11-25 17:22:30 -05:00
/// The name of the tool to upgrade, along with an optional version specifier.
2024-08-08 22:48:14 +02:00
#[ arg(required = true) ]
2024-11-25 17:22:30 -05:00
pub name : Vec < String > ,
2024-08-08 22:48:14 +02:00
/// Upgrade all tools.
#[ arg(long, conflicts_with( " name " )) ]
pub all : bool ,
2024-09-25 10:40:28 -07:00
/// Upgrade a tool, and specify it to use the given Python interpreter
/// to build its environment. Use with `--all` to apply to all tools.
///
/// See `uv help python` for details on Python discovery and supported
/// request formats.
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PYTHON,
2024-09-25 10:40:28 -07:00
verbatim_doc_comment,
2024-10-04 07:32:03 -04:00
help_heading = " Python options " ,
value_parser = parse_maybe_string,
2024-09-25 10:40:28 -07:00
) ]
2024-10-04 07:32:03 -04:00
pub python : Option < Maybe < String > > ,
2024-09-25 10:40:28 -07:00
2024-11-21 09:35:57 -05:00
// The following is equivalent to flattening `ResolverInstallerArgs`, with the `--upgrade`,
// and `--upgrade-package` options hidden, and the `--no-upgrade` option removed.
/// Allow package upgrades, ignoring pinned versions in any existing output file. Implies
/// `--refresh`.
#[ arg(hide = true, long, short = 'U', help_heading = " Resolver options " ) ]
pub upgrade : bool ,
/// Allow upgrades for a specific package, ignoring pinned versions in any existing output
/// file. Implies `--refresh-package`.
#[ arg(hide = true, long, short = 'P', help_heading = " Resolver options " ) ]
pub upgrade_package : Vec < Requirement < VerbatimParsedUrl > > ,
2024-08-08 22:48:14 +02:00
#[ command(flatten) ]
2024-11-21 09:35:57 -05:00
pub index_args : IndexArgs ,
/// Reinstall all packages, regardless of whether they're already installed. Implies
/// `--refresh`.
#[ arg(
long,
alias = " force-reinstall " ,
overrides_with( " no_reinstall " ),
help_heading = " Installer options "
) ]
pub reinstall : bool ,
#[ arg(
long,
overrides_with( " reinstall " ),
hide = true,
help_heading = " Installer options "
) ]
pub no_reinstall : bool ,
/// Reinstall a specific package, regardless of whether it's already installed. Implies
/// `--refresh-package`.
#[ arg(long, help_heading = " Installer options " ) ]
pub reinstall_package : Vec < PackageName > ,
/// The strategy to use when resolving against multiple index URLs.
///
/// By default, uv will stop at the first index on which a given package is available, and
2024-12-19 12:40:14 -05:00
/// limit resolutions to those present on that first index (`first-index`). This prevents
2024-11-21 09:35:57 -05:00
/// "dependency confusion" attacks, whereby an attacker can upload a malicious package under the
/// same name to an alternate index.
#[ arg(
long,
value_enum,
env = EnvVars::UV_INDEX_STRATEGY,
help_heading = " Index options "
) ]
pub index_strategy : Option < IndexStrategy > ,
/// Attempt to use `keyring` for authentication for index URLs.
///
/// At present, only `--keyring-provider subprocess` is supported, which configures uv to
/// use the `keyring` CLI to handle authentication.
///
/// Defaults to `disabled`.
#[ arg(
long,
value_enum,
env = EnvVars::UV_KEYRING_PROVIDER,
help_heading = " Index options "
) ]
pub keyring_provider : Option < KeyringProviderType > ,
/// The strategy to use when selecting between the different compatible versions for a given
/// package requirement.
///
/// By default, uv will use the latest compatible version of each package (`highest`).
#[ arg(
long,
value_enum,
env = EnvVars::UV_RESOLUTION,
help_heading = " Resolver options "
) ]
pub resolution : Option < ResolutionMode > ,
/// The strategy to use when considering pre-release versions.
///
/// By default, uv will accept pre-releases for packages that _only_ publish pre-releases,
/// along with first-party requirements that contain an explicit pre-release marker in the
/// declared specifiers (`if-necessary-or-explicit`).
#[ arg(
long,
value_enum,
env = EnvVars::UV_PRERELEASE,
help_heading = " Resolver options "
) ]
pub prerelease : Option < PrereleaseMode > ,
#[ arg(long, hide = true) ]
pub pre : bool ,
2024-12-13 16:05:07 -05:00
/// The strategy to use when selecting multiple versions of a given package across Python
/// versions and platforms.
///
/// By default, uv will optimize for selecting the latest version of each package for each
/// supported Python version (`requires-python`), while minimizing the number of selected
/// versions across platforms.
///
2024-12-13 16:35:20 -05:00
/// Under `fewest`, uv will minimize the number of selected versions for each package,
/// preferring older versions that are compatible with a wider range of supported Python
/// versions or platforms.
2024-12-13 16:05:07 -05:00
#[ arg(
long,
value_enum,
env = EnvVars::UV_FORK_STRATEGY,
help_heading = " Resolver options "
) ]
pub fork_strategy : Option < ForkStrategy > ,
2024-11-21 09:35:57 -05:00
/// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
#[ arg(
long,
short = 'C',
alias = " config-settings " ,
help_heading = " Build options "
) ]
pub config_setting : Option < Vec < ConfigSettingEntry > > ,
/// Disable isolation when building source distributions.
///
/// Assumes that build dependencies specified by PEP 518 are already installed.
#[ arg(
long,
overrides_with( " build_isolation " ),
help_heading = " Build options " ,
env = EnvVars::UV_NO_BUILD_ISOLATION,
value_parser = clap::builder::BoolishValueParser::new(),
) ]
pub no_build_isolation : bool ,
/// Disable isolation when building source distributions for a specific package.
///
/// Assumes that the packages' build dependencies specified by PEP 518 are already installed.
#[ arg(long, help_heading = " Build options " ) ]
pub no_build_isolation_package : Vec < PackageName > ,
#[ arg(
long,
overrides_with( " no_build_isolation " ),
hide = true,
help_heading = " Build options "
) ]
pub build_isolation : bool ,
/// Limit candidate packages to those that were uploaded prior to the given date.
///
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
/// format (e.g., `2006-12-02`) in your system's configured time zone.
#[ arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = " Resolver options " ) ]
pub exclude_newer : Option < ExcludeNewer > ,
/// The method to use when installing packages from the global cache.
///
/// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
/// Windows.
#[ arg(
long,
value_enum,
env = EnvVars::UV_LINK_MODE,
help_heading = " Installer options "
) ]
pub link_mode : Option < uv_install_wheel ::linker ::LinkMode > ,
/// Compile Python files to bytecode after installation.
///
/// By default, uv does not compile Python (`.py`) files to bytecode (`__pycache__/*.pyc`);
/// instead, compilation is performed lazily the first time a module is imported. For use-cases
/// in which start time is critical, such as CLI applications and Docker containers, this option
/// can be enabled to trade longer installation times for faster start times.
///
/// When enabled, uv will process the entire site-packages directory (including packages that
/// are not being modified by the current operation) for consistency. Like pip, it will also
/// ignore errors.
#[ arg(
long,
alias = " compile " ,
overrides_with( " no_compile_bytecode " ),
help_heading = " Installer options " ,
env = EnvVars::UV_COMPILE_BYTECODE,
value_parser = clap::builder::BoolishValueParser::new(),
) ]
pub compile_bytecode : bool ,
#[ arg(
long,
alias = " no-compile " ,
overrides_with( " compile_bytecode " ),
hide = true,
help_heading = " Installer options "
) ]
pub no_compile_bytecode : bool ,
/// Ignore the `tool.uv.sources` table when resolving dependencies. Used to lock against the
/// standards-compliant, publishable package metadata, as opposed to using any local or Git
/// sources.
#[ arg(long, help_heading = " Resolver options " ) ]
pub no_sources : bool ,
2024-08-08 22:48:14 +02:00
#[ command(flatten) ]
2024-09-04 11:23:46 -04:00
pub build : BuildOptionsArgs ,
2024-08-08 22:48:14 +02:00
}
2024-06-10 10:22:00 -04:00
#[ derive(Args) ]
2024-06-13 18:43:18 -07:00
#[ allow(clippy::struct_excessive_bools) ]
2024-07-03 08:44:29 -04:00
pub struct PythonNamespace {
2024-06-10 10:22:00 -04:00
#[ command(subcommand) ]
2024-07-03 08:44:29 -04:00
pub command : PythonCommand ,
2024-06-10 10:22:00 -04:00
}
#[ derive(Subcommand) ]
2024-07-03 08:44:29 -04:00
pub enum PythonCommand {
/// List the available Python installations.
2024-08-09 14:46:21 -05:00
///
/// By default, installed Python versions and the downloads for latest
/// available patch version of each supported Python major version are
/// shown.
///
/// The displayed versions are filtered by the `--python-preference` option,
/// i.e., if using `only-system`, no managed Python versions will be shown.
///
/// Use `--all-versions` to view all available patch versions.
///
/// Use `--only-installed` to omit available downloads.
2024-07-03 08:44:29 -04:00
List ( PythonListArgs ) ,
2024-06-10 11:56:08 -04:00
2024-07-03 08:44:29 -04:00
/// Download and install Python versions.
2024-08-09 14:46:21 -05:00
///
/// Multiple Python versions may be requested.
///
2024-12-17 14:19:58 -06:00
/// Supports CPython and PyPy. CPython distributions are downloaded from the Astral
2024-10-30 09:13:20 -05:00
/// `python-build-standalone` project. PyPy distributions are downloaded from `python.org`.
2024-08-09 14:46:21 -05:00
///
2024-10-30 09:13:20 -05:00
/// Python versions are installed into the uv Python directory, which can be retrieved with `uv
/// python dir`.
2024-08-09 14:46:21 -05:00
///
2024-10-30 09:13:20 -05:00
/// A `python` executable is not made globally available, managed Python versions are only used
/// in uv commands or in active virtual environments. There is experimental support for
/// adding Python executables to the `PATH` — use the `--preview` flag to enable this behavior.
2024-08-09 14:46:21 -05:00
///
/// See `uv help python` to view supported request formats.
2024-07-03 08:44:29 -04:00
Install ( PythonInstallArgs ) ,
2024-06-14 13:03:16 -04:00
2024-07-03 08:44:29 -04:00
/// Search for a Python installation.
2024-08-09 14:46:21 -05:00
///
/// Displays the path to the Python executable.
///
/// See `uv help python` to view supported request formats and details on
/// discovery behavior.
2024-07-03 08:44:29 -04:00
Find ( PythonFindArgs ) ,
2024-07-01 16:51:59 +02:00
2024-07-10 12:52:24 -04:00
/// Pin to a specific Python version.
2024-08-09 14:46:21 -05:00
///
2024-12-04 20:27:49 +02:00
/// Writes the pinned Python version to a `.python-version` file, which is used by other uv
/// commands to determine the required Python version.
///
/// If no version is provided, uv will look for an existing `.python-version` file and display
/// the currently pinned version. If no `.python-version` file is found, uv will exit with an
/// error.
2024-08-09 14:46:21 -05:00
///
/// See `uv help python` to view supported request formats.
2024-07-10 12:52:24 -04:00
Pin ( PythonPinArgs ) ,
2024-07-03 08:44:29 -04:00
/// Show the uv Python installation directory.
2024-08-19 14:42:36 -05:00
///
/// By default, Python installations are stored in the uv data directory at
/// `$XDG_DATA_HOME/uv/python` or `$HOME/.local/share/uv/python` on Unix and
2024-08-23 21:34:08 +03:30
/// `%APPDATA%\uv\data\python` on Windows.
2024-08-19 14:42:36 -05:00
///
/// The Python installation directory may be overridden with `$UV_PYTHON_INSTALL_DIR`.
2024-10-30 09:13:20 -05:00
///
2024-10-30 16:48:34 -05:00
/// To view the directory where uv installs Python executables instead, use the `--bin` flag.
/// Note that Python executables are only installed when preview mode is enabled.
2024-10-30 09:13:20 -05:00
Dir ( PythonDirArgs ) ,
2024-07-01 22:37:53 -04:00
2024-07-03 08:44:29 -04:00
/// Uninstall Python versions.
Uninstall ( PythonUninstallArgs ) ,
2024-06-10 10:22:00 -04:00
}
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-07-03 08:44:29 -04:00
pub struct PythonListArgs {
2024-08-09 14:46:21 -05:00
/// List all Python versions, including old patch versions.
///
/// By default, only the latest patch version is shown for each minor version.
2024-06-13 11:25:30 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub all_versions : bool ,
2024-06-13 11:25:30 -04:00
2024-08-09 14:46:21 -05:00
/// List Python downloads for all platforms.
///
/// By default, only downloads for the current platform are shown.
2024-06-13 11:25:30 -04:00
#[ arg(long) ]
2024-06-24 13:16:22 +03:00
pub all_platforms : bool ,
2024-06-10 10:22:00 -04:00
2024-12-10 14:02:41 -06:00
/// List Python downloads for all architectures.
///
/// By default, only downloads for the current architecture are shown.
#[ arg(long, alias = " all_architectures " ) ]
pub all_arches : bool ,
2024-07-03 08:44:29 -04:00
/// Only show installed Python versions, exclude available downloads.
2024-08-09 14:46:21 -05:00
///
/// By default, available downloads for the current platform are shown.
2024-12-10 12:52:40 -06:00
#[ arg(long, conflicts_with( " only_downloads " )) ]
2024-06-24 13:16:22 +03:00
pub only_installed : bool ,
2024-12-10 12:52:40 -06:00
/// Only show Python downloads, exclude installed distributions.
///
/// By default, available downloads for the current platform are shown.
#[ arg(long, conflicts_with( " only_installed " )) ]
pub only_downloads : bool ,
/// Show the URLs of available Python downloads.
///
/// By default, these display as `<download available>`.
#[ arg(long) ]
pub show_urls : bool ,
2024-06-10 10:22:00 -04:00
}
2024-10-30 09:13:20 -05:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct PythonDirArgs {
/// Show the directory into which `uv python` will install Python executables.
///
2024-10-30 16:48:34 -05:00
/// Note that this directory is only used when installing Python with preview mode enabled.
2024-10-30 09:13:20 -05:00
///
/// The Python executable directory is determined according to the XDG standard and is derived
/// from the following environment variables, in order of preference:
///
/// - `$UV_PYTHON_BIN_DIR`
/// - `$XDG_BIN_HOME`
/// - `$XDG_DATA_HOME/../bin`
/// - `$HOME/.local/bin`
#[ arg(long, verbatim_doc_comment) ]
pub bin : bool ,
}
2024-06-10 11:56:08 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-07-03 08:44:29 -04:00
pub struct PythonInstallArgs {
2024-12-10 19:04:31 +02:00
/// The directory to store the Python installation in.
///
/// If provided, `UV_PYTHON_INSTALL_DIR` will need to be set for subsequent operations for
/// uv to discover the Python installation.
///
/// See `uv python dir` to view the current Python installation directory. Defaults to
/// `~/.local/share/uv/python`.
2024-12-18 23:10:27 -04:00
#[ arg(long, short, env = EnvVars::UV_PYTHON_INSTALL_DIR) ]
2024-12-10 19:04:31 +02:00
pub install_dir : Option < PathBuf > ,
2024-07-04 18:31:40 -04:00
/// The Python version(s) to install.
2024-06-10 11:56:08 -04:00
///
2024-08-07 11:37:10 -05:00
/// If not provided, the requested Python version(s) will be read from the
/// `.python-versions` or `.python-version` files. If neither file is
/// present, uv will check if it has installed any Python versions. If not,
/// it will install the latest stable version of Python.
///
/// See `uv help python` to view supported request formats.
2024-06-24 13:16:22 +03:00
pub targets : Vec < String > ,
2024-06-13 17:43:40 -04:00
2024-11-14 03:08:55 +11:00
/// Set the URL to use as the source for downloading Python installations.
///
2024-12-17 14:19:58 -06:00
/// The provided URL will replace `https://github.com/astral-sh/python-build-standalone/releases/download` in, e.g., `https://github.com/astral-sh/python-build-standalone/releases/download/20240713/cpython-3.12.4%2B20240713-aarch64-apple-darwin-install_only.tar.gz`.
2024-11-14 03:08:55 +11:00
///
/// Distributions can be read from a local directory by using the `file://` URL scheme.
#[ arg(long, env = EnvVars::UV_PYTHON_INSTALL_MIRROR) ]
pub mirror : Option < String > ,
/// Set the URL to use as the source for downloading PyPy installations.
///
/// The provided URL will replace `https://downloads.python.org/pypy` in, e.g., `https://downloads.python.org/pypy/pypy3.8-v7.3.7-osx64.tar.bz2`.
///
/// Distributions can be read from a local directory by using the `file://` URL scheme.
#[ arg(long, env = EnvVars::UV_PYPY_INSTALL_MIRROR) ]
pub pypy_mirror : Option < String > ,
2024-07-11 22:06:54 -03:00
/// Reinstall the requested Python version, if it's already installed.
2024-08-09 14:46:21 -05:00
///
/// By default, uv will exit successfully if the version is already
/// installed.
2024-11-04 14:22:44 -06:00
#[ arg(long, short) ]
2024-07-11 22:06:54 -03:00
pub reinstall : bool ,
2024-11-04 14:22:44 -06:00
/// Replace existing Python executables during installation.
///
/// By default, uv will refuse to replace executables that it does not manage.
///
/// Implies `--reinstall`.
#[ arg(long, short) ]
pub force : bool ,
2024-12-02 19:04:57 -06:00
/// Use as the default Python version.
///
/// By default, only a `python{major}.{minor}` executable is installed, e.g., `python3.10`. When
/// the `--default` flag is used, `python{major}`, e.g., `python3`, and `python` executables are
/// also installed.
///
/// Alternative Python variants will still include their tag. For example, installing
/// 3.13+freethreaded with `--default` will include in `python3t` and `pythont`, not `python3`
/// and `python`.
///
2024-12-18 16:12:54 -06:00
/// If multiple Python versions are requested, uv will exit with an error.
2024-12-02 19:04:57 -06:00
#[ arg(long) ]
pub default : bool ,
2024-06-10 11:56:08 -04:00
}
2024-07-01 22:37:53 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-07-03 08:44:29 -04:00
pub struct PythonUninstallArgs {
2024-12-10 19:04:31 +02:00
/// The directory where the Python was installed.
2024-12-18 23:10:27 -04:00
#[ arg(long, short, env = EnvVars::UV_PYTHON_INSTALL_DIR) ]
2024-12-10 19:04:31 +02:00
pub install_dir : Option < PathBuf > ,
2024-07-04 18:31:40 -04:00
/// The Python version(s) to uninstall.
2024-08-07 11:37:10 -05:00
///
/// See `uv help python` to view supported request formats.
2024-07-04 18:31:40 -04:00
#[ arg(required = true) ]
2024-07-01 22:37:53 -04:00
pub targets : Vec < String > ,
2024-07-09 11:15:16 -07:00
/// Uninstall all managed Python versions.
#[ arg(long, conflicts_with( " targets " )) ]
pub all : bool ,
2024-07-01 22:37:53 -04:00
}
2024-06-14 13:03:16 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-07-03 08:44:29 -04:00
pub struct PythonFindArgs {
/// The Python request.
2024-08-07 11:37:10 -05:00
///
/// See `uv help python` to view supported request formats.
2024-06-24 13:16:22 +03:00
pub request : Option < String > ,
2024-08-21 17:08:29 -05:00
/// Avoid discovering a project or workspace.
///
/// Otherwise, when no request is provided, the Python requirement of a project in the current
/// directory or parent directories will be used.
#[ arg(long, alias = " no_workspace " ) ]
pub no_project : bool ,
2024-08-23 16:06:57 -05:00
/// Only find system Python interpreters.
///
/// By default, uv will report the first Python interpreter it would use, including those in an
/// active virtual environment or a virtual environment in the current working directory or any
/// parent directory.
///
/// The `--system` option instructs uv to skip virtual environment Python interpreters and
/// restrict its search to the system path.
#[ arg(
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_SYSTEM_PYTHON,
2024-08-23 16:06:57 -05:00
value_parser = clap::builder::BoolishValueParser::new(),
overrides_with( " no_system " )
) ]
pub system : bool ,
#[ arg(long, overrides_with( " system " ), hide = true) ]
pub no_system : bool ,
2024-06-14 13:03:16 -04:00
}
2024-07-10 12:52:24 -04:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct PythonPinArgs {
2024-08-07 11:37:10 -05:00
/// The Python version request.
///
/// uv supports more formats than other tools that read `.python-version`
/// files, i.e., `pyenv`. If compatibility with those tools is needed, only
/// use version numbers instead of complex requests such as `cpython@3.10`.
///
2024-12-04 20:27:49 +02:00
/// If no request is provided, the currently pinned version will be shown.
///
2024-08-07 11:37:10 -05:00
/// See `uv help python` to view supported request formats.
2024-07-10 12:52:24 -04:00
pub request : Option < String > ,
/// Write the resolved Python interpreter path instead of the request.
///
/// Ensures that the exact same interpreter is used.
2024-08-09 14:46:21 -05:00
///
/// This option is usually not safe to use when committing the
/// `.python-version` file to version control.
2024-07-10 12:52:24 -04:00
#[ arg(long, overrides_with( " resolved " )) ]
pub resolved : bool ,
#[ arg(long, overrides_with( " no_resolved " ), hide = true) ]
pub no_resolved : bool ,
2024-07-30 13:52:53 -04:00
2024-08-23 11:08:27 -05:00
/// Avoid validating the Python pin is compatible with the project or workspace.
2024-08-09 14:46:21 -05:00
///
2024-08-23 11:08:27 -05:00
/// By default, a project or workspace is discovered in the current directory or any parent
/// directory. If a workspace is found, the Python pin is validated against the workspace's
/// `requires-python` constraint.
#[ arg(long, alias = " no-workspace " ) ]
pub no_project : bool ,
2024-07-10 12:52:24 -04:00
}
2024-08-18 03:34:34 +09:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct GenerateShellCompletionArgs {
/// The shell to generate the completion script for
pub shell : clap_complete_command ::Shell ,
// Hide unused global options.
#[ arg(long, short, hide = true) ]
pub no_cache : bool ,
#[ arg(long, hide = true) ]
pub cache_dir : Option < PathBuf > ,
#[ arg(long, hide = true) ]
pub python_preference : Option < PythonPreference > ,
#[ arg(long, hide = true) ]
pub no_python_downloads : bool ,
#[ arg(long, short, conflicts_with = " verbose " , hide = true) ]
pub quiet : bool ,
#[ arg(long, short, action = clap::ArgAction::Count, conflicts_with = " quiet " , hide = true) ]
pub verbose : u8 ,
2025-01-05 21:18:16 -05:00
#[ arg(long, conflicts_with = " no_color " , hide = true) ]
pub color : Option < ColorChoice > ,
2024-08-18 03:34:34 +09:00
#[ arg(long, hide = true) ]
pub native_tls : bool ,
#[ arg(long, hide = true) ]
pub offline : bool ,
#[ arg(long, hide = true) ]
pub no_progress : bool ,
#[ arg(long, hide = true) ]
pub config_file : Option < PathBuf > ,
#[ arg(long, hide = true) ]
pub no_config : bool ,
#[ arg(long, short, action = clap::ArgAction::HelpShort, hide = true) ]
pub help : Option < bool > ,
#[ arg(short = 'V', long, hide = true) ]
pub version : bool ,
}
2024-06-03 10:27:35 -04:00
#[ derive(Args) ]
2024-06-13 18:43:18 -07:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct IndexArgs {
2024-10-15 15:24:23 -07:00
/// The URLs to use when resolving dependencies, in addition to the default index.
///
/// Accepts either a repository compliant with PEP 503 (the simple repository API), or a local
/// directory laid out in the same format.
///
/// All indexes provided via this flag take priority over the index specified by
/// `--default-index` (which defaults to PyPI). When multiple `--index` flags are
/// provided, earlier values take priority.
2024-10-16 01:40:09 +00:00
#[ arg(long, env = EnvVars::UV_INDEX, value_delimiter = ' ', value_parser = parse_index, help_heading = " Index options " ) ]
2024-10-15 15:24:23 -07:00
pub index : Option < Vec < Maybe < Index > > > ,
/// The URL of the default package index (by default: <https://pypi.org/simple>).
///
/// Accepts either a repository compliant with PEP 503 (the simple repository API), or a local
/// directory laid out in the same format.
///
/// The index given by this flag is given lower priority than all other indexes specified via
/// the `--index` flag.
2024-10-16 01:40:09 +00:00
#[ arg(long, env = EnvVars::UV_DEFAULT_INDEX, value_parser = parse_default_index, help_heading = " Index options " ) ]
2024-10-15 15:24:23 -07:00
pub default_index : Option < Maybe < Index > > ,
/// (Deprecated: use `--default-index` instead) The URL of the Python package index (by default: <https://pypi.org/simple>).
2024-06-03 10:17:41 -04:00
///
2024-06-10 19:27:04 -07:00
/// Accepts either a repository compliant with PEP 503 (the simple repository API), or a local
/// directory laid out in the same format.
///
2024-06-03 10:17:41 -04:00
/// The index given by this flag is given lower priority than all other
/// indexes specified via the `--extra-index-url` flag.
2024-10-14 21:48:13 +00:00
#[ arg(long, short, env = EnvVars::UV_INDEX_URL, value_parser = parse_index_url, help_heading = " Index options " ) ]
2024-10-15 16:56:24 -07:00
pub index_url : Option < Maybe < PipIndex > > ,
2024-06-03 10:17:41 -04:00
2024-10-15 15:24:23 -07:00
/// (Deprecated: use `--index` instead) Extra URLs of package indexes to use, in addition to `--index-url`.
2024-06-03 10:17:41 -04:00
///
2024-06-10 19:27:04 -07:00
/// Accepts either a repository compliant with PEP 503 (the simple repository API), or a local
/// directory laid out in the same format.
///
2024-07-16 16:39:22 -04:00
/// All indexes provided via this flag take priority over the index specified by
/// `--index-url` (which defaults to PyPI). When multiple `--extra-index-url` flags are
/// provided, earlier values take priority.
2024-10-15 16:56:24 -07:00
#[ arg(long, env = EnvVars::UV_EXTRA_INDEX_URL, value_delimiter = ' ', value_parser = parse_extra_index_url, help_heading = " Index options " ) ]
pub extra_index_url : Option < Vec < Maybe < PipExtraIndex > > > ,
2024-06-03 10:17:41 -04:00
2024-07-16 16:39:22 -04:00
/// Locations to search for candidate distributions, in addition to those found in the registry
/// indexes.
2024-06-03 10:17:41 -04:00
///
2024-07-16 16:39:22 -04:00
/// If a path, the target must be a directory that contains packages as wheel files (`.whl`) or
2024-09-07 21:16:12 +02:00
/// source distributions (e.g., `.tar.gz` or `.zip`) at the top level.
2024-06-03 10:17:41 -04:00
///
2024-07-16 16:39:22 -04:00
/// If a URL, the page must contain a flat list of links to package files adhering to the
/// formats described above.
2024-10-04 04:30:49 -07:00
#[ arg(
long,
short,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_FIND_LINKS,
2024-10-15 16:56:24 -07:00
value_parser = parse_find_links,
2024-10-04 04:30:49 -07:00
help_heading = " Index options "
) ]
2024-10-15 16:56:24 -07:00
pub find_links : Option < Vec < Maybe < PipFindLinks > > > ,
2024-06-03 10:17:41 -04:00
/// Ignore the registry index (e.g., PyPI), instead relying on direct URL dependencies and those
2024-07-16 16:39:22 -04:00
/// provided via `--find-links`.
2024-08-05 16:28:35 -05:00
#[ arg(long, help_heading = " Index options " ) ]
2024-06-24 13:16:22 +03:00
pub no_index : bool ,
2024-05-21 15:51:30 -04:00
}
2024-06-13 17:56:38 -07:00
2024-06-13 18:43:18 -07:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct RefreshArgs {
2024-06-13 18:43:18 -07:00
/// Refresh all cached data.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
conflicts_with( " offline " ),
overrides_with( " no_refresh " ),
help_heading = " Cache options "
) ]
2024-06-24 13:16:22 +03:00
pub refresh : bool ,
2024-06-13 18:43:18 -07:00
#[ arg(
long,
conflicts_with( " offline " ),
overrides_with( " refresh " ),
2024-08-05 16:28:35 -05:00
hide = true,
help_heading = " Cache options "
2024-06-13 18:43:18 -07:00
) ]
2024-06-24 13:16:22 +03:00
pub no_refresh : bool ,
2024-06-13 18:43:18 -07:00
/// Refresh cached data for a specific package.
2024-08-05 16:28:35 -05:00
#[ arg(long, help_heading = " Cache options " ) ]
2024-06-24 13:16:22 +03:00
pub refresh_package : Vec < PackageName > ,
2024-06-13 18:43:18 -07:00
}
2024-06-13 21:05:00 -07:00
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
2024-09-04 11:23:46 -04:00
pub struct BuildOptionsArgs {
2024-06-13 21:05:00 -07:00
/// Don't build source distributions.
///
2024-07-16 16:39:22 -04:00
/// When enabled, resolving will not run arbitrary Python code. The cached wheels of
/// already-built source distributions will be reused, but operations that require building
/// distributions will exit with an error.
2024-08-05 16:28:35 -05:00
#[ arg(long, overrides_with( " build " ), help_heading = " Build options " ) ]
2024-06-24 13:16:22 +03:00
pub no_build : bool ,
2024-06-13 21:05:00 -07:00
2024-08-05 16:28:35 -05:00
#[ arg(
long,
overrides_with( " no_build " ),
hide = true,
help_heading = " Build options "
) ]
2024-06-24 13:16:22 +03:00
pub build : bool ,
2024-06-13 21:05:00 -07:00
/// Don't build source distributions for a specific package.
2024-08-05 16:28:35 -05:00
#[ arg(long, help_heading = " Build options " ) ]
2024-06-24 13:16:22 +03:00
pub no_build_package : Vec < PackageName > ,
2024-06-13 21:05:00 -07:00
/// Don't install pre-built wheels.
///
2024-07-16 16:39:22 -04:00
/// The given packages will be built and installed from source. The resolver will still use
/// pre-built wheels to extract package metadata, if available.
2024-08-05 16:28:35 -05:00
#[ arg(long, overrides_with( " binary " ), help_heading = " Build options " ) ]
2024-06-24 13:16:22 +03:00
pub no_binary : bool ,
2024-06-13 21:05:00 -07:00
2024-08-05 16:28:35 -05:00
#[ arg(
long,
overrides_with( " no_binary " ),
hide = true,
help_heading = " Build options "
) ]
2024-06-24 13:16:22 +03:00
pub binary : bool ,
2024-06-13 21:05:00 -07:00
/// Don't install pre-built wheels for a specific package.
2024-08-05 16:28:35 -05:00
#[ arg(long, help_heading = " Build options " ) ]
2024-06-24 13:16:22 +03:00
pub no_binary_package : Vec < PackageName > ,
2024-06-13 21:05:00 -07:00
}
2024-06-13 17:56:38 -07:00
/// Arguments that are used by commands that need to install (but not resolve) packages.
#[ derive(Args) ]
2024-06-13 18:43:18 -07:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct InstallerArgs {
2024-06-13 17:56:38 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub index_args : IndexArgs ,
2024-06-13 17:56:38 -07:00
2024-07-25 09:45:58 -04:00
/// Reinstall all packages, regardless of whether they're already installed. Implies
/// `--refresh`.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
alias = " force-reinstall " ,
overrides_with( " no_reinstall " ),
help_heading = " Installer options "
) ]
2024-06-24 13:16:22 +03:00
pub reinstall : bool ,
2024-06-13 18:43:18 -07:00
2024-08-05 16:28:35 -05:00
#[ arg(
long,
overrides_with( " reinstall " ),
hide = true,
help_heading = " Installer options "
) ]
2024-06-24 13:16:22 +03:00
pub no_reinstall : bool ,
2024-06-13 18:43:18 -07:00
2024-07-25 09:45:58 -04:00
/// Reinstall a specific package, regardless of whether it's already installed. Implies
/// `--refresh-package`.
2024-08-05 16:28:35 -05:00
#[ arg(long, help_heading = " Installer options " ) ]
2024-06-24 13:16:22 +03:00
pub reinstall_package : Vec < PackageName > ,
2024-06-13 18:43:18 -07:00
2024-06-13 17:56:38 -07:00
/// The strategy to use when resolving against multiple index URLs.
///
2024-07-16 16:50:04 -04:00
/// By default, uv will stop at the first index on which a given package is available, and
2024-12-19 12:40:14 -05:00
/// limit resolutions to those present on that first index (`first-index`). This prevents
2024-10-15 15:24:23 -07:00
/// "dependency confusion" attacks, whereby an attacker can upload a malicious package under the
/// same name to an alternate index.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_INDEX_STRATEGY,
2024-08-05 16:28:35 -05:00
help_heading = " Index options "
) ]
2024-06-24 13:16:22 +03:00
pub index_strategy : Option < IndexStrategy > ,
2024-06-13 17:56:38 -07:00
/// Attempt to use `keyring` for authentication for index URLs.
///
2024-07-16 16:50:04 -04:00
/// At present, only `--keyring-provider subprocess` is supported, which configures uv to
2024-06-13 17:56:38 -07:00
/// use the `keyring` CLI to handle authentication.
///
/// Defaults to `disabled`.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_KEYRING_PROVIDER,
2024-08-05 16:28:35 -05:00
help_heading = " Index options "
) ]
2024-06-24 13:16:22 +03:00
pub keyring_provider : Option < KeyringProviderType > ,
2024-06-13 17:56:38 -07:00
/// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
short = 'C',
alias = " config-settings " ,
help_heading = " Build options "
) ]
2024-06-24 13:16:22 +03:00
pub config_setting : Option < Vec < ConfigSettingEntry > > ,
2024-06-13 17:56:38 -07:00
2024-08-06 17:11:48 -04:00
/// Disable isolation when building source distributions.
///
/// Assumes that build dependencies specified by PEP 518 are already installed.
#[ arg(
long,
overrides_with( " build_isolation " ),
help_heading = " Build options " ,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_NO_BUILD_ISOLATION,
2024-08-06 17:11:48 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
) ]
pub no_build_isolation : bool ,
#[ arg(
long,
overrides_with( " no_build_isolation " ),
hide = true,
help_heading = " Build options "
) ]
pub build_isolation : bool ,
2024-07-03 14:05:05 -04:00
/// Limit candidate packages to those that were uploaded prior to the given date.
///
2024-08-19 10:36:00 -07:00
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
/// format (e.g., `2006-12-02`) in your system's configured time zone.
2024-10-14 21:48:13 +00:00
#[ arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = " Resolver options " ) ]
2024-07-03 14:05:05 -04:00
pub exclude_newer : Option < ExcludeNewer > ,
2024-06-13 17:56:38 -07:00
/// The method to use when installing packages from the global cache.
///
/// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
/// Windows.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_LINK_MODE,
2024-08-05 16:28:35 -05:00
help_heading = " Installer options "
) ]
2024-10-01 20:45:39 -04:00
pub link_mode : Option < uv_install_wheel ::linker ::LinkMode > ,
2024-06-13 17:56:38 -07:00
2024-07-16 17:14:27 -04:00
/// Compile Python files to bytecode after installation.
2024-06-13 17:56:38 -07:00
///
2024-07-16 17:14:27 -04:00
/// By default, uv does not compile Python (`.py`) files to bytecode (`__pycache__/*.pyc`);
/// instead, compilation is performed lazily the first time a module is imported. For use-cases
/// in which start time is critical, such as CLI applications and Docker containers, this option
/// can be enabled to trade longer installation times for faster start times.
2024-06-13 17:56:38 -07:00
///
2024-07-16 17:14:27 -04:00
/// When enabled, uv will process the entire site-packages directory (including packages that
/// are not being modified by the current operation) for consistency. Like pip, it will also
/// ignore errors.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
alias = " compile " ,
overrides_with( " no_compile_bytecode " ),
2024-08-23 14:05:32 -04:00
help_heading = " Installer options " ,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_COMPILE_BYTECODE,
2024-08-23 14:05:32 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-08-05 16:28:35 -05:00
) ]
2024-06-24 13:16:22 +03:00
pub compile_bytecode : bool ,
2024-06-13 17:56:38 -07:00
#[ arg(
long,
2024-06-23 20:25:50 +03:00
alias = " no-compile " ,
2024-06-13 17:56:38 -07:00
overrides_with( " compile_bytecode " ),
2024-08-05 16:28:35 -05:00
hide = true,
help_heading = " Installer options "
2024-06-13 17:56:38 -07:00
) ]
2024-06-24 13:16:22 +03:00
pub no_compile_bytecode : bool ,
2024-08-06 10:14:19 -04:00
/// Ignore the `tool.uv.sources` table when resolving dependencies. Used to lock against the
/// standards-compliant, publishable package metadata, as opposed to using any local or Git
/// sources.
2024-08-06 17:29:56 -04:00
#[ arg(long, help_heading = " Resolver options " ) ]
2024-08-06 10:14:19 -04:00
pub no_sources : bool ,
2024-06-13 17:56:38 -07:00
}
/// Arguments that are used by commands that need to resolve (but not install) packages.
#[ derive(Args) ]
2024-06-13 18:43:18 -07:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct ResolverArgs {
2024-06-13 17:56:38 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub index_args : IndexArgs ,
2024-06-13 17:56:38 -07:00
2024-08-08 20:11:31 -04:00
/// Allow package upgrades, ignoring pinned versions in any existing output file. Implies
/// `--refresh`.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
short = 'U',
overrides_with( " no_upgrade " ),
help_heading = " Resolver options "
) ]
2024-06-24 13:16:22 +03:00
pub upgrade : bool ,
2024-06-13 18:43:18 -07:00
2024-08-05 16:28:35 -05:00
#[ arg(
long,
overrides_with( " upgrade " ),
hide = true,
help_heading = " Resolver options "
) ]
2024-06-24 13:16:22 +03:00
pub no_upgrade : bool ,
2024-06-13 18:43:18 -07:00
/// Allow upgrades for a specific package, ignoring pinned versions in any existing output
2024-08-08 20:11:31 -04:00
/// file. Implies `--refresh-package`.
2024-08-05 16:28:35 -05:00
#[ arg(long, short = 'P', help_heading = " Resolver options " ) ]
2024-07-09 20:09:13 -07:00
pub upgrade_package : Vec < Requirement < VerbatimParsedUrl > > ,
2024-06-13 18:43:18 -07:00
2024-06-13 17:56:38 -07:00
/// The strategy to use when resolving against multiple index URLs.
///
2024-07-16 16:50:04 -04:00
/// By default, uv will stop at the first index on which a given package is available, and
2024-12-19 12:40:14 -05:00
/// limit resolutions to those present on that first index (`first-index`). This prevents
2024-10-15 15:24:23 -07:00
/// "dependency confusion" attacks, whereby an attacker can upload a malicious package under the
/// same name to an alternate index.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_INDEX_STRATEGY,
2024-08-05 16:28:35 -05:00
help_heading = " Index options "
) ]
2024-06-24 13:16:22 +03:00
pub index_strategy : Option < IndexStrategy > ,
2024-06-13 17:56:38 -07:00
/// Attempt to use `keyring` for authentication for index URLs.
///
2024-07-16 16:50:04 -04:00
/// At present, only `--keyring-provider subprocess` is supported, which configures uv to
2024-06-13 17:56:38 -07:00
/// use the `keyring` CLI to handle authentication.
///
/// Defaults to `disabled`.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_KEYRING_PROVIDER,
2024-08-05 16:28:35 -05:00
help_heading = " Index options "
) ]
2024-06-24 13:16:22 +03:00
pub keyring_provider : Option < KeyringProviderType > ,
2024-06-13 17:56:38 -07:00
/// The strategy to use when selecting between the different compatible versions for a given
/// package requirement.
///
2024-07-16 16:50:04 -04:00
/// By default, uv will use the latest compatible version of each package (`highest`).
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_RESOLUTION,
2024-08-05 16:28:35 -05:00
help_heading = " Resolver options "
) ]
2024-06-24 13:16:22 +03:00
pub resolution : Option < ResolutionMode > ,
2024-06-13 17:56:38 -07:00
/// The strategy to use when considering pre-release versions.
///
2024-07-16 16:50:04 -04:00
/// By default, uv will accept pre-releases for packages that _only_ publish pre-releases,
2024-06-13 17:56:38 -07:00
/// along with first-party requirements that contain an explicit pre-release marker in the
/// declared specifiers (`if-necessary-or-explicit`).
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PRERELEASE,
2024-08-05 16:28:35 -05:00
help_heading = " Resolver options "
) ]
2024-08-01 16:56:29 -04:00
pub prerelease : Option < PrereleaseMode > ,
2024-06-13 17:56:38 -07:00
2024-08-05 16:28:35 -05:00
#[ arg(long, hide = true, help_heading = " Resolver options " ) ]
2024-06-24 13:16:22 +03:00
pub pre : bool ,
2024-06-13 17:56:38 -07:00
2024-12-13 16:05:07 -05:00
/// The strategy to use when selecting multiple versions of a given package across Python
/// versions and platforms.
///
/// By default, uv will optimize for selecting the latest version of each package for each
/// supported Python version (`requires-python`), while minimizing the number of selected
/// versions across platforms.
///
2024-12-13 16:35:20 -05:00
/// Under `fewest`, uv will minimize the number of selected versions for each package,
/// preferring older versions that are compatible with a wider range of supported Python
/// versions or platforms.
2024-12-13 16:05:07 -05:00
#[ arg(
long,
value_enum,
env = EnvVars::UV_FORK_STRATEGY,
help_heading = " Resolver options "
) ]
pub fork_strategy : Option < ForkStrategy > ,
2024-06-13 17:56:38 -07:00
/// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
short = 'C',
alias = " config-settings " ,
help_heading = " Build options "
) ]
2024-06-24 13:16:22 +03:00
pub config_setting : Option < Vec < ConfigSettingEntry > > ,
2024-06-13 17:56:38 -07:00
2024-08-06 17:11:48 -04:00
/// Disable isolation when building source distributions.
///
/// Assumes that build dependencies specified by PEP 518 are already installed.
#[ arg(
long,
overrides_with( " build_isolation " ),
help_heading = " Build options " ,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_NO_BUILD_ISOLATION,
2024-08-06 17:11:48 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
) ]
pub no_build_isolation : bool ,
2024-08-08 03:35:56 +02:00
/// Disable isolation when building source distributions for a specific package.
///
2024-09-24 04:15:06 +08:00
/// Assumes that the packages' build dependencies specified by PEP 518 are already installed.
2024-08-08 03:35:56 +02:00
#[ arg(long, help_heading = " Build options " ) ]
pub no_build_isolation_package : Vec < PackageName > ,
2024-08-06 17:11:48 -04:00
#[ arg(
long,
overrides_with( " no_build_isolation " ),
hide = true,
help_heading = " Build options "
) ]
pub build_isolation : bool ,
2024-06-13 17:56:38 -07:00
/// Limit candidate packages to those that were uploaded prior to the given date.
///
2024-08-19 10:36:00 -07:00
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
/// format (e.g., `2006-12-02`) in your system's configured time zone.
2024-10-14 21:48:13 +00:00
#[ arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = " Resolver options " ) ]
2024-06-24 13:16:22 +03:00
pub exclude_newer : Option < ExcludeNewer > ,
2024-06-13 17:56:38 -07:00
/// The method to use when installing packages from the global cache.
///
/// This option is only used when building source distributions.
///
/// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
/// Windows.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_LINK_MODE,
2024-08-05 16:28:35 -05:00
help_heading = " Installer options "
) ]
2024-10-01 20:45:39 -04:00
pub link_mode : Option < uv_install_wheel ::linker ::LinkMode > ,
2024-08-06 10:14:19 -04:00
/// Ignore the `tool.uv.sources` table when resolving dependencies. Used to lock against the
/// standards-compliant, publishable package metadata, as opposed to using any local or Git
/// sources.
2024-08-06 17:29:56 -04:00
#[ arg(long, help_heading = " Resolver options " ) ]
2024-08-06 10:14:19 -04:00
pub no_sources : bool ,
2024-06-13 17:56:38 -07:00
}
/// Arguments that are used by commands that need to resolve and install packages.
#[ derive(Args) ]
2024-06-13 18:43:18 -07:00
#[ allow(clippy::struct_excessive_bools) ]
2024-06-24 13:16:22 +03:00
pub struct ResolverInstallerArgs {
2024-06-13 17:56:38 -07:00
#[ command(flatten) ]
2024-06-24 13:16:22 +03:00
pub index_args : IndexArgs ,
2024-06-13 17:56:38 -07:00
2024-08-08 20:11:31 -04:00
/// Allow package upgrades, ignoring pinned versions in any existing output file. Implies
/// `--refresh`.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
short = 'U',
overrides_with( " no_upgrade " ),
help_heading = " Resolver options "
) ]
2024-06-24 13:16:22 +03:00
pub upgrade : bool ,
2024-06-13 18:43:18 -07:00
2024-08-05 16:28:35 -05:00
#[ arg(
long,
overrides_with( " upgrade " ),
hide = true,
help_heading = " Resolver options "
) ]
2024-06-24 13:16:22 +03:00
pub no_upgrade : bool ,
2024-06-13 18:43:18 -07:00
/// Allow upgrades for a specific package, ignoring pinned versions in any existing output
2024-08-08 20:11:31 -04:00
/// file. Implies `--refresh-package`.
2024-08-05 16:28:35 -05:00
#[ arg(long, short = 'P', help_heading = " Resolver options " ) ]
2024-07-09 20:09:13 -07:00
pub upgrade_package : Vec < Requirement < VerbatimParsedUrl > > ,
2024-06-13 18:43:18 -07:00
2024-07-25 09:45:58 -04:00
/// Reinstall all packages, regardless of whether they're already installed. Implies
/// `--refresh`.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
alias = " force-reinstall " ,
overrides_with( " no_reinstall " ),
help_heading = " Installer options "
) ]
2024-06-24 13:16:22 +03:00
pub reinstall : bool ,
2024-06-13 18:43:18 -07:00
2024-08-05 16:28:35 -05:00
#[ arg(
long,
overrides_with( " reinstall " ),
hide = true,
help_heading = " Installer options "
) ]
2024-06-24 13:16:22 +03:00
pub no_reinstall : bool ,
2024-06-13 18:43:18 -07:00
2024-07-25 09:45:58 -04:00
/// Reinstall a specific package, regardless of whether it's already installed. Implies
/// `--refresh-package`.
2024-08-05 16:28:35 -05:00
#[ arg(long, help_heading = " Installer options " ) ]
2024-06-24 13:16:22 +03:00
pub reinstall_package : Vec < PackageName > ,
2024-06-13 18:43:18 -07:00
2024-06-13 17:56:38 -07:00
/// The strategy to use when resolving against multiple index URLs.
///
2024-07-16 16:50:04 -04:00
/// By default, uv will stop at the first index on which a given package is available, and
2024-12-19 12:40:14 -05:00
/// limit resolutions to those present on that first index (`first-index`). This prevents
2024-10-15 15:24:23 -07:00
/// "dependency confusion" attacks, whereby an attacker can upload a malicious package under the
/// same name to an alternate index.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_INDEX_STRATEGY,
2024-08-05 16:28:35 -05:00
help_heading = " Index options "
) ]
2024-06-24 13:16:22 +03:00
pub index_strategy : Option < IndexStrategy > ,
2024-06-13 17:56:38 -07:00
/// Attempt to use `keyring` for authentication for index URLs.
///
2024-07-16 16:50:04 -04:00
/// At present, only `--keyring-provider subprocess` is supported, which configures uv to
2024-06-13 17:56:38 -07:00
/// use the `keyring` CLI to handle authentication.
///
/// Defaults to `disabled`.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_KEYRING_PROVIDER,
2024-08-05 16:28:35 -05:00
help_heading = " Index options "
) ]
2024-06-24 13:16:22 +03:00
pub keyring_provider : Option < KeyringProviderType > ,
2024-06-13 17:56:38 -07:00
/// The strategy to use when selecting between the different compatible versions for a given
/// package requirement.
///
2024-07-16 16:50:04 -04:00
/// By default, uv will use the latest compatible version of each package (`highest`).
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_RESOLUTION,
2024-08-05 16:28:35 -05:00
help_heading = " Resolver options "
) ]
2024-06-24 13:16:22 +03:00
pub resolution : Option < ResolutionMode > ,
2024-06-13 17:56:38 -07:00
/// The strategy to use when considering pre-release versions.
///
2024-07-16 16:50:04 -04:00
/// By default, uv will accept pre-releases for packages that _only_ publish pre-releases,
2024-06-13 17:56:38 -07:00
/// along with first-party requirements that contain an explicit pre-release marker in the
/// declared specifiers (`if-necessary-or-explicit`).
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PRERELEASE,
2024-08-05 16:28:35 -05:00
help_heading = " Resolver options "
) ]
2024-08-01 16:56:29 -04:00
pub prerelease : Option < PrereleaseMode > ,
2024-06-13 17:56:38 -07:00
#[ arg(long, hide = true) ]
2024-06-24 13:16:22 +03:00
pub pre : bool ,
2024-06-13 17:56:38 -07:00
2024-12-13 16:05:07 -05:00
/// The strategy to use when selecting multiple versions of a given package across Python
/// versions and platforms.
///
/// By default, uv will optimize for selecting the latest version of each package for each
/// supported Python version (`requires-python`), while minimizing the number of selected
/// versions across platforms.
///
2024-12-13 16:35:20 -05:00
/// Under `fewest`, uv will minimize the number of selected versions for each package,
/// preferring older versions that are compatible with a wider range of supported Python
/// versions or platforms.
2024-12-13 16:05:07 -05:00
#[ arg(
long,
value_enum,
env = EnvVars::UV_FORK_STRATEGY,
help_heading = " Resolver options "
) ]
pub fork_strategy : Option < ForkStrategy > ,
2024-06-13 17:56:38 -07:00
/// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
short = 'C',
alias = " config-settings " ,
help_heading = " Build options "
) ]
2024-06-24 13:16:22 +03:00
pub config_setting : Option < Vec < ConfigSettingEntry > > ,
2024-06-13 17:56:38 -07:00
2024-08-06 17:11:48 -04:00
/// Disable isolation when building source distributions.
///
/// Assumes that build dependencies specified by PEP 518 are already installed.
#[ arg(
long,
overrides_with( " build_isolation " ),
help_heading = " Build options " ,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_NO_BUILD_ISOLATION,
2024-08-06 17:11:48 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
) ]
pub no_build_isolation : bool ,
2024-08-08 03:35:56 +02:00
/// Disable isolation when building source distributions for a specific package.
///
2024-09-24 04:15:06 +08:00
/// Assumes that the packages' build dependencies specified by PEP 518 are already installed.
2024-08-08 03:35:56 +02:00
#[ arg(long, help_heading = " Build options " ) ]
pub no_build_isolation_package : Vec < PackageName > ,
2024-08-06 17:11:48 -04:00
#[ arg(
long,
overrides_with( " no_build_isolation " ),
hide = true,
help_heading = " Build options "
) ]
pub build_isolation : bool ,
2024-06-13 17:56:38 -07:00
/// Limit candidate packages to those that were uploaded prior to the given date.
///
2024-08-19 10:36:00 -07:00
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
/// format (e.g., `2006-12-02`) in your system's configured time zone.
2024-10-14 21:48:13 +00:00
#[ arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = " Resolver options " ) ]
2024-06-24 13:16:22 +03:00
pub exclude_newer : Option < ExcludeNewer > ,
2024-06-13 17:56:38 -07:00
/// The method to use when installing packages from the global cache.
///
/// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
/// Windows.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
value_enum,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_LINK_MODE,
2024-08-05 16:28:35 -05:00
help_heading = " Installer options "
) ]
2024-10-01 20:45:39 -04:00
pub link_mode : Option < uv_install_wheel ::linker ::LinkMode > ,
2024-06-13 17:56:38 -07:00
2024-07-16 17:14:27 -04:00
/// Compile Python files to bytecode after installation.
2024-06-13 17:56:38 -07:00
///
2024-07-16 17:14:27 -04:00
/// By default, uv does not compile Python (`.py`) files to bytecode (`__pycache__/*.pyc`);
/// instead, compilation is performed lazily the first time a module is imported. For use-cases
/// in which start time is critical, such as CLI applications and Docker containers, this option
/// can be enabled to trade longer installation times for faster start times.
2024-06-13 17:56:38 -07:00
///
2024-07-16 17:14:27 -04:00
/// When enabled, uv will process the entire site-packages directory (including packages that
/// are not being modified by the current operation) for consistency. Like pip, it will also
/// ignore errors.
2024-08-05 16:28:35 -05:00
#[ arg(
long,
alias = " compile " ,
overrides_with( " no_compile_bytecode " ),
2024-08-23 14:05:32 -04:00
help_heading = " Installer options " ,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_COMPILE_BYTECODE,
2024-08-23 14:05:32 -04:00
value_parser = clap::builder::BoolishValueParser::new(),
2024-08-05 16:28:35 -05:00
) ]
2024-06-24 13:16:22 +03:00
pub compile_bytecode : bool ,
2024-06-13 17:56:38 -07:00
#[ arg(
long,
2024-06-23 20:25:50 +03:00
alias = " no-compile " ,
2024-06-13 17:56:38 -07:00
overrides_with( " compile_bytecode " ),
2024-08-05 16:28:35 -05:00
hide = true,
help_heading = " Installer options "
2024-06-13 17:56:38 -07:00
) ]
2024-06-24 13:16:22 +03:00
pub no_compile_bytecode : bool ,
2024-08-06 10:14:19 -04:00
/// Ignore the `tool.uv.sources` table when resolving dependencies. Used to lock against the
/// standards-compliant, publishable package metadata, as opposed to using any local or Git
/// sources.
2024-08-06 17:29:56 -04:00
#[ arg(long, help_heading = " Resolver options " ) ]
2024-08-06 10:14:19 -04:00
pub no_sources : bool ,
2024-06-13 17:56:38 -07:00
}
2024-07-08 14:07:48 -04:00
2024-11-08 09:52:32 -05:00
/// Arguments that are used by commands that need to fetch from the Simple API.
#[ derive(Args) ]
#[ allow(clippy::struct_excessive_bools) ]
pub struct FetchArgs {
#[ command(flatten) ]
pub index_args : IndexArgs ,
/// The strategy to use when resolving against multiple index URLs.
///
/// By default, uv will stop at the first index on which a given package is available, and
2024-12-19 12:40:14 -05:00
/// limit resolutions to those present on that first index (`first-index`). This prevents
2024-11-08 09:52:32 -05:00
/// "dependency confusion" attacks, whereby an attacker can upload a malicious package under the
/// same name to an alternate index.
#[ arg(
long,
value_enum,
env = EnvVars::UV_INDEX_STRATEGY,
help_heading = " Index options "
) ]
pub index_strategy : Option < IndexStrategy > ,
/// Attempt to use `keyring` for authentication for index URLs.
///
/// At present, only `--keyring-provider subprocess` is supported, which configures uv to
/// use the `keyring` CLI to handle authentication.
///
/// Defaults to `disabled`.
#[ arg(
long,
value_enum,
env = EnvVars::UV_KEYRING_PROVIDER,
help_heading = " Index options "
) ]
pub keyring_provider : Option < KeyringProviderType > ,
/// Limit candidate packages to those that were uploaded prior to the given date.
///
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
/// format (e.g., `2006-12-02`) in your system's configured time zone.
#[ arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = " Resolver options " ) ]
pub exclude_newer : Option < ExcludeNewer > ,
}
2024-07-08 14:07:48 -04:00
#[ derive(Args) ]
pub struct DisplayTreeArgs {
/// Maximum display depth of the dependency tree
#[ arg(long, short, default_value_t = 255) ]
pub depth : u8 ,
/// Prune the given package from the display of the dependency tree.
#[ arg(long) ]
pub prune : Vec < PackageName > ,
/// Display only the specified packages.
#[ arg(long) ]
pub package : Vec < PackageName > ,
/// Do not de-duplicate repeated dependencies.
/// Usually, when a package has already displayed its dependencies,
/// further occurrences will not re-display its dependencies,
/// and will include a (*) to indicate it has already been shown.
/// This flag will cause those duplicates to be repeated.
#[ arg(long) ]
pub no_dedupe : bool ,
2024-10-08 21:16:02 +02:00
/// Show the reverse dependencies for the given package. This flag will invert the tree and
/// display the packages that depend on the given package.
2024-07-08 14:07:48 -04:00
#[ arg(long, alias = " reverse " ) ]
pub invert : bool ,
2024-11-07 15:10:46 -05:00
/// Show the latest available version of each package in the tree.
#[ arg(long) ]
pub outdated : bool ,
2024-07-08 14:07:48 -04:00
}
2024-09-24 17:33:06 +02:00
#[ derive(Args, Debug) ]
pub struct PublishArgs {
/// Paths to the files to upload. Accepts glob expressions.
///
/// Defaults to the `dist` directory. Selects only wheels and source distributions, while
/// ignoring other files.
#[ arg(default_value = " dist/* " ) ]
pub files : Vec < String > ,
2024-12-10 22:17:47 +01:00
/// The name of an index in the configuration to use for publishing.
2024-09-24 17:33:06 +02:00
///
2024-12-10 22:17:47 +01:00
/// The index must have a `publish-url` setting, for example:
2024-09-24 17:33:06 +02:00
///
2024-12-10 22:17:47 +01:00
/// ```toml
/// [[tool.uv.index]]
/// name = "pypi"
/// url = "https://pypi.org/simple"
/// publish-url = "https://upload.pypi.org/legacy/"
/// ```
///
/// The index `url` will be used to check for existing files to skip duplicate uploads.
///
/// With these settings, the following two calls are equivalent:
///
/// ```
/// uv publish --index pypi
/// uv publish --publish-url https://upload.pypi.org/legacy/ --check-url https://pypi.org/simple
/// ```
#[ arg(
long,
env = EnvVars::UV_PUBLISH_INDEX,
conflicts_with = " publish_url " ,
conflicts_with = " check_url "
) ]
pub index : Option < String > ,
2024-09-24 17:33:06 +02:00
/// The username for the upload.
2024-10-14 21:48:13 +00:00
#[ arg(short, long, env = EnvVars::UV_PUBLISH_USERNAME) ]
2024-09-24 17:33:06 +02:00
pub username : Option < String > ,
/// The password for the upload.
2024-10-14 21:48:13 +00:00
#[ arg(short, long, env = EnvVars::UV_PUBLISH_PASSWORD) ]
2024-09-24 17:33:06 +02:00
pub password : Option < String > ,
/// The token for the upload.
///
2024-11-19 13:01:17 +01:00
/// Using a token is equivalent to passing `__token__` as `--username` and the token as
/// `--password` password.
2024-09-24 17:33:06 +02:00
#[ arg(
short,
long,
2024-10-14 21:48:13 +00:00
env = EnvVars::UV_PUBLISH_TOKEN,
2024-09-24 17:33:06 +02:00
conflicts_with = " username " ,
conflicts_with = " password "
) ]
pub token : Option < String > ,
2024-09-24 18:07:20 +02:00
/// Configure using trusted publishing through GitHub Actions.
///
/// By default, uv checks for trusted publishing when running in GitHub Actions, but ignores it
/// if it isn't configured or the workflow doesn't have enough permissions (e.g., a pull request
/// from a fork).
#[ arg(long) ]
pub trusted_publishing : Option < TrustedPublishing > ,
2024-09-24 17:33:06 +02:00
/// Attempt to use `keyring` for authentication for remote requirements files.
///
/// At present, only `--keyring-provider subprocess` is supported, which configures uv to
/// use the `keyring` CLI to handle authentication.
///
/// Defaults to `disabled`.
2024-10-14 21:48:13 +00:00
#[ arg(long, value_enum, env = EnvVars::UV_KEYRING_PROVIDER) ]
2024-09-24 17:33:06 +02:00
pub keyring_provider : Option < KeyringProviderType > ,
2024-12-10 22:17:47 +01:00
/// The URL of the upload endpoint (not the index URL).
///
/// Note that there are typically different URLs for index access (e.g., `https:://.../simple`)
/// and index upload.
///
/// Defaults to PyPI's publish URL (<https://upload.pypi.org/legacy/>).
#[ arg(long, env = EnvVars::UV_PUBLISH_URL) ]
pub publish_url : Option < Url > ,
2024-10-31 16:23:12 +01:00
/// Check an index URL for existing files to skip duplicate uploads.
///
/// This option allows retrying publishing that failed after only some, but not all files have
/// been uploaded, and handles error due to parallel uploads of the same file.
///
/// Before uploading, the index is checked. If the exact same file already exists in the index,
/// the file will not be uploaded. If an error occurred during the upload, the index is checked
/// again, to handle cases where the identical file was uploaded twice in parallel.
///
/// The exact behavior will vary based on the index. When uploading to PyPI, uploading the same
/// file succeeds even without `--check-url`, while most other indexes error.
///
/// The index must provide one of the supported hashes (SHA-256, SHA-384, or SHA-512).
2024-11-05 00:21:01 +01:00
#[ arg(long, env = EnvVars::UV_PUBLISH_CHECK_URL) ]
2024-10-31 16:23:12 +01:00
pub check_url : Option < IndexUrl > ,
2024-11-05 00:21:01 +01:00
#[ arg(long, hide = true) ]
pub skip_existing : bool ,
2024-09-24 17:33:06 +02:00
}
2024-09-24 19:23:17 +02:00
/// See [PEP 517](https://peps.python.org/pep-0517/) and
/// [PEP 660](https://peps.python.org/pep-0660/) for specifications of the parameters.
#[ derive(Subcommand) ]
pub enum BuildBackendCommand {
/// PEP 517 hook `build_sdist`.
BuildSdist { sdist_directory : PathBuf } ,
/// PEP 517 hook `build_wheel`.
BuildWheel {
wheel_directory : PathBuf ,
#[ arg(long) ]
metadata_directory : Option < PathBuf > ,
} ,
/// PEP 660 hook `build_editable`.
BuildEditable {
wheel_directory : PathBuf ,
#[ arg(long) ]
metadata_directory : Option < PathBuf > ,
} ,
/// PEP 517 hook `get_requires_for_build_sdist`.
GetRequiresForBuildSdist ,
/// PEP 517 hook `get_requires_for_build_wheel`.
GetRequiresForBuildWheel ,
/// PEP 517 hook `prepare_metadata_for_build_wheel`.
PrepareMetadataForBuildWheel { wheel_directory : PathBuf } ,
/// PEP 660 hook `get_requires_for_build_editable`.
GetRequiresForBuildEditable ,
/// PEP 660 hook `prepare_metadata_for_build_editable`.
PrepareMetadataForBuildEditable { wheel_directory : PathBuf } ,
}