uv_cli/
lib.rs

1use std::ffi::OsString;
2use std::fmt::{self, Display, Formatter};
3use std::ops::{Deref, DerefMut};
4use std::path::PathBuf;
5use std::str::FromStr;
6
7use anyhow::{Result, anyhow};
8use clap::ValueEnum;
9use clap::builder::styling::{AnsiColor, Effects, Style};
10use clap::builder::{PossibleValue, Styles, TypedValueParser, ValueParserFactory};
11use clap::error::ErrorKind;
12use clap::{Args, Parser, Subcommand};
13
14use uv_auth::Service;
15use uv_cache::CacheArgs;
16use uv_configuration::{
17    ExportFormat, IndexStrategy, KeyringProviderType, PackageNameSpecifier, PipCompileFormat,
18    ProjectBuildBackend, TargetTriple, TrustedHost, TrustedPublishing, VersionControlSystem,
19};
20use uv_distribution_types::{
21    ConfigSettingEntry, ConfigSettingPackageEntry, Index, IndexUrl, Origin, PipExtraIndex,
22    PipFindLinks, PipIndex,
23};
24use uv_normalize::{ExtraName, GroupName, PackageName, PipGroupName};
25use uv_pep508::{MarkerTree, Requirement};
26use uv_preview::PreviewFeatures;
27use uv_pypi_types::VerbatimParsedUrl;
28use uv_python::{PythonDownloads, PythonPreference, PythonVersion};
29use uv_redacted::DisplaySafeUrl;
30use uv_resolver::{
31    AnnotationStyle, ExcludeNewerPackageEntry, ExcludeNewerTimestamp, ForkStrategy, PrereleaseMode,
32    ResolutionMode,
33};
34use uv_settings::PythonInstallMirrors;
35use uv_static::EnvVars;
36use uv_torch::TorchMode;
37use uv_workspace::pyproject_mut::AddBoundsKind;
38
39pub mod comma;
40pub mod compat;
41pub mod options;
42pub mod version;
43
44#[derive(Debug, Clone, Copy, clap::ValueEnum)]
45pub enum VersionFormat {
46    /// Display the version as plain text.
47    Text,
48    /// Display the version as JSON.
49    Json,
50}
51
52#[derive(Debug, Default, Clone, Copy, clap::ValueEnum)]
53pub enum PythonListFormat {
54    /// Plain text (for humans).
55    #[default]
56    Text,
57    /// JSON (for computers).
58    Json,
59}
60
61#[derive(Debug, Default, Clone, Copy, clap::ValueEnum)]
62pub enum SyncFormat {
63    /// Display the result in a human-readable format.
64    #[default]
65    Text,
66    /// Display the result in JSON format.
67    Json,
68}
69
70#[derive(Debug, Default, Clone, clap::ValueEnum)]
71pub enum ListFormat {
72    /// Display the list of packages in a human-readable table.
73    #[default]
74    Columns,
75    /// Display the list of packages in a `pip freeze`-like format, with one package per line
76    /// alongside its version.
77    Freeze,
78    /// Display the list of packages in a machine-readable JSON format.
79    Json,
80}
81
82fn extra_name_with_clap_error(arg: &str) -> Result<ExtraName> {
83    ExtraName::from_str(arg).map_err(|_err| {
84        anyhow!(
85            "Extra names must start and end with a letter or digit and may only \
86            contain -, _, ., and alphanumeric characters"
87        )
88    })
89}
90
91// Configures Clap v3-style help menu colors
92const STYLES: Styles = Styles::styled()
93    .header(AnsiColor::Green.on_default().effects(Effects::BOLD))
94    .usage(AnsiColor::Green.on_default().effects(Effects::BOLD))
95    .literal(AnsiColor::Cyan.on_default().effects(Effects::BOLD))
96    .placeholder(AnsiColor::Cyan.on_default());
97
98#[derive(Parser)]
99#[command(name = "uv", author, long_version = crate::version::uv_self_version())]
100#[command(about = "An extremely fast Python package manager.")]
101#[command(
102    after_help = "Use `uv help` for more details.",
103    after_long_help = "",
104    disable_help_flag = true,
105    disable_help_subcommand = true,
106    disable_version_flag = true
107)]
108#[command(styles=STYLES)]
109pub struct Cli {
110    #[command(subcommand)]
111    pub command: Box<Commands>,
112
113    #[command(flatten)]
114    pub top_level: TopLevelArgs,
115}
116
117#[derive(Parser)]
118#[command(disable_help_flag = true, disable_version_flag = true)]
119pub struct TopLevelArgs {
120    #[command(flatten)]
121    pub cache_args: Box<CacheArgs>,
122
123    #[command(flatten)]
124    pub global_args: Box<GlobalArgs>,
125
126    /// The path to a `uv.toml` file to use for configuration.
127    ///
128    /// While uv configuration can be included in a `pyproject.toml` file, it is
129    /// not allowed in this context.
130    #[arg(
131        global = true,
132        long,
133        env = EnvVars::UV_CONFIG_FILE,
134        help_heading = "Global options"
135    )]
136    pub config_file: Option<PathBuf>,
137
138    /// Avoid discovering configuration files (`pyproject.toml`, `uv.toml`).
139    ///
140    /// Normally, configuration files are discovered in the current directory,
141    /// parent directories, or user configuration directories.
142    #[arg(global = true, long, env = EnvVars::UV_NO_CONFIG, value_parser = clap::builder::BoolishValueParser::new(), help_heading = "Global options")]
143    pub no_config: bool,
144
145    /// Display the concise help for this command.
146    #[arg(global = true, short, long, action = clap::ArgAction::HelpShort, help_heading = "Global options")]
147    help: Option<bool>,
148
149    /// Display the uv version.
150    #[arg(short = 'V', long, action = clap::ArgAction::Version)]
151    version: Option<bool>,
152}
153
154#[derive(Parser, Debug, Clone)]
155#[command(next_help_heading = "Global options", next_display_order = 1000)]
156pub struct GlobalArgs {
157    #[arg(
158        global = true,
159        long,
160        help_heading = "Python options",
161        display_order = 700,
162        env = EnvVars::UV_PYTHON_PREFERENCE,
163        hide = true
164    )]
165    pub python_preference: Option<PythonPreference>,
166
167    /// Require use of uv-managed Python versions.
168    ///
169    /// By default, uv prefers using Python versions it manages. However, it
170    /// will use system Python versions if a uv-managed Python is not
171    /// installed. This option disables use of system Python versions.
172    #[arg(
173        global = true,
174        long,
175        help_heading = "Python options",
176        env = EnvVars::UV_MANAGED_PYTHON,
177        value_parser = clap::builder::BoolishValueParser::new(),
178        overrides_with = "no_managed_python",
179        conflicts_with = "python_preference"
180    )]
181    pub managed_python: bool,
182
183    /// Disable use of uv-managed Python versions.
184    ///
185    /// Instead, uv will search for a suitable Python version on the system.
186    #[arg(
187        global = true,
188        long,
189        help_heading = "Python options",
190        env = EnvVars::UV_NO_MANAGED_PYTHON,
191        value_parser = clap::builder::BoolishValueParser::new(),
192        overrides_with = "managed_python",
193        conflicts_with = "python_preference"
194    )]
195    pub no_managed_python: bool,
196
197    #[allow(clippy::doc_markdown)]
198    /// Allow automatically downloading Python when required. [env: "UV_PYTHON_DOWNLOADS=auto"]
199    #[arg(global = true, long, help_heading = "Python options", hide = true)]
200    pub allow_python_downloads: bool,
201
202    #[allow(clippy::doc_markdown)]
203    /// Disable automatic downloads of Python. [env: "UV_PYTHON_DOWNLOADS=never"]
204    #[arg(global = true, long, help_heading = "Python options")]
205    pub no_python_downloads: bool,
206
207    /// Deprecated version of [`Self::python_downloads`].
208    #[arg(global = true, long, hide = true)]
209    pub python_fetch: Option<PythonDownloads>,
210
211    /// Use quiet output.
212    ///
213    /// Repeating this option, e.g., `-qq`, will enable a silent mode in which
214    /// uv will write no output to stdout.
215    #[arg(global = true, action = clap::ArgAction::Count, long, short, conflicts_with = "verbose")]
216    pub quiet: u8,
217
218    /// Use verbose output.
219    ///
220    /// You can configure fine-grained logging using the `RUST_LOG` environment variable.
221    /// (<https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives>)
222    #[arg(global = true, action = clap::ArgAction::Count, long, short, conflicts_with = "quiet")]
223    pub verbose: u8,
224
225    /// Disable colors.
226    ///
227    /// Provided for compatibility with `pip`, use `--color` instead.
228    #[arg(global = true, long, hide = true, conflicts_with = "color")]
229    pub no_color: bool,
230
231    /// Control the use of color in output.
232    ///
233    /// By default, uv will automatically detect support for colors when writing to a terminal.
234    #[arg(
235        global = true,
236        long,
237        value_enum,
238        conflicts_with = "no_color",
239        value_name = "COLOR_CHOICE"
240    )]
241    pub color: Option<ColorChoice>,
242
243    /// Whether to load TLS certificates from the platform's native certificate store.
244    ///
245    /// By default, uv loads certificates from the bundled `webpki-roots` crate. The
246    /// `webpki-roots` are a reliable set of trust roots from Mozilla, and including them in uv
247    /// improves portability and performance (especially on macOS).
248    ///
249    /// However, in some cases, you may want to use the platform's native certificate store,
250    /// especially if you're relying on a corporate trust root (e.g., for a mandatory proxy) that's
251    /// included in your system's certificate store.
252    #[arg(global = true, long, env = EnvVars::UV_NATIVE_TLS, value_parser = clap::builder::BoolishValueParser::new(), overrides_with("no_native_tls"))]
253    pub native_tls: bool,
254
255    #[arg(global = true, long, overrides_with("native_tls"), hide = true)]
256    pub no_native_tls: bool,
257
258    /// Disable network access.
259    ///
260    /// When disabled, uv will only use locally cached data and locally available files.
261    #[arg(global = true, long, overrides_with("no_offline"), env = EnvVars::UV_OFFLINE, value_parser = clap::builder::BoolishValueParser::new())]
262    pub offline: bool,
263
264    #[arg(global = true, long, overrides_with("offline"), hide = true)]
265    pub no_offline: bool,
266
267    /// Allow insecure connections to a host.
268    ///
269    /// Can be provided multiple times.
270    ///
271    /// Expects to receive either a hostname (e.g., `localhost`), a host-port pair (e.g.,
272    /// `localhost:8080`), or a URL (e.g., `https://localhost`).
273    ///
274    /// WARNING: Hosts included in this list will not be verified against the system's certificate
275    /// store. Only use `--allow-insecure-host` in a secure network with verified sources, as it
276    /// bypasses SSL verification and could expose you to MITM attacks.
277    #[arg(
278        global = true,
279        long,
280        alias = "trusted-host",
281        env = EnvVars::UV_INSECURE_HOST,
282        value_delimiter = ' ',
283        value_parser = parse_insecure_host,
284    )]
285    pub allow_insecure_host: Option<Vec<Maybe<TrustedHost>>>,
286
287    /// Whether to enable all experimental preview features.
288    ///
289    /// Preview features may change without warning.
290    #[arg(global = true, long, hide = true, env = EnvVars::UV_PREVIEW, value_parser = clap::builder::BoolishValueParser::new(), overrides_with("no_preview"))]
291    pub preview: bool,
292
293    #[arg(global = true, long, overrides_with("preview"), hide = true)]
294    pub no_preview: bool,
295
296    /// Enable experimental preview features.
297    ///
298    /// Preview features may change without warning.
299    ///
300    /// Use comma-separated values or pass multiple times to enable multiple features.
301    ///
302    /// The following features are available: `python-install-default`, `python-upgrade`,
303    /// `json-output`, `pylock`, `add-bounds`.
304    #[arg(
305        global = true,
306        long = "preview-features",
307        env = EnvVars::UV_PREVIEW_FEATURES,
308        value_delimiter = ',',
309        hide = true,
310        alias = "preview-feature",
311        value_enum,
312    )]
313    pub preview_features: Vec<PreviewFeatures>,
314
315    /// Avoid discovering a `pyproject.toml` or `uv.toml` file.
316    ///
317    /// Normally, configuration files are discovered in the current directory,
318    /// parent directories, or user configuration directories.
319    ///
320    /// This option is deprecated in favor of `--no-config`.
321    #[arg(global = true, long, hide = true, env = EnvVars::UV_ISOLATED, value_parser = clap::builder::BoolishValueParser::new())]
322    pub isolated: bool,
323
324    /// Show the resolved settings for the current command.
325    ///
326    /// This option is used for debugging and development purposes.
327    #[arg(global = true, long, hide = true)]
328    pub show_settings: bool,
329
330    /// Hide all progress outputs.
331    ///
332    /// For example, spinners or progress bars.
333    #[arg(global = true, long, env = EnvVars::UV_NO_PROGRESS, value_parser = clap::builder::BoolishValueParser::new())]
334    pub no_progress: bool,
335
336    /// Skip writing `uv` installer metadata files (e.g., `INSTALLER`, `REQUESTED`, and `direct_url.json`) to site-packages `.dist-info` directories.
337    #[arg(global = true, long, hide = true, env = EnvVars::UV_NO_INSTALLER_METADATA, value_parser = clap::builder::BoolishValueParser::new())]
338    pub no_installer_metadata: bool,
339
340    /// Change to the given directory prior to running the command.
341    ///
342    /// Relative paths are resolved with the given directory as the base.
343    ///
344    /// See `--project` to only change the project root directory.
345    #[arg(global = true, long, env = EnvVars::UV_WORKING_DIR)]
346    pub directory: Option<PathBuf>,
347
348    /// Run the command within the given project directory.
349    ///
350    /// All `pyproject.toml`, `uv.toml`, and `.python-version` files will be discovered by walking
351    /// up the directory tree from the project root, as will the project's virtual environment
352    /// (`.venv`).
353    ///
354    /// Other command-line arguments (such as relative paths) will be resolved relative
355    /// to the current working directory.
356    ///
357    /// See `--directory` to change the working directory entirely.
358    ///
359    /// This setting has no effect when used in the `uv pip` interface.
360    #[arg(global = true, long, env = EnvVars::UV_PROJECT)]
361    pub project: Option<PathBuf>,
362}
363
364#[derive(Debug, Copy, Clone, clap::ValueEnum)]
365pub enum ColorChoice {
366    /// Enables colored output only when the output is going to a terminal or TTY with support.
367    Auto,
368
369    /// Enables colored output regardless of the detected environment.
370    Always,
371
372    /// Disables colored output.
373    Never,
374}
375
376impl ColorChoice {
377    /// Combine self (higher priority) with an [`anstream::ColorChoice`] (lower priority).
378    ///
379    /// This method allows prioritizing the user choice, while using the inferred choice for a
380    /// stream as default.
381    #[must_use]
382    pub fn and_colorchoice(self, next: anstream::ColorChoice) -> Self {
383        match self {
384            Self::Auto => match next {
385                anstream::ColorChoice::Auto => Self::Auto,
386                anstream::ColorChoice::Always | anstream::ColorChoice::AlwaysAnsi => Self::Always,
387                anstream::ColorChoice::Never => Self::Never,
388            },
389            Self::Always | Self::Never => self,
390        }
391    }
392}
393
394impl From<ColorChoice> for anstream::ColorChoice {
395    fn from(value: ColorChoice) -> Self {
396        match value {
397            ColorChoice::Auto => Self::Auto,
398            ColorChoice::Always => Self::Always,
399            ColorChoice::Never => Self::Never,
400        }
401    }
402}
403
404#[derive(Subcommand)]
405#[allow(clippy::large_enum_variant)]
406pub enum Commands {
407    /// Manage authentication.
408    #[command(
409        after_help = "Use `uv help auth` for more details.",
410        after_long_help = ""
411    )]
412    Auth(AuthNamespace),
413
414    /// Manage Python projects.
415    #[command(flatten)]
416    Project(Box<ProjectCommand>),
417
418    /// Run and install commands provided by Python packages.
419    #[command(
420        after_help = "Use `uv help tool` for more details.",
421        after_long_help = ""
422    )]
423    Tool(ToolNamespace),
424
425    /// Manage Python versions and installations
426    ///
427    /// Generally, uv first searches for Python in a virtual environment, either active or in a
428    /// `.venv` directory in the current working directory or any parent directory. If a virtual
429    /// environment is not required, uv will then search for a Python interpreter. Python
430    /// interpreters are found by searching for Python executables in the `PATH` environment
431    /// variable.
432    ///
433    /// On Windows, the registry is also searched for Python executables.
434    ///
435    /// By default, uv will download Python if a version cannot be found. This behavior can be
436    /// disabled with the `--no-python-downloads` flag or the `python-downloads` setting.
437    ///
438    /// The `--python` option allows requesting a different interpreter.
439    ///
440    /// The following Python version request formats are supported:
441    ///
442    /// - `<version>` e.g. `3`, `3.12`, `3.12.3`
443    /// - `<version-specifier>` e.g. `>=3.12,<3.13`
444    /// - `<version><short-variant>` (e.g., `3.13t`, `3.12.0d`)
445    /// - `<version>+<variant>` (e.g., `3.13+freethreaded`, `3.12.0+debug`)
446    /// - `<implementation>` e.g. `cpython` or `cp`
447    /// - `<implementation>@<version>` e.g. `cpython@3.12`
448    /// - `<implementation><version>` e.g. `cpython3.12` or `cp312`
449    /// - `<implementation><version-specifier>` e.g. `cpython>=3.12,<3.13`
450    /// - `<implementation>-<version>-<os>-<arch>-<libc>` e.g. `cpython-3.12.3-macos-aarch64-none`
451    ///
452    /// Additionally, a specific system Python interpreter can often be requested with:
453    ///
454    /// - `<executable-path>` e.g. `/opt/homebrew/bin/python3`
455    /// - `<executable-name>` e.g. `mypython3`
456    /// - `<install-dir>` e.g. `/some/environment/`
457    ///
458    /// When the `--python` option is used, normal discovery rules apply but discovered interpreters
459    /// are checked for compatibility with the request, e.g., if `pypy` is requested, uv will first
460    /// check if the virtual environment contains a PyPy interpreter then check if each executable
461    /// in the path is a PyPy interpreter.
462    ///
463    /// uv supports discovering CPython, PyPy, and GraalPy interpreters. Unsupported interpreters
464    /// will be skipped during discovery. If an unsupported interpreter implementation is requested,
465    /// uv will exit with an error.
466    #[clap(verbatim_doc_comment)]
467    #[command(
468        after_help = "Use `uv help python` for more details.",
469        after_long_help = ""
470    )]
471    Python(PythonNamespace),
472    /// Manage Python packages with a pip-compatible interface.
473    #[command(
474        after_help = "Use `uv help pip` for more details.",
475        after_long_help = ""
476    )]
477    Pip(PipNamespace),
478    /// Create a virtual environment.
479    ///
480    /// By default, creates a virtual environment named `.venv` in the working
481    /// directory. An alternative path may be provided positionally.
482    ///
483    /// If in a project, the default environment name can be changed with
484    /// the `UV_PROJECT_ENVIRONMENT` environment variable; this only applies
485    /// when run from the project root directory.
486    ///
487    /// If a virtual environment exists at the target path, it will be removed
488    /// and a new, empty virtual environment will be created.
489    ///
490    /// When using uv, the virtual environment does not need to be activated. uv
491    /// will find a virtual environment (named `.venv`) in the working directory
492    /// or any parent directories.
493    #[command(
494        alias = "virtualenv",
495        alias = "v",
496        after_help = "Use `uv help venv` for more details.",
497        after_long_help = ""
498    )]
499    Venv(VenvArgs),
500    /// Build Python packages into source distributions and wheels.
501    ///
502    /// `uv build` accepts a path to a directory or source distribution,
503    /// which defaults to the current working directory.
504    ///
505    /// By default, if passed a directory, `uv build` will build a source
506    /// distribution ("sdist") from the source directory, and a binary
507    /// distribution ("wheel") from the source distribution.
508    ///
509    /// `uv build --sdist` can be used to build only the source distribution,
510    /// `uv build --wheel` can be used to build only the binary distribution,
511    /// and `uv build --sdist --wheel` can be used to build both distributions
512    /// from source.
513    ///
514    /// If passed a source distribution, `uv build --wheel` will build a wheel
515    /// from the source distribution.
516    #[command(
517        after_help = "Use `uv help build` for more details.",
518        after_long_help = ""
519    )]
520    Build(BuildArgs),
521    /// Upload distributions to an index.
522    Publish(PublishArgs),
523    /// Inspect uv workspaces.
524    #[command(
525        after_help = "Use `uv help workspace` for more details.",
526        after_long_help = "",
527        hide = true
528    )]
529    Workspace(WorkspaceNamespace),
530    /// The implementation of the build backend.
531    ///
532    /// These commands are not directly exposed to the user, instead users invoke their build
533    /// frontend (PEP 517) which calls the Python shims which calls back into uv with this method.
534    #[command(hide = true)]
535    BuildBackend {
536        #[command(subcommand)]
537        command: BuildBackendCommand,
538    },
539    /// Manage uv's cache.
540    #[command(
541        after_help = "Use `uv help cache` for more details.",
542        after_long_help = ""
543    )]
544    Cache(CacheNamespace),
545    /// Manage the uv executable.
546    #[command(name = "self")]
547    Self_(SelfNamespace),
548    /// Clear the cache, removing all entries or those linked to specific packages.
549    #[command(hide = true)]
550    Clean(CleanArgs),
551    /// Generate shell completion
552    #[command(alias = "--generate-shell-completion", hide = true)]
553    GenerateShellCompletion(GenerateShellCompletionArgs),
554    /// Display documentation for a command.
555    // To avoid showing the global options when displaying help for the help command, we are
556    // responsible for maintaining the options using the `after_help`.
557    #[command(help_template = "\
558{about-with-newline}
559{usage-heading} {usage}{after-help}
560",
561        after_help = format!("\
562{heading}Options:{heading:#}
563  {option}--no-pager{option:#} Disable pager when printing help
564",
565            heading = Style::new().bold().underline(),
566            option = Style::new().bold(),
567        ),
568    )]
569    Help(HelpArgs),
570}
571
572#[derive(Args, Debug)]
573pub struct HelpArgs {
574    /// Disable pager when printing help
575    #[arg(long)]
576    pub no_pager: bool,
577
578    pub command: Option<Vec<String>>,
579}
580
581#[derive(Args)]
582#[command(group = clap::ArgGroup::new("operation"))]
583pub struct VersionArgs {
584    /// Set the project version to this value
585    ///
586    /// To update the project using semantic versioning components instead, use `--bump`.
587    #[arg(group = "operation")]
588    pub value: Option<String>,
589
590    /// Update the project version using the given semantics
591    ///
592    /// This flag can be passed multiple times.
593    #[arg(group = "operation", long, value_name = "BUMP[=VALUE]")]
594    pub bump: Vec<VersionBumpSpec>,
595
596    /// Don't write a new version to the `pyproject.toml`
597    ///
598    /// Instead, the version will be displayed.
599    #[arg(long)]
600    pub dry_run: bool,
601
602    /// Only show the version
603    ///
604    /// By default, uv will show the project name before the version.
605    #[arg(long)]
606    pub short: bool,
607
608    /// The format of the output
609    #[arg(long, value_enum, default_value = "text")]
610    pub output_format: VersionFormat,
611
612    /// Avoid syncing the virtual environment after re-locking the project.
613    #[arg(long, env = EnvVars::UV_NO_SYNC, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")]
614    pub no_sync: bool,
615
616    /// Prefer the active virtual environment over the project's virtual environment.
617    ///
618    /// If the project virtual environment is active or no virtual environment is active, this has
619    /// no effect.
620    #[arg(long, overrides_with = "no_active")]
621    pub active: bool,
622
623    /// Prefer project's virtual environment over an active environment.
624    ///
625    /// This is the default behavior.
626    #[arg(long, overrides_with = "active", hide = true)]
627    pub no_active: bool,
628
629    /// Assert that the `uv.lock` will remain unchanged.
630    ///
631    /// Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated,
632    /// uv will exit with an error.
633    #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])]
634    pub locked: bool,
635
636    /// Update the version without re-locking the project.
637    ///
638    /// The project environment will not be synced.
639    #[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["locked", "upgrade", "no_sources"])]
640    pub frozen: bool,
641
642    #[command(flatten)]
643    pub installer: ResolverInstallerArgs,
644
645    #[command(flatten)]
646    pub build: BuildOptionsArgs,
647
648    #[command(flatten)]
649    pub refresh: RefreshArgs,
650
651    /// Update the version of a specific package in the workspace.
652    #[arg(long, conflicts_with = "isolated")]
653    pub package: Option<PackageName>,
654
655    /// The Python interpreter to use for resolving and syncing.
656    ///
657    /// See `uv help python` for details on Python discovery and supported request formats.
658    #[arg(
659        long,
660        short,
661        env = EnvVars::UV_PYTHON,
662        verbatim_doc_comment,
663        help_heading = "Python options",
664        value_parser = parse_maybe_string,
665    )]
666    pub python: Option<Maybe<String>>,
667}
668
669// Note that the ordering of the variants is significant, as when given a list of operations
670// to perform, we sort them and apply them in order, so users don't have to think too hard about it.
671#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)]
672pub enum VersionBump {
673    /// Increase the major version (e.g., 1.2.3 => 2.0.0)
674    Major,
675    /// Increase the minor version (e.g., 1.2.3 => 1.3.0)
676    Minor,
677    /// Increase the patch version (e.g., 1.2.3 => 1.2.4)
678    Patch,
679    /// Move from a pre-release to stable version (e.g., 1.2.3b4.post5.dev6 => 1.2.3)
680    ///
681    /// Removes all pre-release components, but will not remove "local" components.
682    Stable,
683    /// Increase the alpha version (e.g., 1.2.3a4 => 1.2.3a5)
684    ///
685    /// To move from a stable to a pre-release version, combine this with a stable component, e.g.,
686    /// for 1.2.3 => 2.0.0a1, you'd also include [`VersionBump::Major`].
687    Alpha,
688    /// Increase the beta version (e.g., 1.2.3b4 => 1.2.3b5)
689    ///
690    /// To move from a stable to a pre-release version, combine this with a stable component, e.g.,
691    /// for 1.2.3 => 2.0.0b1, you'd also include [`VersionBump::Major`].
692    Beta,
693    /// Increase the rc version (e.g., 1.2.3rc4 => 1.2.3rc5)
694    ///
695    /// To move from a stable to a pre-release version, combine this with a stable component, e.g.,
696    /// for 1.2.3 => 2.0.0rc1, you'd also include [`VersionBump::Major`].]
697    Rc,
698    /// Increase the post version (e.g., 1.2.3.post5 => 1.2.3.post6)
699    Post,
700    /// Increase the dev version (e.g., 1.2.3a4.dev6 => 1.2.3.dev7)
701    Dev,
702}
703
704impl Display for VersionBump {
705    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
706        let string = match self {
707            Self::Major => "major",
708            Self::Minor => "minor",
709            Self::Patch => "patch",
710            Self::Stable => "stable",
711            Self::Alpha => "alpha",
712            Self::Beta => "beta",
713            Self::Rc => "rc",
714            Self::Post => "post",
715            Self::Dev => "dev",
716        };
717        string.fmt(f)
718    }
719}
720
721impl FromStr for VersionBump {
722    type Err = String;
723
724    fn from_str(value: &str) -> Result<Self, Self::Err> {
725        match value {
726            "major" => Ok(Self::Major),
727            "minor" => Ok(Self::Minor),
728            "patch" => Ok(Self::Patch),
729            "stable" => Ok(Self::Stable),
730            "alpha" => Ok(Self::Alpha),
731            "beta" => Ok(Self::Beta),
732            "rc" => Ok(Self::Rc),
733            "post" => Ok(Self::Post),
734            "dev" => Ok(Self::Dev),
735            _ => Err(format!("invalid bump component `{value}`")),
736        }
737    }
738}
739
740#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
741pub struct VersionBumpSpec {
742    pub bump: VersionBump,
743    pub value: Option<u64>,
744}
745
746impl Display for VersionBumpSpec {
747    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
748        match self.value {
749            Some(value) => write!(f, "{}={value}", self.bump),
750            None => self.bump.fmt(f),
751        }
752    }
753}
754
755impl FromStr for VersionBumpSpec {
756    type Err = String;
757
758    fn from_str(input: &str) -> Result<Self, Self::Err> {
759        let (name, value) = match input.split_once('=') {
760            Some((name, value)) => (name, Some(value)),
761            None => (input, None),
762        };
763
764        let bump = name.parse::<VersionBump>()?;
765
766        if bump == VersionBump::Stable && value.is_some() {
767            return Err("`--bump stable` does not accept a value".to_string());
768        }
769
770        let value = match value {
771            Some("") => {
772                return Err("`--bump` values cannot be empty".to_string());
773            }
774            Some(raw) => Some(
775                raw.parse::<u64>()
776                    .map_err(|_| format!("invalid numeric value `{raw}` for `--bump {name}`"))?,
777            ),
778            None => None,
779        };
780
781        Ok(Self { bump, value })
782    }
783}
784
785impl ValueParserFactory for VersionBumpSpec {
786    type Parser = VersionBumpSpecValueParser;
787
788    fn value_parser() -> Self::Parser {
789        VersionBumpSpecValueParser
790    }
791}
792
793#[derive(Clone, Debug)]
794pub struct VersionBumpSpecValueParser;
795
796impl TypedValueParser for VersionBumpSpecValueParser {
797    type Value = VersionBumpSpec;
798
799    fn parse_ref(
800        &self,
801        _cmd: &clap::Command,
802        _arg: Option<&clap::Arg>,
803        value: &std::ffi::OsStr,
804    ) -> Result<Self::Value, clap::Error> {
805        let raw = value.to_str().ok_or_else(|| {
806            clap::Error::raw(
807                ErrorKind::InvalidUtf8,
808                "`--bump` values must be valid UTF-8",
809            )
810        })?;
811
812        VersionBumpSpec::from_str(raw)
813            .map_err(|message| clap::Error::raw(ErrorKind::InvalidValue, message))
814    }
815
816    fn possible_values(&self) -> Option<Box<dyn Iterator<Item = PossibleValue> + '_>> {
817        Some(Box::new(
818            VersionBump::value_variants()
819                .iter()
820                .filter_map(ValueEnum::to_possible_value),
821        ))
822    }
823}
824
825#[derive(Args)]
826pub struct SelfNamespace {
827    #[command(subcommand)]
828    pub command: SelfCommand,
829}
830
831#[derive(Subcommand)]
832pub enum SelfCommand {
833    /// Update uv.
834    Update(SelfUpdateArgs),
835    /// Display uv's version
836    Version {
837        /// Only print the version
838        #[arg(long)]
839        short: bool,
840        #[arg(long, value_enum, default_value = "text")]
841        output_format: VersionFormat,
842    },
843}
844
845#[derive(Args, Debug)]
846pub struct SelfUpdateArgs {
847    /// Update to the specified version. If not provided, uv will update to the latest version.
848    pub target_version: Option<String>,
849
850    /// A GitHub token for authentication.
851    /// A token is not required but can be used to reduce the chance of encountering rate limits.
852    #[arg(long, env = EnvVars::UV_GITHUB_TOKEN)]
853    pub token: Option<String>,
854
855    /// Run without performing the update.
856    #[arg(long)]
857    pub dry_run: bool,
858}
859
860#[derive(Args)]
861pub struct CacheNamespace {
862    #[command(subcommand)]
863    pub command: CacheCommand,
864}
865
866#[derive(Subcommand)]
867pub enum CacheCommand {
868    /// Clear the cache, removing all entries or those linked to specific packages.
869    Clean(CleanArgs),
870    /// Prune all unreachable objects from the cache.
871    Prune(PruneArgs),
872    /// Show the cache directory.
873    ///
874    /// By default, the cache is stored in `$XDG_CACHE_HOME/uv` or `$HOME/.cache/uv` on Unix and
875    /// `%LOCALAPPDATA%\uv\cache` on Windows.
876    ///
877    /// When `--no-cache` is used, the cache is stored in a temporary directory and discarded when
878    /// the process exits.
879    ///
880    /// An alternative cache directory may be specified via the `cache-dir` setting, the
881    /// `--cache-dir` option, or the `$UV_CACHE_DIR` environment variable.
882    ///
883    /// Note that it is important for performance for the cache directory to be located on the same
884    /// file system as the Python environment uv is operating on.
885    Dir,
886    /// Show the cache size.
887    ///
888    /// Displays the total size of the cache directory. This includes all downloaded and built
889    /// wheels, source distributions, and other cached data. By default, outputs the size in raw
890    /// bytes; use `--human` for human-readable output.
891    Size(SizeArgs),
892}
893
894#[derive(Args, Debug)]
895pub struct CleanArgs {
896    /// The packages to remove from the cache.
897    pub package: Vec<PackageName>,
898
899    /// Force removal of the cache, ignoring in-use checks.
900    ///
901    /// By default, `uv cache clean` will block until no process is reading the cache. When
902    /// `--force` is used, `uv cache clean` will proceed without taking a lock.
903    #[arg(long)]
904    pub force: bool,
905}
906
907#[derive(Args, Debug)]
908pub struct PruneArgs {
909    /// Optimize the cache for persistence in a continuous integration environment, like GitHub
910    /// Actions.
911    ///
912    /// By default, uv caches both the wheels that it builds from source and the pre-built wheels
913    /// that it downloads directly, to enable high-performance package installation. In some
914    /// scenarios, though, persisting pre-built wheels may be undesirable. For example, in GitHub
915    /// Actions, it's faster to omit pre-built wheels from the cache and instead have re-download
916    /// them on each run. However, it typically _is_ faster to cache wheels that are built from
917    /// source, since the wheel building process can be expensive, especially for extension
918    /// modules.
919    ///
920    /// In `--ci` mode, uv will prune any pre-built wheels from the cache, but retain any wheels
921    /// that were built from source.
922    #[arg(long)]
923    pub ci: bool,
924
925    /// Force removal of the cache, ignoring in-use checks.
926    ///
927    /// By default, `uv cache prune` will block until no process is reading the cache. When
928    /// `--force` is used, `uv cache prune` will proceed without taking a lock.
929    #[arg(long)]
930    pub force: bool,
931}
932
933#[derive(Args, Debug)]
934pub struct SizeArgs {
935    /// Display the cache size in human-readable format (e.g., `1.2 GiB` instead of raw bytes).
936    #[arg(long = "human", short = 'H', alias = "human-readable")]
937    pub human: bool,
938}
939
940#[derive(Args)]
941pub struct PipNamespace {
942    #[command(subcommand)]
943    pub command: PipCommand,
944}
945
946#[derive(Subcommand)]
947pub enum PipCommand {
948    /// Compile a `requirements.in` file to a `requirements.txt` or `pylock.toml` file.
949    #[command(
950        after_help = "Use `uv help pip compile` for more details.",
951        after_long_help = ""
952    )]
953    Compile(PipCompileArgs),
954    /// Sync an environment with a `requirements.txt` or `pylock.toml` file.
955    ///
956    /// When syncing an environment, any packages not listed in the `requirements.txt` or
957    /// `pylock.toml` file will be removed. To retain extraneous packages, use `uv pip install`
958    /// instead.
959    ///
960    /// The input file is presumed to be the output of a `pip compile` or `uv export` operation,
961    /// in which it will include all transitive dependencies. If transitive dependencies are not
962    /// present in the file, they will not be installed. Use `--strict` to warn if any transitive
963    /// dependencies are missing.
964    #[command(
965        after_help = "Use `uv help pip sync` for more details.",
966        after_long_help = ""
967    )]
968    Sync(Box<PipSyncArgs>),
969    /// Install packages into an environment.
970    #[command(
971        after_help = "Use `uv help pip install` for more details.",
972        after_long_help = ""
973    )]
974    Install(PipInstallArgs),
975    /// Uninstall packages from an environment.
976    #[command(
977        after_help = "Use `uv help pip uninstall` for more details.",
978        after_long_help = ""
979    )]
980    Uninstall(PipUninstallArgs),
981    /// List, in requirements format, packages installed in an environment.
982    #[command(
983        after_help = "Use `uv help pip freeze` for more details.",
984        after_long_help = ""
985    )]
986    Freeze(PipFreezeArgs),
987    /// List, in tabular format, packages installed in an environment.
988    #[command(
989        after_help = "Use `uv help pip list` for more details.",
990        after_long_help = "",
991        alias = "ls"
992    )]
993    List(PipListArgs),
994    /// Show information about one or more installed packages.
995    #[command(
996        after_help = "Use `uv help pip show` for more details.",
997        after_long_help = ""
998    )]
999    Show(PipShowArgs),
1000    /// Display the dependency tree for an environment.
1001    #[command(
1002        after_help = "Use `uv help pip tree` for more details.",
1003        after_long_help = ""
1004    )]
1005    Tree(PipTreeArgs),
1006    /// Verify installed packages have compatible dependencies.
1007    #[command(
1008        after_help = "Use `uv help pip check` for more details.",
1009        after_long_help = ""
1010    )]
1011    Check(PipCheckArgs),
1012}
1013
1014#[derive(Subcommand)]
1015pub enum ProjectCommand {
1016    /// Run a command or script.
1017    ///
1018    /// Ensures that the command runs in a Python environment.
1019    ///
1020    /// When used with a file ending in `.py` or an HTTP(S) URL, the file will be treated as a
1021    /// script and run with a Python interpreter, i.e., `uv run file.py` is equivalent to `uv run
1022    /// python file.py`. For URLs, the script is temporarily downloaded before execution. If the
1023    /// script contains inline dependency metadata, it will be installed into an isolated, ephemeral
1024    /// environment. When used with `-`, the input will be read from stdin, and treated as a Python
1025    /// script.
1026    ///
1027    /// When used in a project, the project environment will be created and updated before invoking
1028    /// the command.
1029    ///
1030    /// When used outside a project, if a virtual environment can be found in the current directory
1031    /// or a parent directory, the command will be run in that environment. Otherwise, the command
1032    /// will be run in the environment of the discovered interpreter.
1033    ///
1034    /// Arguments following the command (or script) are not interpreted as arguments to uv. All
1035    /// options to uv must be provided before the command, e.g., `uv run --verbose foo`. A `--` can
1036    /// be used to separate the command from uv options for clarity, e.g., `uv run --python 3.12 --
1037    /// python`.
1038    #[command(
1039        after_help = "Use `uv help run` for more details.",
1040        after_long_help = ""
1041    )]
1042    Run(RunArgs),
1043    /// Create a new project.
1044    ///
1045    /// Follows the `pyproject.toml` specification.
1046    ///
1047    /// If a `pyproject.toml` already exists at the target, uv will exit with an error.
1048    ///
1049    /// If a `pyproject.toml` is found in any of the parent directories of the target path, the
1050    /// project will be added as a workspace member of the parent.
1051    ///
1052    /// Some project state is not created until needed, e.g., the project virtual environment
1053    /// (`.venv`) and lockfile (`uv.lock`) are lazily created during the first sync.
1054    Init(InitArgs),
1055    /// Add dependencies to the project.
1056    ///
1057    /// Dependencies are added to the project's `pyproject.toml` file.
1058    ///
1059    /// If a given dependency exists already, it will be updated to the new version specifier unless
1060    /// it includes markers that differ from the existing specifier in which case another entry for
1061    /// the dependency will be added.
1062    ///
1063    /// The lockfile and project environment will be updated to reflect the added dependencies. To
1064    /// skip updating the lockfile, use `--frozen`. To skip updating the environment, use
1065    /// `--no-sync`.
1066    ///
1067    /// If any of the requested dependencies cannot be found, uv will exit with an error, unless the
1068    /// `--frozen` flag is provided, in which case uv will add the dependencies verbatim without
1069    /// checking that they exist or are compatible with the project.
1070    ///
1071    /// uv will search for a project in the current directory or any parent directory. If a project
1072    /// cannot be found, uv will exit with an error.
1073    #[command(
1074        after_help = "Use `uv help add` for more details.",
1075        after_long_help = ""
1076    )]
1077    Add(AddArgs),
1078    /// Remove dependencies from the project.
1079    ///
1080    /// Dependencies are removed from the project's `pyproject.toml` file.
1081    ///
1082    /// If multiple entries exist for a given dependency, i.e., each with different markers, all of
1083    /// the entries will be removed.
1084    ///
1085    /// The lockfile and project environment will be updated to reflect the removed dependencies. To
1086    /// skip updating the lockfile, use `--frozen`. To skip updating the environment, use
1087    /// `--no-sync`.
1088    ///
1089    /// If any of the requested dependencies are not present in the project, uv will exit with an
1090    /// error.
1091    ///
1092    /// If a package has been manually installed in the environment, i.e., with `uv pip install`, it
1093    /// will not be removed by `uv remove`.
1094    ///
1095    /// uv will search for a project in the current directory or any parent directory. If a project
1096    /// cannot be found, uv will exit with an error.
1097    #[command(
1098        after_help = "Use `uv help remove` for more details.",
1099        after_long_help = ""
1100    )]
1101    Remove(RemoveArgs),
1102    /// Read or update the project's version.
1103    Version(VersionArgs),
1104    /// Update the project's environment.
1105    ///
1106    /// Syncing ensures that all project dependencies are installed and up-to-date with the
1107    /// lockfile.
1108    ///
1109    /// By default, an exact sync is performed: uv removes packages that are not declared as
1110    /// dependencies of the project. Use the `--inexact` flag to keep extraneous packages. Note that
1111    /// if an extraneous package conflicts with a project dependency, it will still be removed.
1112    /// Additionally, if `--no-build-isolation` is used, uv will not remove extraneous packages to
1113    /// avoid removing possible build dependencies.
1114    ///
1115    /// If the project virtual environment (`.venv`) does not exist, it will be created.
1116    ///
1117    /// The project is re-locked before syncing unless the `--locked` or `--frozen` flag is
1118    /// provided.
1119    ///
1120    /// uv will search for a project in the current directory or any parent directory. If a project
1121    /// cannot be found, uv will exit with an error.
1122    ///
1123    /// Note that, when installing from a lockfile, uv will not provide warnings for yanked package
1124    /// versions.
1125    #[command(
1126        after_help = "Use `uv help sync` for more details.",
1127        after_long_help = ""
1128    )]
1129    Sync(SyncArgs),
1130    /// Update the project's lockfile.
1131    ///
1132    /// If the project lockfile (`uv.lock`) does not exist, it will be created. If a lockfile is
1133    /// present, its contents will be used as preferences for the resolution.
1134    ///
1135    /// If there are no changes to the project's dependencies, locking will have no effect unless
1136    /// the `--upgrade` flag is provided.
1137    #[command(
1138        after_help = "Use `uv help lock` for more details.",
1139        after_long_help = ""
1140    )]
1141    Lock(LockArgs),
1142    /// Export the project's lockfile to an alternate format.
1143    ///
1144    /// At present, both `requirements.txt` and `pylock.toml` (PEP 751) formats are supported.
1145    ///
1146    /// The project is re-locked before exporting unless the `--locked` or `--frozen` flag is
1147    /// provided.
1148    ///
1149    /// uv will search for a project in the current directory or any parent directory. If a project
1150    /// cannot be found, uv will exit with an error.
1151    ///
1152    /// If operating in a workspace, the root will be exported by default; however, specific
1153    /// members can be selected using the `--package` option.
1154    #[command(
1155        after_help = "Use `uv help export` for more details.",
1156        after_long_help = ""
1157    )]
1158    Export(ExportArgs),
1159    /// Display the project's dependency tree.
1160    Tree(TreeArgs),
1161    /// Format Python code in the project.
1162    ///
1163    /// Formats Python code using the Ruff formatter. By default, all Python files in the project
1164    /// are formatted. This command has the same behavior as running `ruff format` in the project
1165    /// root.
1166    ///
1167    /// To check if files are formatted without modifying them, use `--check`. To see a diff of
1168    /// formatting changes, use `--diff`.
1169    ///
1170    /// Additional arguments can be passed to Ruff after `--`.
1171    #[command(
1172        after_help = "Use `uv help format` for more details.",
1173        after_long_help = ""
1174    )]
1175    Format(FormatArgs),
1176}
1177
1178/// A re-implementation of `Option`, used to avoid Clap's automatic `Option` flattening in
1179/// [`parse_index_url`].
1180#[derive(Debug, Clone)]
1181pub enum Maybe<T> {
1182    Some(T),
1183    None,
1184}
1185
1186impl<T> Maybe<T> {
1187    pub fn into_option(self) -> Option<T> {
1188        match self {
1189            Self::Some(value) => Some(value),
1190            Self::None => None,
1191        }
1192    }
1193
1194    pub fn is_some(&self) -> bool {
1195        matches!(self, Self::Some(_))
1196    }
1197}
1198
1199/// Parse an `--index-url` argument into an [`PipIndex`], mapping the empty string to `None`.
1200fn parse_index_url(input: &str) -> Result<Maybe<PipIndex>, String> {
1201    if input.is_empty() {
1202        Ok(Maybe::None)
1203    } else {
1204        IndexUrl::from_str(input)
1205            .map(Index::from_index_url)
1206            .map(|index| Index {
1207                origin: Some(Origin::Cli),
1208                ..index
1209            })
1210            .map(PipIndex::from)
1211            .map(Maybe::Some)
1212            .map_err(|err| err.to_string())
1213    }
1214}
1215
1216/// Parse an `--extra-index-url` argument into an [`PipExtraIndex`], mapping the empty string to `None`.
1217fn parse_extra_index_url(input: &str) -> Result<Maybe<PipExtraIndex>, String> {
1218    if input.is_empty() {
1219        Ok(Maybe::None)
1220    } else {
1221        IndexUrl::from_str(input)
1222            .map(Index::from_extra_index_url)
1223            .map(|index| Index {
1224                origin: Some(Origin::Cli),
1225                ..index
1226            })
1227            .map(PipExtraIndex::from)
1228            .map(Maybe::Some)
1229            .map_err(|err| err.to_string())
1230    }
1231}
1232
1233/// Parse a `--find-links` argument into an [`PipFindLinks`], mapping the empty string to `None`.
1234fn parse_find_links(input: &str) -> Result<Maybe<PipFindLinks>, String> {
1235    if input.is_empty() {
1236        Ok(Maybe::None)
1237    } else {
1238        IndexUrl::from_str(input)
1239            .map(Index::from_find_links)
1240            .map(|index| Index {
1241                origin: Some(Origin::Cli),
1242                ..index
1243            })
1244            .map(PipFindLinks::from)
1245            .map(Maybe::Some)
1246            .map_err(|err| err.to_string())
1247    }
1248}
1249
1250/// Parse an `--index` argument into a [`Vec<Index>`], mapping the empty string to an empty Vec.
1251///
1252/// This function splits the input on all whitespace characters rather than a single delimiter,
1253/// which is necessary to parse environment variables like `PIP_EXTRA_INDEX_URL`.
1254/// The standard `clap::Args` `value_delimiter` only supports single-character delimiters.
1255fn parse_indices(input: &str) -> Result<Vec<Maybe<Index>>, String> {
1256    if input.trim().is_empty() {
1257        return Ok(Vec::new());
1258    }
1259    let mut indices = Vec::new();
1260    for token in input.split_whitespace() {
1261        match Index::from_str(token) {
1262            Ok(index) => indices.push(Maybe::Some(Index {
1263                default: false,
1264                origin: Some(Origin::Cli),
1265                ..index
1266            })),
1267            Err(e) => return Err(e.to_string()),
1268        }
1269    }
1270    Ok(indices)
1271}
1272
1273/// Parse a `--default-index` argument into an [`Index`], mapping the empty string to `None`.
1274fn parse_default_index(input: &str) -> Result<Maybe<Index>, String> {
1275    if input.is_empty() {
1276        Ok(Maybe::None)
1277    } else {
1278        match Index::from_str(input) {
1279            Ok(index) => Ok(Maybe::Some(Index {
1280                default: true,
1281                origin: Some(Origin::Cli),
1282                ..index
1283            })),
1284            Err(err) => Err(err.to_string()),
1285        }
1286    }
1287}
1288
1289/// Parse a string into an [`Url`], mapping the empty string to `None`.
1290fn parse_insecure_host(input: &str) -> Result<Maybe<TrustedHost>, String> {
1291    if input.is_empty() {
1292        Ok(Maybe::None)
1293    } else {
1294        match TrustedHost::from_str(input) {
1295            Ok(host) => Ok(Maybe::Some(host)),
1296            Err(err) => Err(err.to_string()),
1297        }
1298    }
1299}
1300
1301/// Parse a string into a [`PathBuf`]. The string can represent a file, either as a path or a
1302/// `file://` URL.
1303fn parse_file_path(input: &str) -> Result<PathBuf, String> {
1304    if input.starts_with("file://") {
1305        let url = match url::Url::from_str(input) {
1306            Ok(url) => url,
1307            Err(err) => return Err(err.to_string()),
1308        };
1309        url.to_file_path()
1310            .map_err(|()| "invalid file URL".to_string())
1311    } else {
1312        Ok(PathBuf::from(input))
1313    }
1314}
1315
1316/// Parse a string into a [`PathBuf`], mapping the empty string to `None`.
1317fn parse_maybe_file_path(input: &str) -> Result<Maybe<PathBuf>, String> {
1318    if input.is_empty() {
1319        Ok(Maybe::None)
1320    } else {
1321        parse_file_path(input).map(Maybe::Some)
1322    }
1323}
1324
1325// Parse a string, mapping the empty string to `None`.
1326#[allow(clippy::unnecessary_wraps)]
1327fn parse_maybe_string(input: &str) -> Result<Maybe<String>, String> {
1328    if input.is_empty() {
1329        Ok(Maybe::None)
1330    } else {
1331        Ok(Maybe::Some(input.to_string()))
1332    }
1333}
1334
1335#[derive(Args)]
1336#[command(group = clap::ArgGroup::new("sources").required(true).multiple(true))]
1337pub struct PipCompileArgs {
1338    /// Include the packages listed in the given files.
1339    ///
1340    /// The following formats are supported: `requirements.txt`, `.py` files with inline metadata,
1341    /// `pylock.toml`, `pyproject.toml`, `setup.py`, and `setup.cfg`.
1342    ///
1343    /// If a `pyproject.toml`, `setup.py`, or `setup.cfg` file is provided, uv will extract the
1344    /// requirements for the relevant project.
1345    ///
1346    /// If `-` is provided, then requirements will be read from stdin.
1347    ///
1348    /// The order of the requirements files and the requirements in them is used to determine
1349    /// priority during resolution.
1350    #[arg(group = "sources", value_parser = parse_file_path)]
1351    pub src_file: Vec<PathBuf>,
1352
1353    /// Constrain versions using the given requirements files.
1354    ///
1355    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
1356    /// requirement that's installed. However, including a package in a constraints file will _not_
1357    /// trigger the installation of that package.
1358    ///
1359    /// This is equivalent to pip's `--constraint` option.
1360    #[arg(long, short, alias = "constraint", env = EnvVars::UV_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
1361    pub constraints: Vec<Maybe<PathBuf>>,
1362
1363    /// Override versions using the given requirements files.
1364    ///
1365    /// Overrides files are `requirements.txt`-like files that force a specific version of a
1366    /// requirement to be installed, regardless of the requirements declared by any constituent
1367    /// package, and regardless of whether this would be considered an invalid resolution.
1368    ///
1369    /// While constraints are _additive_, in that they're combined with the requirements of the
1370    /// constituent packages, overrides are _absolute_, in that they completely replace the
1371    /// requirements of the constituent packages.
1372    #[arg(long, alias = "override", env = EnvVars::UV_OVERRIDE, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
1373    pub overrides: Vec<Maybe<PathBuf>>,
1374
1375    /// Exclude packages from resolution using the given requirements files.
1376    ///
1377    /// Excludes files are `requirements.txt`-like files that specify packages to exclude
1378    /// from the resolution. When a package is excluded, it will be omitted from the
1379    /// dependency list entirely and its own dependencies will be ignored during the resolution
1380    /// phase. Excludes are unconditional in that requirement specifiers and markers are ignored;
1381    /// any package listed in the provided file will be omitted from all resolved environments.
1382    #[arg(long, alias = "exclude", env = EnvVars::UV_EXCLUDE, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
1383    pub excludes: Vec<Maybe<PathBuf>>,
1384
1385    /// Constrain build dependencies using the given requirements files when building source
1386    /// distributions.
1387    ///
1388    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
1389    /// requirement that's installed. However, including a package in a constraints file will _not_
1390    /// trigger the installation of that package.
1391    #[arg(long, short, alias = "build-constraint", env = EnvVars::UV_BUILD_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
1392    pub build_constraints: Vec<Maybe<PathBuf>>,
1393
1394    /// Include optional dependencies from the specified extra name; may be provided more than once.
1395    ///
1396    /// Only applies to `pyproject.toml`, `setup.py`, and `setup.cfg` sources.
1397    #[arg(long, conflicts_with = "all_extras", value_parser = extra_name_with_clap_error)]
1398    pub extra: Option<Vec<ExtraName>>,
1399
1400    /// Include all optional dependencies.
1401    ///
1402    /// Only applies to `pyproject.toml`, `setup.py`, and `setup.cfg` sources.
1403    #[arg(long, conflicts_with = "extra")]
1404    pub all_extras: bool,
1405
1406    #[arg(long, overrides_with("all_extras"), hide = true)]
1407    pub no_all_extras: bool,
1408
1409    /// Install the specified dependency group from a `pyproject.toml`.
1410    ///
1411    /// If no path is provided, the `pyproject.toml` in the working directory is used.
1412    ///
1413    /// May be provided multiple times.
1414    #[arg(long, group = "sources")]
1415    pub group: Vec<PipGroupName>,
1416
1417    #[command(flatten)]
1418    pub resolver: ResolverArgs,
1419
1420    #[command(flatten)]
1421    pub refresh: RefreshArgs,
1422
1423    /// Ignore package dependencies, instead only add those packages explicitly listed
1424    /// on the command line to the resulting requirements file.
1425    #[arg(long)]
1426    pub no_deps: bool,
1427
1428    #[arg(long, overrides_with("no_deps"), hide = true)]
1429    pub deps: bool,
1430
1431    /// Write the compiled requirements to the given `requirements.txt` or `pylock.toml` file.
1432    ///
1433    /// If the file already exists, the existing versions will be preferred when resolving
1434    /// dependencies, unless `--upgrade` is also specified.
1435    #[arg(long, short)]
1436    pub output_file: Option<PathBuf>,
1437
1438    /// The format in which the resolution should be output.
1439    ///
1440    /// Supports both `requirements.txt` and `pylock.toml` (PEP 751) output formats.
1441    ///
1442    /// uv will infer the output format from the file extension of the output file, if
1443    /// provided. Otherwise, defaults to `requirements.txt`.
1444    #[arg(long, value_enum)]
1445    pub format: Option<PipCompileFormat>,
1446
1447    /// Include extras in the output file.
1448    ///
1449    /// By default, uv strips extras, as any packages pulled in by the extras are already included
1450    /// as dependencies in the output file directly. Further, output files generated with
1451    /// `--no-strip-extras` cannot be used as constraints files in `install` and `sync` invocations.
1452    #[arg(long, overrides_with("strip_extras"))]
1453    pub no_strip_extras: bool,
1454
1455    #[arg(long, overrides_with("no_strip_extras"), hide = true)]
1456    pub strip_extras: bool,
1457
1458    /// Include environment markers in the output file.
1459    ///
1460    /// By default, uv strips environment markers, as the resolution generated by `compile` is
1461    /// only guaranteed to be correct for the target environment.
1462    #[arg(long, overrides_with("strip_markers"))]
1463    pub no_strip_markers: bool,
1464
1465    #[arg(long, overrides_with("no_strip_markers"), hide = true)]
1466    pub strip_markers: bool,
1467
1468    /// Exclude comment annotations indicating the source of each package.
1469    #[arg(long, overrides_with("annotate"))]
1470    pub no_annotate: bool,
1471
1472    #[arg(long, overrides_with("no_annotate"), hide = true)]
1473    pub annotate: bool,
1474
1475    /// Exclude the comment header at the top of the generated output file.
1476    #[arg(long, overrides_with("header"))]
1477    pub no_header: bool,
1478
1479    #[arg(long, overrides_with("no_header"), hide = true)]
1480    pub header: bool,
1481
1482    /// The style of the annotation comments included in the output file, used to indicate the
1483    /// source of each package.
1484    ///
1485    /// Defaults to `split`.
1486    #[arg(long, value_enum)]
1487    pub annotation_style: Option<AnnotationStyle>,
1488
1489    /// The header comment to include at the top of the output file generated by `uv pip compile`.
1490    ///
1491    /// Used to reflect custom build scripts and commands that wrap `uv pip compile`.
1492    #[arg(long, env = EnvVars::UV_CUSTOM_COMPILE_COMMAND)]
1493    pub custom_compile_command: Option<String>,
1494
1495    /// The Python interpreter to use during resolution.
1496    ///
1497    /// A Python interpreter is required for building source distributions to determine package
1498    /// metadata when there are not wheels.
1499    ///
1500    /// The interpreter is also used to determine the default minimum Python version, unless
1501    /// `--python-version` is provided.
1502    ///
1503    /// This option respects `UV_PYTHON`, but when set via environment variable, it is overridden
1504    /// by `--python-version`.
1505    ///
1506    /// See `uv help python` for details on Python discovery and supported request formats.
1507    #[arg(
1508        long,
1509        short,
1510        verbatim_doc_comment,
1511        help_heading = "Python options",
1512        value_parser = parse_maybe_string
1513    )]
1514    pub python: Option<Maybe<String>>,
1515
1516    /// Install packages into the system Python environment.
1517    ///
1518    /// By default, uv uses the virtual environment in the current working directory or any parent
1519    /// directory, falling back to searching for a Python executable in `PATH`. The `--system`
1520    /// option instructs uv to avoid using a virtual environment Python and restrict its search to
1521    /// the system path.
1522    #[arg(
1523        long,
1524        env = EnvVars::UV_SYSTEM_PYTHON,
1525        value_parser = clap::builder::BoolishValueParser::new(),
1526        overrides_with("no_system")
1527    )]
1528    pub system: bool,
1529
1530    #[arg(long, overrides_with("system"), hide = true)]
1531    pub no_system: bool,
1532
1533    /// Include distribution hashes in the output file.
1534    #[arg(long, overrides_with("no_generate_hashes"))]
1535    pub generate_hashes: bool,
1536
1537    #[arg(long, overrides_with("generate_hashes"), hide = true)]
1538    pub no_generate_hashes: bool,
1539
1540    /// Don't build source distributions.
1541    ///
1542    /// When enabled, resolving will not run arbitrary Python code. The cached wheels of
1543    /// already-built source distributions will be reused, but operations that require building
1544    /// distributions will exit with an error.
1545    ///
1546    /// Alias for `--only-binary :all:`.
1547    #[arg(
1548        long,
1549        conflicts_with = "no_binary",
1550        conflicts_with = "only_binary",
1551        overrides_with("build")
1552    )]
1553    pub no_build: bool,
1554
1555    #[arg(
1556        long,
1557        conflicts_with = "no_binary",
1558        conflicts_with = "only_binary",
1559        overrides_with("no_build"),
1560        hide = true
1561    )]
1562    pub build: bool,
1563
1564    /// Don't install pre-built wheels.
1565    ///
1566    /// The given packages will be built and installed from source. The resolver will still use
1567    /// pre-built wheels to extract package metadata, if available.
1568    ///
1569    /// Multiple packages may be provided. Disable binaries for all packages with `:all:`.
1570    /// Clear previously specified packages with `:none:`.
1571    #[arg(long, conflicts_with = "no_build")]
1572    pub no_binary: Option<Vec<PackageNameSpecifier>>,
1573
1574    /// Only use pre-built wheels; don't build source distributions.
1575    ///
1576    /// When enabled, resolving will not run code from the given packages. The cached wheels of already-built
1577    /// source distributions will be reused, but operations that require building distributions will
1578    /// exit with an error.
1579    ///
1580    /// Multiple packages may be provided. Disable binaries for all packages with `:all:`.
1581    /// Clear previously specified packages with `:none:`.
1582    #[arg(long, conflicts_with = "no_build")]
1583    pub only_binary: Option<Vec<PackageNameSpecifier>>,
1584
1585    /// The Python version to use for resolution.
1586    ///
1587    /// For example, `3.8` or `3.8.17`.
1588    ///
1589    /// Defaults to the version of the Python interpreter used for resolution.
1590    ///
1591    /// Defines the minimum Python version that must be supported by the
1592    /// resolved requirements.
1593    ///
1594    /// If a patch version is omitted, the minimum patch version is assumed. For
1595    /// example, `3.8` is mapped to `3.8.0`.
1596    #[arg(long, help_heading = "Python options")]
1597    pub python_version: Option<PythonVersion>,
1598
1599    /// The platform for which requirements should be resolved.
1600    ///
1601    /// Represented as a "target triple", a string that describes the target platform in terms of
1602    /// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
1603    /// `aarch64-apple-darwin`.
1604    ///
1605    /// When targeting macOS (Darwin), the default minimum version is `13.0`. Use
1606    /// `MACOSX_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
1607    ///
1608    /// When targeting iOS, the default minimum version is `13.0`. Use
1609    /// `IPHONEOS_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
1610    ///
1611    /// When targeting Android, the default minimum Android API level is `24`. Use
1612    /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`.
1613    #[arg(long)]
1614    pub python_platform: Option<TargetTriple>,
1615
1616    /// Perform a universal resolution, attempting to generate a single `requirements.txt` output
1617    /// file that is compatible with all operating systems, architectures, and Python
1618    /// implementations.
1619    ///
1620    /// In universal mode, the current Python version (or user-provided `--python-version`) will be
1621    /// treated as a lower bound. For example, `--universal --python-version 3.7` would produce a
1622    /// universal resolution for Python 3.7 and later.
1623    ///
1624    /// Implies `--no-strip-markers`.
1625    #[arg(
1626        long,
1627        overrides_with("no_universal"),
1628        conflicts_with("python_platform"),
1629        conflicts_with("strip_markers")
1630    )]
1631    pub universal: bool,
1632
1633    #[arg(long, overrides_with("universal"), hide = true)]
1634    pub no_universal: bool,
1635
1636    /// Specify a package to omit from the output resolution. Its dependencies will still be
1637    /// included in the resolution. Equivalent to pip-compile's `--unsafe-package` option.
1638    #[arg(long, alias = "unsafe-package")]
1639    pub no_emit_package: Option<Vec<PackageName>>,
1640
1641    /// Include `--index-url` and `--extra-index-url` entries in the generated output file.
1642    #[arg(long, overrides_with("no_emit_index_url"))]
1643    pub emit_index_url: bool,
1644
1645    #[arg(long, overrides_with("emit_index_url"), hide = true)]
1646    pub no_emit_index_url: bool,
1647
1648    /// Include `--find-links` entries in the generated output file.
1649    #[arg(long, overrides_with("no_emit_find_links"))]
1650    pub emit_find_links: bool,
1651
1652    #[arg(long, overrides_with("emit_find_links"), hide = true)]
1653    pub no_emit_find_links: bool,
1654
1655    /// Include `--no-binary` and `--only-binary` entries in the generated output file.
1656    #[arg(long, overrides_with("no_emit_build_options"))]
1657    pub emit_build_options: bool,
1658
1659    #[arg(long, overrides_with("emit_build_options"), hide = true)]
1660    pub no_emit_build_options: bool,
1661
1662    /// Whether to emit a marker string indicating when it is known that the
1663    /// resulting set of pinned dependencies is valid.
1664    ///
1665    /// The pinned dependencies may be valid even when the marker expression is
1666    /// false, but when the expression is true, the requirements are known to
1667    /// be correct.
1668    #[arg(long, overrides_with("no_emit_marker_expression"), hide = true)]
1669    pub emit_marker_expression: bool,
1670
1671    #[arg(long, overrides_with("emit_marker_expression"), hide = true)]
1672    pub no_emit_marker_expression: bool,
1673
1674    /// Include comment annotations indicating the index used to resolve each package (e.g.,
1675    /// `# from https://pypi.org/simple`).
1676    #[arg(long, overrides_with("no_emit_index_annotation"))]
1677    pub emit_index_annotation: bool,
1678
1679    #[arg(long, overrides_with("emit_index_annotation"), hide = true)]
1680    pub no_emit_index_annotation: bool,
1681
1682    /// The backend to use when fetching packages in the PyTorch ecosystem (e.g., `cpu`, `cu126`, or `auto`).
1683    ///
1684    /// When set, uv will ignore the configured index URLs for packages in the PyTorch ecosystem,
1685    /// and will instead use the defined backend.
1686    ///
1687    /// For example, when set to `cpu`, uv will use the CPU-only PyTorch index; when set to `cu126`,
1688    /// uv will use the PyTorch index for CUDA 12.6.
1689    ///
1690    /// The `auto` mode will attempt to detect the appropriate PyTorch index based on the currently
1691    /// installed CUDA drivers.
1692    ///
1693    /// This option is in preview and may change in any future release.
1694    #[arg(long, value_enum, env = EnvVars::UV_TORCH_BACKEND)]
1695    pub torch_backend: Option<TorchMode>,
1696
1697    #[command(flatten)]
1698    pub compat_args: compat::PipCompileCompatArgs,
1699}
1700
1701#[derive(Args)]
1702pub struct PipSyncArgs {
1703    /// Include the packages listed in the given files.
1704    ///
1705    /// The following formats are supported: `requirements.txt`, `.py` files with inline metadata,
1706    /// `pylock.toml`, `pyproject.toml`, `setup.py`, and `setup.cfg`.
1707    ///
1708    /// If a `pyproject.toml`, `setup.py`, or `setup.cfg` file is provided, uv will
1709    /// extract the requirements for the relevant project.
1710    ///
1711    /// If `-` is provided, then requirements will be read from stdin.
1712    #[arg(required(true), value_parser = parse_file_path)]
1713    pub src_file: Vec<PathBuf>,
1714
1715    /// Constrain versions using the given requirements files.
1716    ///
1717    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
1718    /// requirement that's installed. However, including a package in a constraints file will _not_
1719    /// trigger the installation of that package.
1720    ///
1721    /// This is equivalent to pip's `--constraint` option.
1722    #[arg(long, short, alias = "constraint", env = EnvVars::UV_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
1723    pub constraints: Vec<Maybe<PathBuf>>,
1724
1725    /// Constrain build dependencies using the given requirements files when building source
1726    /// distributions.
1727    ///
1728    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
1729    /// requirement that's installed. However, including a package in a constraints file will _not_
1730    /// trigger the installation of that package.
1731    #[arg(long, short, alias = "build-constraint", env = EnvVars::UV_BUILD_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
1732    pub build_constraints: Vec<Maybe<PathBuf>>,
1733
1734    /// Include optional dependencies from the specified extra name; may be provided more than once.
1735    ///
1736    /// Only applies to `pylock.toml`, `pyproject.toml`, `setup.py`, and `setup.cfg` sources.
1737    #[arg(long, conflicts_with = "all_extras", value_parser = extra_name_with_clap_error)]
1738    pub extra: Option<Vec<ExtraName>>,
1739
1740    /// Include all optional dependencies.
1741    ///
1742    /// Only applies to `pylock.toml`, `pyproject.toml`, `setup.py`, and `setup.cfg` sources.
1743    #[arg(long, conflicts_with = "extra", overrides_with = "no_all_extras")]
1744    pub all_extras: bool,
1745
1746    #[arg(long, overrides_with("all_extras"), hide = true)]
1747    pub no_all_extras: bool,
1748
1749    /// Install the specified dependency group from a `pylock.toml` or `pyproject.toml`.
1750    ///
1751    /// If no path is provided, the `pylock.toml` or `pyproject.toml` in the working directory is
1752    /// used.
1753    ///
1754    /// May be provided multiple times.
1755    #[arg(long, group = "sources")]
1756    pub group: Vec<PipGroupName>,
1757
1758    #[command(flatten)]
1759    pub installer: InstallerArgs,
1760
1761    #[command(flatten)]
1762    pub refresh: RefreshArgs,
1763
1764    /// Require a matching hash for each requirement.
1765    ///
1766    /// By default, uv will verify any available hashes in the requirements file, but will not
1767    /// require that all requirements have an associated hash.
1768    ///
1769    /// When `--require-hashes` is enabled, _all_ requirements must include a hash or set of hashes,
1770    /// and _all_ requirements must either be pinned to exact versions (e.g., `==1.0.0`), or be
1771    /// specified via direct URL.
1772    ///
1773    /// Hash-checking mode introduces a number of additional constraints:
1774    ///
1775    /// - Git dependencies are not supported.
1776    /// - Editable installations are not supported.
1777    /// - Local dependencies are not supported, unless they point to a specific wheel (`.whl`) or
1778    ///   source archive (`.zip`, `.tar.gz`), as opposed to a directory.
1779    #[arg(
1780        long,
1781        env = EnvVars::UV_REQUIRE_HASHES,
1782        value_parser = clap::builder::BoolishValueParser::new(),
1783        overrides_with("no_require_hashes"),
1784    )]
1785    pub require_hashes: bool,
1786
1787    #[arg(long, overrides_with("require_hashes"), hide = true)]
1788    pub no_require_hashes: bool,
1789
1790    #[arg(long, overrides_with("no_verify_hashes"), hide = true)]
1791    pub verify_hashes: bool,
1792
1793    /// Disable validation of hashes in the requirements file.
1794    ///
1795    /// By default, uv will verify any available hashes in the requirements file, but will not
1796    /// require that all requirements have an associated hash. To enforce hash validation, use
1797    /// `--require-hashes`.
1798    #[arg(
1799        long,
1800        env = EnvVars::UV_NO_VERIFY_HASHES,
1801        value_parser = clap::builder::BoolishValueParser::new(),
1802        overrides_with("verify_hashes"),
1803    )]
1804    pub no_verify_hashes: bool,
1805
1806    /// The Python interpreter into which packages should be installed.
1807    ///
1808    /// By default, syncing requires a virtual environment. A path to an alternative Python can be
1809    /// provided, but it is only recommended in continuous integration (CI) environments and should
1810    /// be used with caution, as it can modify the system Python installation.
1811    ///
1812    /// See `uv help python` for details on Python discovery and supported request formats.
1813    #[arg(
1814        long,
1815        short,
1816        env = EnvVars::UV_PYTHON,
1817        verbatim_doc_comment,
1818        help_heading = "Python options",
1819        value_parser = parse_maybe_string,
1820    )]
1821    pub python: Option<Maybe<String>>,
1822
1823    /// Install packages into the system Python environment.
1824    ///
1825    /// By default, uv installs into the virtual environment in the current working directory or any
1826    /// parent directory. The `--system` option instructs uv to instead use the first Python found
1827    /// in the system `PATH`.
1828    ///
1829    /// WARNING: `--system` is intended for use in continuous integration (CI) environments and
1830    /// should be used with caution, as it can modify the system Python installation.
1831    #[arg(
1832        long,
1833        env = EnvVars::UV_SYSTEM_PYTHON,
1834        value_parser = clap::builder::BoolishValueParser::new(),
1835        overrides_with("no_system")
1836    )]
1837    pub system: bool,
1838
1839    #[arg(long, overrides_with("system"), hide = true)]
1840    pub no_system: bool,
1841
1842    /// Allow uv to modify an `EXTERNALLY-MANAGED` Python installation.
1843    ///
1844    /// WARNING: `--break-system-packages` is intended for use in continuous integration (CI)
1845    /// environments, when installing into Python installations that are managed by an external
1846    /// package manager, like `apt`. It should be used with caution, as such Python installations
1847    /// explicitly recommend against modifications by other package managers (like uv or `pip`).
1848    #[arg(
1849        long,
1850        env = EnvVars::UV_BREAK_SYSTEM_PACKAGES,
1851        value_parser = clap::builder::BoolishValueParser::new(),
1852        overrides_with("no_break_system_packages")
1853    )]
1854    pub break_system_packages: bool,
1855
1856    #[arg(long, overrides_with("break_system_packages"))]
1857    pub no_break_system_packages: bool,
1858
1859    /// Install packages into the specified directory, rather than into the virtual or system Python
1860    /// environment. The packages will be installed at the top-level of the directory.
1861    ///
1862    /// Unlike other install operations, this command does not require discovery of an existing Python
1863    /// environment and only searches for a Python interpreter to use for package resolution.
1864    /// If a suitable Python interpreter cannot be found, uv will install one.
1865    /// To disable this, add `--no-python-downloads`.
1866    #[arg(long, conflicts_with = "prefix")]
1867    pub target: Option<PathBuf>,
1868
1869    /// Install packages into `lib`, `bin`, and other top-level folders under the specified
1870    /// directory, as if a virtual environment were present at that location.
1871    ///
1872    /// In general, prefer the use of `--python` to install into an alternate environment, as
1873    /// scripts and other artifacts installed via `--prefix` will reference the installing
1874    /// interpreter, rather than any interpreter added to the `--prefix` directory, rendering them
1875    /// non-portable.
1876    ///
1877    /// Unlike other install operations, this command does not require discovery of an existing Python
1878    /// environment and only searches for a Python interpreter to use for package resolution.
1879    /// If a suitable Python interpreter cannot be found, uv will install one.
1880    /// To disable this, add `--no-python-downloads`.
1881    #[arg(long, conflicts_with = "target")]
1882    pub prefix: Option<PathBuf>,
1883
1884    /// Don't build source distributions.
1885    ///
1886    /// When enabled, resolving will not run arbitrary Python code. The cached wheels of
1887    /// already-built source distributions will be reused, but operations that require building
1888    /// distributions will exit with an error.
1889    ///
1890    /// Alias for `--only-binary :all:`.
1891    #[arg(
1892        long,
1893        conflicts_with = "no_binary",
1894        conflicts_with = "only_binary",
1895        overrides_with("build")
1896    )]
1897    pub no_build: bool,
1898
1899    #[arg(
1900        long,
1901        conflicts_with = "no_binary",
1902        conflicts_with = "only_binary",
1903        overrides_with("no_build"),
1904        hide = true
1905    )]
1906    pub build: bool,
1907
1908    /// Don't install pre-built wheels.
1909    ///
1910    /// The given packages will be built and installed from source. The resolver will still use
1911    /// pre-built wheels to extract package metadata, if available.
1912    ///
1913    /// Multiple packages may be provided. Disable binaries for all packages with `:all:`. Clear
1914    /// previously specified packages with `:none:`.
1915    #[arg(long, conflicts_with = "no_build")]
1916    pub no_binary: Option<Vec<PackageNameSpecifier>>,
1917
1918    /// Only use pre-built wheels; don't build source distributions.
1919    ///
1920    /// When enabled, resolving will not run code from the given packages. The cached wheels of
1921    /// already-built source distributions will be reused, but operations that require building
1922    /// distributions will exit with an error.
1923    ///
1924    /// Multiple packages may be provided. Disable binaries for all packages with `:all:`. Clear
1925    /// previously specified packages with `:none:`.
1926    #[arg(long, conflicts_with = "no_build")]
1927    pub only_binary: Option<Vec<PackageNameSpecifier>>,
1928
1929    /// Allow sync of empty requirements, which will clear the environment of all packages.
1930    #[arg(long, overrides_with("no_allow_empty_requirements"))]
1931    pub allow_empty_requirements: bool,
1932
1933    #[arg(long, overrides_with("allow_empty_requirements"))]
1934    pub no_allow_empty_requirements: bool,
1935
1936    /// The minimum Python version that should be supported by the requirements (e.g., `3.7` or
1937    /// `3.7.9`).
1938    ///
1939    /// If a patch version is omitted, the minimum patch version is assumed. For example, `3.7` is
1940    /// mapped to `3.7.0`.
1941    #[arg(long)]
1942    pub python_version: Option<PythonVersion>,
1943
1944    /// The platform for which requirements should be installed.
1945    ///
1946    /// Represented as a "target triple", a string that describes the target platform in terms of
1947    /// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
1948    /// `aarch64-apple-darwin`.
1949    ///
1950    /// When targeting macOS (Darwin), the default minimum version is `13.0`. Use
1951    /// `MACOSX_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
1952    ///
1953    /// When targeting iOS, the default minimum version is `13.0`. Use
1954    /// `IPHONEOS_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
1955    ///
1956    /// When targeting Android, the default minimum Android API level is `24`. Use
1957    /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`.
1958    ///
1959    /// WARNING: When specified, uv will select wheels that are compatible with the _target_
1960    /// platform; as a result, the installed distributions may not be compatible with the _current_
1961    /// platform. Conversely, any distributions that are built from source may be incompatible with
1962    /// the _target_ platform, as they will be built for the _current_ platform. The
1963    /// `--python-platform` option is intended for advanced use cases.
1964    #[arg(long)]
1965    pub python_platform: Option<TargetTriple>,
1966
1967    /// Validate the Python environment after completing the installation, to detect packages with
1968    /// missing dependencies or other issues.
1969    #[arg(long, overrides_with("no_strict"))]
1970    pub strict: bool,
1971
1972    #[arg(long, overrides_with("strict"), hide = true)]
1973    pub no_strict: bool,
1974
1975    /// Perform a dry run, i.e., don't actually install anything but resolve the dependencies and
1976    /// print the resulting plan.
1977    #[arg(long)]
1978    pub dry_run: bool,
1979
1980    /// The backend to use when fetching packages in the PyTorch ecosystem (e.g., `cpu`, `cu126`, or `auto`).
1981    ///
1982    /// When set, uv will ignore the configured index URLs for packages in the PyTorch ecosystem,
1983    /// and will instead use the defined backend.
1984    ///
1985    /// For example, when set to `cpu`, uv will use the CPU-only PyTorch index; when set to `cu126`,
1986    /// uv will use the PyTorch index for CUDA 12.6.
1987    ///
1988    /// The `auto` mode will attempt to detect the appropriate PyTorch index based on the currently
1989    /// installed CUDA drivers.
1990    ///
1991    /// This option is in preview and may change in any future release.
1992    #[arg(long, value_enum, env = EnvVars::UV_TORCH_BACKEND)]
1993    pub torch_backend: Option<TorchMode>,
1994
1995    #[command(flatten)]
1996    pub compat_args: compat::PipSyncCompatArgs,
1997}
1998
1999#[derive(Args)]
2000#[command(group = clap::ArgGroup::new("sources").required(true).multiple(true))]
2001pub struct PipInstallArgs {
2002    /// Install all listed packages.
2003    ///
2004    /// The order of the packages is used to determine priority during resolution.
2005    #[arg(group = "sources")]
2006    pub package: Vec<String>,
2007
2008    /// Install the packages listed in the given files.
2009    ///
2010    /// The following formats are supported: `requirements.txt`, `.py` files with inline metadata,
2011    /// `pylock.toml`, `pyproject.toml`, `setup.py`, and `setup.cfg`.
2012    ///
2013    /// If a `pyproject.toml`, `setup.py`, or `setup.cfg` file is provided, uv will extract the
2014    /// requirements for the relevant project.
2015    ///
2016    /// If `-` is provided, then requirements will be read from stdin.
2017    #[arg(long, short, alias = "requirement", group = "sources", value_parser = parse_file_path)]
2018    pub requirements: Vec<PathBuf>,
2019
2020    /// Install the editable package based on the provided local file path.
2021    #[arg(long, short, group = "sources")]
2022    pub editable: Vec<String>,
2023
2024    /// Constrain versions using the given requirements files.
2025    ///
2026    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
2027    /// requirement that's installed. However, including a package in a constraints file will _not_
2028    /// trigger the installation of that package.
2029    ///
2030    /// This is equivalent to pip's `--constraint` option.
2031    #[arg(long, short, alias = "constraint", env = EnvVars::UV_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
2032    pub constraints: Vec<Maybe<PathBuf>>,
2033
2034    /// Override versions using the given requirements files.
2035    ///
2036    /// Overrides files are `requirements.txt`-like files that force a specific version of a
2037    /// requirement to be installed, regardless of the requirements declared by any constituent
2038    /// package, and regardless of whether this would be considered an invalid resolution.
2039    ///
2040    /// While constraints are _additive_, in that they're combined with the requirements of the
2041    /// constituent packages, overrides are _absolute_, in that they completely replace the
2042    /// requirements of the constituent packages.
2043    #[arg(long, alias = "override", env = EnvVars::UV_OVERRIDE, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
2044    pub overrides: Vec<Maybe<PathBuf>>,
2045
2046    /// Exclude packages from resolution using the given requirements files.
2047    ///
2048    /// Excludes files are `requirements.txt`-like files that specify packages to exclude
2049    /// from the resolution. When a package is excluded, it will be omitted from the
2050    /// dependency list entirely and its own dependencies will be ignored during the resolution
2051    /// phase. Excludes are unconditional in that requirement specifiers and markers are ignored;
2052    /// any package listed in the provided file will be omitted from all resolved environments.
2053    #[arg(long, alias = "exclude", env = EnvVars::UV_EXCLUDE, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
2054    pub excludes: Vec<Maybe<PathBuf>>,
2055
2056    /// Constrain build dependencies using the given requirements files when building source
2057    /// distributions.
2058    ///
2059    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
2060    /// requirement that's installed. However, including a package in a constraints file will _not_
2061    /// trigger the installation of that package.
2062    #[arg(long, short, alias = "build-constraint", env = EnvVars::UV_BUILD_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
2063    pub build_constraints: Vec<Maybe<PathBuf>>,
2064
2065    /// Include optional dependencies from the specified extra name; may be provided more than once.
2066    ///
2067    /// Only applies to `pylock.toml`, `pyproject.toml`, `setup.py`, and `setup.cfg` sources.
2068    #[arg(long, conflicts_with = "all_extras", value_parser = extra_name_with_clap_error)]
2069    pub extra: Option<Vec<ExtraName>>,
2070
2071    /// Include all optional dependencies.
2072    ///
2073    /// Only applies to `pylock.toml`, `pyproject.toml`, `setup.py`, and `setup.cfg` sources.
2074    #[arg(long, conflicts_with = "extra", overrides_with = "no_all_extras")]
2075    pub all_extras: bool,
2076
2077    #[arg(long, overrides_with("all_extras"), hide = true)]
2078    pub no_all_extras: bool,
2079
2080    /// Install the specified dependency group from a `pylock.toml` or `pyproject.toml`.
2081    ///
2082    /// If no path is provided, the `pylock.toml` or `pyproject.toml` in the working directory is
2083    /// used.
2084    ///
2085    /// May be provided multiple times.
2086    #[arg(long, group = "sources")]
2087    pub group: Vec<PipGroupName>,
2088
2089    #[command(flatten)]
2090    pub installer: ResolverInstallerArgs,
2091
2092    #[command(flatten)]
2093    pub refresh: RefreshArgs,
2094
2095    /// Ignore package dependencies, instead only installing those packages explicitly listed
2096    /// on the command line or in the requirements files.
2097    #[arg(long, overrides_with("deps"))]
2098    pub no_deps: bool,
2099
2100    #[arg(long, overrides_with("no_deps"), hide = true)]
2101    pub deps: bool,
2102
2103    /// Require a matching hash for each requirement.
2104    ///
2105    /// By default, uv will verify any available hashes in the requirements file, but will not
2106    /// require that all requirements have an associated hash.
2107    ///
2108    /// When `--require-hashes` is enabled, _all_ requirements must include a hash or set of hashes,
2109    /// and _all_ requirements must either be pinned to exact versions (e.g., `==1.0.0`), or be
2110    /// specified via direct URL.
2111    ///
2112    /// Hash-checking mode introduces a number of additional constraints:
2113    ///
2114    /// - Git dependencies are not supported.
2115    /// - Editable installations are not supported.
2116    /// - Local dependencies are not supported, unless they point to a specific wheel (`.whl`) or
2117    ///   source archive (`.zip`, `.tar.gz`), as opposed to a directory.
2118    #[arg(
2119        long,
2120        env = EnvVars::UV_REQUIRE_HASHES,
2121        value_parser = clap::builder::BoolishValueParser::new(),
2122        overrides_with("no_require_hashes"),
2123    )]
2124    pub require_hashes: bool,
2125
2126    #[arg(long, overrides_with("require_hashes"), hide = true)]
2127    pub no_require_hashes: bool,
2128
2129    #[arg(long, overrides_with("no_verify_hashes"), hide = true)]
2130    pub verify_hashes: bool,
2131
2132    /// Disable validation of hashes in the requirements file.
2133    ///
2134    /// By default, uv will verify any available hashes in the requirements file, but will not
2135    /// require that all requirements have an associated hash. To enforce hash validation, use
2136    /// `--require-hashes`.
2137    #[arg(
2138        long,
2139        env = EnvVars::UV_NO_VERIFY_HASHES,
2140        value_parser = clap::builder::BoolishValueParser::new(),
2141        overrides_with("verify_hashes"),
2142    )]
2143    pub no_verify_hashes: bool,
2144
2145    /// The Python interpreter into which packages should be installed.
2146    ///
2147    /// By default, installation requires a virtual environment. A path to an alternative Python can
2148    /// be provided, but it is only recommended in continuous integration (CI) environments and
2149    /// should be used with caution, as it can modify the system Python installation.
2150    ///
2151    /// See `uv help python` for details on Python discovery and supported request formats.
2152    #[arg(
2153        long,
2154        short,
2155        env = EnvVars::UV_PYTHON,
2156        verbatim_doc_comment,
2157        help_heading = "Python options",
2158        value_parser = parse_maybe_string,
2159    )]
2160    pub python: Option<Maybe<String>>,
2161
2162    /// Install packages into the system Python environment.
2163    ///
2164    /// By default, uv installs into the virtual environment in the current working directory or any
2165    /// parent directory. The `--system` option instructs uv to instead use the first Python found
2166    /// in the system `PATH`.
2167    ///
2168    /// WARNING: `--system` is intended for use in continuous integration (CI) environments and
2169    /// should be used with caution, as it can modify the system Python installation.
2170    #[arg(
2171        long,
2172        env = EnvVars::UV_SYSTEM_PYTHON,
2173        value_parser = clap::builder::BoolishValueParser::new(),
2174        overrides_with("no_system")
2175    )]
2176    pub system: bool,
2177
2178    #[arg(long, overrides_with("system"), hide = true)]
2179    pub no_system: bool,
2180
2181    /// Allow uv to modify an `EXTERNALLY-MANAGED` Python installation.
2182    ///
2183    /// WARNING: `--break-system-packages` is intended for use in continuous integration (CI)
2184    /// environments, when installing into Python installations that are managed by an external
2185    /// package manager, like `apt`. It should be used with caution, as such Python installations
2186    /// explicitly recommend against modifications by other package managers (like uv or `pip`).
2187    #[arg(
2188        long,
2189        env = EnvVars::UV_BREAK_SYSTEM_PACKAGES,
2190        value_parser = clap::builder::BoolishValueParser::new(),
2191        overrides_with("no_break_system_packages")
2192    )]
2193    pub break_system_packages: bool,
2194
2195    #[arg(long, overrides_with("break_system_packages"))]
2196    pub no_break_system_packages: bool,
2197
2198    /// Install packages into the specified directory, rather than into the virtual or system Python
2199    /// environment. The packages will be installed at the top-level of the directory.
2200    ///
2201    /// Unlike other install operations, this command does not require discovery of an existing Python
2202    /// environment and only searches for a Python interpreter to use for package resolution.
2203    /// If a suitable Python interpreter cannot be found, uv will install one.
2204    /// To disable this, add `--no-python-downloads`.
2205    #[arg(long, conflicts_with = "prefix")]
2206    pub target: Option<PathBuf>,
2207
2208    /// Install packages into `lib`, `bin`, and other top-level folders under the specified
2209    /// directory, as if a virtual environment were present at that location.
2210    ///
2211    /// In general, prefer the use of `--python` to install into an alternate environment, as
2212    /// scripts and other artifacts installed via `--prefix` will reference the installing
2213    /// interpreter, rather than any interpreter added to the `--prefix` directory, rendering them
2214    /// non-portable.
2215    ///
2216    /// Unlike other install operations, this command does not require discovery of an existing Python
2217    /// environment and only searches for a Python interpreter to use for package resolution.
2218    /// If a suitable Python interpreter cannot be found, uv will install one.
2219    /// To disable this, add `--no-python-downloads`.
2220    #[arg(long, conflicts_with = "target")]
2221    pub prefix: Option<PathBuf>,
2222
2223    /// Don't build source distributions.
2224    ///
2225    /// When enabled, resolving will not run arbitrary Python code. The cached wheels of
2226    /// already-built source distributions will be reused, but operations that require building
2227    /// distributions will exit with an error.
2228    ///
2229    /// Alias for `--only-binary :all:`.
2230    #[arg(
2231        long,
2232        conflicts_with = "no_binary",
2233        conflicts_with = "only_binary",
2234        overrides_with("build")
2235    )]
2236    pub no_build: bool,
2237
2238    #[arg(
2239        long,
2240        conflicts_with = "no_binary",
2241        conflicts_with = "only_binary",
2242        overrides_with("no_build"),
2243        hide = true
2244    )]
2245    pub build: bool,
2246
2247    /// Don't install pre-built wheels.
2248    ///
2249    /// The given packages will be built and installed from source. The resolver will still use
2250    /// pre-built wheels to extract package metadata, if available.
2251    ///
2252    /// Multiple packages may be provided. Disable binaries for all packages with `:all:`. Clear
2253    /// previously specified packages with `:none:`.
2254    #[arg(long, conflicts_with = "no_build")]
2255    pub no_binary: Option<Vec<PackageNameSpecifier>>,
2256
2257    /// Only use pre-built wheels; don't build source distributions.
2258    ///
2259    /// When enabled, resolving will not run code from the given packages. The cached wheels of
2260    /// already-built source distributions will be reused, but operations that require building
2261    /// distributions will exit with an error.
2262    ///
2263    /// Multiple packages may be provided. Disable binaries for all packages with `:all:`. Clear
2264    /// previously specified packages with `:none:`.
2265    #[arg(long, conflicts_with = "no_build")]
2266    pub only_binary: Option<Vec<PackageNameSpecifier>>,
2267
2268    /// The minimum Python version that should be supported by the requirements (e.g., `3.7` or
2269    /// `3.7.9`).
2270    ///
2271    /// If a patch version is omitted, the minimum patch version is assumed. For example, `3.7` is
2272    /// mapped to `3.7.0`.
2273    #[arg(long)]
2274    pub python_version: Option<PythonVersion>,
2275
2276    /// The platform for which requirements should be installed.
2277    ///
2278    /// Represented as a "target triple", a string that describes the target platform in terms of
2279    /// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
2280    /// `aarch64-apple-darwin`.
2281    ///
2282    /// When targeting macOS (Darwin), the default minimum version is `13.0`. Use
2283    /// `MACOSX_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
2284    ///
2285    /// When targeting iOS, the default minimum version is `13.0`. Use
2286    /// `IPHONEOS_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
2287    ///
2288    /// When targeting Android, the default minimum Android API level is `24`. Use
2289    /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`.
2290    ///
2291    /// WARNING: When specified, uv will select wheels that are compatible with the _target_
2292    /// platform; as a result, the installed distributions may not be compatible with the _current_
2293    /// platform. Conversely, any distributions that are built from source may be incompatible with
2294    /// the _target_ platform, as they will be built for the _current_ platform. The
2295    /// `--python-platform` option is intended for advanced use cases.
2296    #[arg(long)]
2297    pub python_platform: Option<TargetTriple>,
2298
2299    /// Do not remove extraneous packages present in the environment.
2300    #[arg(long, overrides_with("exact"), alias = "no-exact", hide = true)]
2301    pub inexact: bool,
2302
2303    /// Perform an exact sync, removing extraneous packages.
2304    ///
2305    /// By default, installing will make the minimum necessary changes to satisfy the requirements.
2306    /// When enabled, uv will update the environment to exactly match the requirements, removing
2307    /// packages that are not included in the requirements.
2308    #[arg(long, overrides_with("inexact"))]
2309    pub exact: bool,
2310
2311    /// Validate the Python environment after completing the installation, to detect packages with
2312    /// missing dependencies or other issues.
2313    #[arg(long, overrides_with("no_strict"))]
2314    pub strict: bool,
2315
2316    #[arg(long, overrides_with("strict"), hide = true)]
2317    pub no_strict: bool,
2318
2319    /// Perform a dry run, i.e., don't actually install anything but resolve the dependencies and
2320    /// print the resulting plan.
2321    #[arg(long)]
2322    pub dry_run: bool,
2323
2324    /// The backend to use when fetching packages in the PyTorch ecosystem (e.g., `cpu`, `cu126`, or `auto`)
2325    ///
2326    /// When set, uv will ignore the configured index URLs for packages in the PyTorch ecosystem,
2327    /// and will instead use the defined backend.
2328    ///
2329    /// For example, when set to `cpu`, uv will use the CPU-only PyTorch index; when set to `cu126`,
2330    /// uv will use the PyTorch index for CUDA 12.6.
2331    ///
2332    /// The `auto` mode will attempt to detect the appropriate PyTorch index based on the currently
2333    /// installed CUDA drivers.
2334    ///
2335    /// This option is in preview and may change in any future release.
2336    #[arg(long, value_enum, env = EnvVars::UV_TORCH_BACKEND)]
2337    pub torch_backend: Option<TorchMode>,
2338
2339    #[command(flatten)]
2340    pub compat_args: compat::PipInstallCompatArgs,
2341}
2342
2343#[derive(Args)]
2344#[command(group = clap::ArgGroup::new("sources").required(true).multiple(true))]
2345pub struct PipUninstallArgs {
2346    /// Uninstall all listed packages.
2347    #[arg(group = "sources")]
2348    pub package: Vec<String>,
2349
2350    /// Uninstall the packages listed in the given files.
2351    ///
2352    /// The following formats are supported: `requirements.txt`, `.py` files with inline metadata,
2353    /// `pylock.toml`, `pyproject.toml`, `setup.py`, and `setup.cfg`.
2354    #[arg(long, short, alias = "requirement", group = "sources", value_parser = parse_file_path)]
2355    pub requirements: Vec<PathBuf>,
2356
2357    /// The Python interpreter from which packages should be uninstalled.
2358    ///
2359    /// By default, uninstallation requires a virtual environment. A path to an alternative Python
2360    /// can be provided, but it is only recommended in continuous integration (CI) environments and
2361    /// should be used with caution, as it can modify the system Python installation.
2362    ///
2363    /// See `uv help python` for details on Python discovery and supported request formats.
2364    #[arg(
2365        long,
2366        short,
2367        env = EnvVars::UV_PYTHON,
2368        verbatim_doc_comment,
2369        help_heading = "Python options",
2370        value_parser = parse_maybe_string,
2371    )]
2372    pub python: Option<Maybe<String>>,
2373
2374    /// Attempt to use `keyring` for authentication for remote requirements files.
2375    ///
2376    /// At present, only `--keyring-provider subprocess` is supported, which configures uv to use
2377    /// the `keyring` CLI to handle authentication.
2378    ///
2379    /// Defaults to `disabled`.
2380    #[arg(long, value_enum, env = EnvVars::UV_KEYRING_PROVIDER)]
2381    pub keyring_provider: Option<KeyringProviderType>,
2382
2383    /// Use the system Python to uninstall packages.
2384    ///
2385    /// By default, uv uninstalls from the virtual environment in the current working directory or
2386    /// any parent directory. The `--system` option instructs uv to instead use the first Python
2387    /// found in the system `PATH`.
2388    ///
2389    /// WARNING: `--system` is intended for use in continuous integration (CI) environments and
2390    /// should be used with caution, as it can modify the system Python installation.
2391    #[arg(
2392        long,
2393        env = EnvVars::UV_SYSTEM_PYTHON,
2394        value_parser = clap::builder::BoolishValueParser::new(),
2395        overrides_with("no_system")
2396    )]
2397    pub system: bool,
2398
2399    #[arg(long, overrides_with("system"), hide = true)]
2400    pub no_system: bool,
2401
2402    /// Allow uv to modify an `EXTERNALLY-MANAGED` Python installation.
2403    ///
2404    /// WARNING: `--break-system-packages` is intended for use in continuous integration (CI)
2405    /// environments, when installing into Python installations that are managed by an external
2406    /// package manager, like `apt`. It should be used with caution, as such Python installations
2407    /// explicitly recommend against modifications by other package managers (like uv or `pip`).
2408    #[arg(
2409        long,
2410        env = EnvVars::UV_BREAK_SYSTEM_PACKAGES,
2411        value_parser = clap::builder::BoolishValueParser::new(),
2412        overrides_with("no_break_system_packages")
2413    )]
2414    pub break_system_packages: bool,
2415
2416    #[arg(long, overrides_with("break_system_packages"))]
2417    pub no_break_system_packages: bool,
2418
2419    /// Uninstall packages from the specified `--target` directory.
2420    #[arg(long, conflicts_with = "prefix")]
2421    pub target: Option<PathBuf>,
2422
2423    /// Uninstall packages from the specified `--prefix` directory.
2424    #[arg(long, conflicts_with = "target")]
2425    pub prefix: Option<PathBuf>,
2426
2427    /// Perform a dry run, i.e., don't actually uninstall anything but print the resulting plan.
2428    #[arg(long)]
2429    pub dry_run: bool,
2430
2431    #[command(flatten)]
2432    pub compat_args: compat::PipGlobalCompatArgs,
2433}
2434
2435#[derive(Args)]
2436pub struct PipFreezeArgs {
2437    /// Exclude any editable packages from output.
2438    #[arg(long)]
2439    pub exclude_editable: bool,
2440
2441    /// Validate the Python environment, to detect packages with missing dependencies and other
2442    /// issues.
2443    #[arg(long, overrides_with("no_strict"))]
2444    pub strict: bool,
2445
2446    #[arg(long, overrides_with("strict"), hide = true)]
2447    pub no_strict: bool,
2448
2449    /// The Python interpreter for which packages should be listed.
2450    ///
2451    /// By default, uv lists packages in a virtual environment but will show packages in a system
2452    /// Python environment if no virtual environment is found.
2453    ///
2454    /// See `uv help python` for details on Python discovery and supported request formats.
2455    #[arg(
2456        long,
2457        short,
2458        env = EnvVars::UV_PYTHON,
2459        verbatim_doc_comment,
2460        help_heading = "Python options",
2461        value_parser = parse_maybe_string,
2462    )]
2463    pub python: Option<Maybe<String>>,
2464
2465    /// Restrict to the specified installation path for listing packages (can be used multiple times).
2466    #[arg(long("path"), value_parser = parse_file_path)]
2467    pub paths: Option<Vec<PathBuf>>,
2468
2469    /// List packages in the system Python environment.
2470    ///
2471    /// Disables discovery of virtual environments.
2472    ///
2473    /// See `uv help python` for details on Python discovery.
2474    #[arg(
2475        long,
2476        env = EnvVars::UV_SYSTEM_PYTHON,
2477        value_parser = clap::builder::BoolishValueParser::new(),
2478        overrides_with("no_system")
2479    )]
2480    pub system: bool,
2481
2482    #[arg(long, overrides_with("system"), hide = true)]
2483    pub no_system: bool,
2484
2485    #[command(flatten)]
2486    pub compat_args: compat::PipGlobalCompatArgs,
2487}
2488
2489#[derive(Args)]
2490pub struct PipListArgs {
2491    /// Only include editable projects.
2492    #[arg(short, long)]
2493    pub editable: bool,
2494
2495    /// Exclude any editable packages from output.
2496    #[arg(long, conflicts_with = "editable")]
2497    pub exclude_editable: bool,
2498
2499    /// Exclude the specified package(s) from the output.
2500    #[arg(long)]
2501    pub r#exclude: Vec<PackageName>,
2502
2503    /// Select the output format.
2504    #[arg(long, value_enum, default_value_t = ListFormat::default())]
2505    pub format: ListFormat,
2506
2507    /// List outdated packages.
2508    ///
2509    /// The latest version of each package will be shown alongside the installed version. Up-to-date
2510    /// packages will be omitted from the output.
2511    #[arg(long, overrides_with("no_outdated"))]
2512    pub outdated: bool,
2513
2514    #[arg(long, overrides_with("outdated"), hide = true)]
2515    pub no_outdated: bool,
2516
2517    /// Validate the Python environment, to detect packages with missing dependencies and other
2518    /// issues.
2519    #[arg(long, overrides_with("no_strict"))]
2520    pub strict: bool,
2521
2522    #[arg(long, overrides_with("strict"), hide = true)]
2523    pub no_strict: bool,
2524
2525    #[command(flatten)]
2526    pub fetch: FetchArgs,
2527
2528    /// The Python interpreter for which packages should be listed.
2529    ///
2530    /// By default, uv lists packages in a virtual environment but will show packages in a system
2531    /// Python environment if no virtual environment is found.
2532    ///
2533    /// See `uv help python` for details on Python discovery and supported request formats.
2534    #[arg(
2535        long,
2536        short,
2537        env = EnvVars::UV_PYTHON,
2538        verbatim_doc_comment,
2539        help_heading = "Python options",
2540        value_parser = parse_maybe_string,
2541    )]
2542    pub python: Option<Maybe<String>>,
2543
2544    /// List packages in the system Python environment.
2545    ///
2546    /// Disables discovery of virtual environments.
2547    ///
2548    /// See `uv help python` for details on Python discovery.
2549    #[arg(
2550        long,
2551        env = EnvVars::UV_SYSTEM_PYTHON,
2552        value_parser = clap::builder::BoolishValueParser::new(),
2553        overrides_with("no_system")
2554    )]
2555    pub system: bool,
2556
2557    #[arg(long, overrides_with("system"), hide = true)]
2558    pub no_system: bool,
2559
2560    #[command(flatten)]
2561    pub compat_args: compat::PipListCompatArgs,
2562}
2563
2564#[derive(Args)]
2565pub struct PipCheckArgs {
2566    /// The Python interpreter for which packages should be checked.
2567    ///
2568    /// By default, uv checks packages in a virtual environment but will check packages in a system
2569    /// Python environment if no virtual environment is found.
2570    ///
2571    /// See `uv help python` for details on Python discovery and supported request formats.
2572    #[arg(
2573        long,
2574        short,
2575        env = EnvVars::UV_PYTHON,
2576        verbatim_doc_comment,
2577        help_heading = "Python options",
2578        value_parser = parse_maybe_string,
2579    )]
2580    pub python: Option<Maybe<String>>,
2581
2582    /// Check packages in the system Python environment.
2583    ///
2584    /// Disables discovery of virtual environments.
2585    ///
2586    /// See `uv help python` for details on Python discovery.
2587    #[arg(
2588        long,
2589        env = EnvVars::UV_SYSTEM_PYTHON,
2590        value_parser = clap::builder::BoolishValueParser::new(),
2591        overrides_with("no_system")
2592    )]
2593    pub system: bool,
2594
2595    #[arg(long, overrides_with("system"), hide = true)]
2596    pub no_system: bool,
2597
2598    /// The Python version against which packages should be checked.
2599    ///
2600    /// By default, the installed packages are checked against the version of the current
2601    /// interpreter.
2602    #[arg(long)]
2603    pub python_version: Option<PythonVersion>,
2604
2605    /// The platform for which packages should be checked.
2606    ///
2607    /// By default, the installed packages are checked against the platform of the current
2608    /// interpreter.
2609    ///
2610    /// Represented as a "target triple", a string that describes the target platform in terms of
2611    /// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
2612    /// `aarch64-apple-darwin`.
2613    ///
2614    /// When targeting macOS (Darwin), the default minimum version is `13.0`. Use
2615    /// `MACOSX_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
2616    ///
2617    /// When targeting iOS, the default minimum version is `13.0`. Use
2618    /// `IPHONEOS_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
2619    ///
2620    /// When targeting Android, the default minimum Android API level is `24`. Use
2621    /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`.
2622    #[arg(long)]
2623    pub python_platform: Option<TargetTriple>,
2624}
2625
2626#[derive(Args)]
2627pub struct PipShowArgs {
2628    /// The package(s) to display.
2629    pub package: Vec<PackageName>,
2630
2631    /// Validate the Python environment, to detect packages with missing dependencies and other
2632    /// issues.
2633    #[arg(long, overrides_with("no_strict"))]
2634    pub strict: bool,
2635
2636    #[arg(long, overrides_with("strict"), hide = true)]
2637    pub no_strict: bool,
2638
2639    /// Show the full list of installed files for each package.
2640    #[arg(short, long)]
2641    pub files: bool,
2642
2643    /// The Python interpreter to find the package in.
2644    ///
2645    /// By default, uv looks for packages in a virtual environment but will look for packages in a
2646    /// system Python environment if no virtual environment is found.
2647    ///
2648    /// See `uv help python` for details on Python discovery and supported request formats.
2649    #[arg(
2650        long,
2651        short,
2652        env = EnvVars::UV_PYTHON,
2653        verbatim_doc_comment,
2654        help_heading = "Python options",
2655        value_parser = parse_maybe_string,
2656    )]
2657    pub python: Option<Maybe<String>>,
2658
2659    /// Show a package in the system Python environment.
2660    ///
2661    /// Disables discovery of virtual environments.
2662    ///
2663    /// See `uv help python` for details on Python discovery.
2664    #[arg(
2665        long,
2666        env = EnvVars::UV_SYSTEM_PYTHON,
2667        value_parser = clap::builder::BoolishValueParser::new(),
2668        overrides_with("no_system")
2669    )]
2670    pub system: bool,
2671
2672    #[arg(long, overrides_with("system"), hide = true)]
2673    pub no_system: bool,
2674
2675    #[command(flatten)]
2676    pub compat_args: compat::PipGlobalCompatArgs,
2677}
2678
2679#[derive(Args)]
2680pub struct PipTreeArgs {
2681    /// Show the version constraint(s) imposed on each package.
2682    #[arg(long)]
2683    pub show_version_specifiers: bool,
2684
2685    #[command(flatten)]
2686    pub tree: DisplayTreeArgs,
2687
2688    /// Validate the Python environment, to detect packages with missing dependencies and other
2689    /// issues.
2690    #[arg(long, overrides_with("no_strict"))]
2691    pub strict: bool,
2692
2693    #[arg(long, overrides_with("strict"), hide = true)]
2694    pub no_strict: bool,
2695
2696    #[command(flatten)]
2697    pub fetch: FetchArgs,
2698
2699    /// The Python interpreter for which packages should be listed.
2700    ///
2701    /// By default, uv lists packages in a virtual environment but will show packages in a system
2702    /// Python environment if no virtual environment is found.
2703    ///
2704    /// See `uv help python` for details on Python discovery and supported request formats.
2705    #[arg(
2706        long,
2707        short,
2708        env = EnvVars::UV_PYTHON,
2709        verbatim_doc_comment,
2710        help_heading = "Python options",
2711        value_parser = parse_maybe_string,
2712    )]
2713    pub python: Option<Maybe<String>>,
2714
2715    /// List packages in the system Python environment.
2716    ///
2717    /// Disables discovery of virtual environments.
2718    ///
2719    /// See `uv help python` for details on Python discovery.
2720    #[arg(
2721        long,
2722        env = EnvVars::UV_SYSTEM_PYTHON,
2723        value_parser = clap::builder::BoolishValueParser::new(),
2724        overrides_with("no_system")
2725    )]
2726    pub system: bool,
2727
2728    #[arg(long, overrides_with("system"), hide = true)]
2729    pub no_system: bool,
2730
2731    #[command(flatten)]
2732    pub compat_args: compat::PipGlobalCompatArgs,
2733}
2734
2735#[derive(Args)]
2736pub struct BuildArgs {
2737    /// The directory from which distributions should be built, or a source
2738    /// distribution archive to build into a wheel.
2739    ///
2740    /// Defaults to the current working directory.
2741    #[arg(value_parser = parse_file_path)]
2742    pub src: Option<PathBuf>,
2743
2744    /// Build a specific package in the workspace.
2745    ///
2746    /// The workspace will be discovered from the provided source directory, or the current
2747    /// directory if no source directory is provided.
2748    ///
2749    /// If the workspace member does not exist, uv will exit with an error.
2750    #[arg(long, conflicts_with("all_packages"))]
2751    pub package: Option<PackageName>,
2752
2753    /// Builds all packages in the workspace.
2754    ///
2755    /// The workspace will be discovered from the provided source directory, or the current
2756    /// directory if no source directory is provided.
2757    ///
2758    /// If the workspace member does not exist, uv will exit with an error.
2759    #[arg(long, alias = "all", conflicts_with("package"))]
2760    pub all_packages: bool,
2761
2762    /// The output directory to which distributions should be written.
2763    ///
2764    /// Defaults to the `dist` subdirectory within the source directory, or the
2765    /// directory containing the source distribution archive.
2766    #[arg(long, short, value_parser = parse_file_path)]
2767    pub out_dir: Option<PathBuf>,
2768
2769    /// Build a source distribution ("sdist") from the given directory.
2770    #[arg(long)]
2771    pub sdist: bool,
2772
2773    /// Build a binary distribution ("wheel") from the given directory.
2774    #[arg(long)]
2775    pub wheel: bool,
2776
2777    /// When using the uv build backend, list the files that would be included when building.
2778    ///
2779    /// Skips building the actual distribution, except when the source distribution is needed to
2780    /// build the wheel. The file list is collected directly without a PEP 517 environment. It only
2781    /// works with the uv build backend, there is no PEP 517 file list build hook.
2782    ///
2783    /// This option can be combined with `--sdist` and `--wheel` for inspecting different build
2784    /// paths.
2785    // Hidden while in preview.
2786    #[arg(long, hide = true)]
2787    pub list: bool,
2788
2789    #[arg(long, overrides_with("no_build_logs"), hide = true)]
2790    pub build_logs: bool,
2791
2792    /// Hide logs from the build backend.
2793    #[arg(long, overrides_with("build_logs"))]
2794    pub no_build_logs: bool,
2795
2796    /// Always build through PEP 517, don't use the fast path for the uv build backend.
2797    ///
2798    /// By default, uv won't create a PEP 517 build environment for packages using the uv build
2799    /// backend, but use a fast path that calls into the build backend directly. This option forces
2800    /// always using PEP 517.
2801    #[arg(long, conflicts_with = "list")]
2802    pub force_pep517: bool,
2803
2804    /// Clear the output directory before the build, removing stale artifacts.
2805    #[arg(long)]
2806    pub clear: bool,
2807
2808    #[arg(long, overrides_with("no_create_gitignore"), hide = true)]
2809    pub create_gitignore: bool,
2810
2811    /// Do not create a `.gitignore` file in the output directory.
2812    ///
2813    /// By default, uv creates a `.gitignore` file in the output directory to exclude build
2814    /// artifacts from version control. When this flag is used, the file will be omitted.
2815    #[arg(long, overrides_with("create_gitignore"))]
2816    pub no_create_gitignore: bool,
2817
2818    /// Constrain build dependencies using the given requirements files when building distributions.
2819    ///
2820    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
2821    /// build dependency that's installed. However, including a package in a constraints file will
2822    /// _not_ trigger the inclusion of that package on its own.
2823    #[arg(long, short, alias = "build-constraint", env = EnvVars::UV_BUILD_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
2824    pub build_constraints: Vec<Maybe<PathBuf>>,
2825
2826    /// Require a matching hash for each requirement.
2827    ///
2828    /// By default, uv will verify any available hashes in the requirements file, but will not
2829    /// require that all requirements have an associated hash.
2830    ///
2831    /// When `--require-hashes` is enabled, _all_ requirements must include a hash or set of hashes,
2832    /// and _all_ requirements must either be pinned to exact versions (e.g., `==1.0.0`), or be
2833    /// specified via direct URL.
2834    ///
2835    /// Hash-checking mode introduces a number of additional constraints:
2836    ///
2837    /// - Git dependencies are not supported.
2838    /// - Editable installations are not supported.
2839    /// - Local dependencies are not supported, unless they point to a specific wheel (`.whl`) or
2840    ///   source archive (`.zip`, `.tar.gz`), as opposed to a directory.
2841    #[arg(
2842        long,
2843        env = EnvVars::UV_REQUIRE_HASHES,
2844        value_parser = clap::builder::BoolishValueParser::new(),
2845        overrides_with("no_require_hashes"),
2846    )]
2847    pub require_hashes: bool,
2848
2849    #[arg(long, overrides_with("require_hashes"), hide = true)]
2850    pub no_require_hashes: bool,
2851
2852    #[arg(long, overrides_with("no_verify_hashes"), hide = true)]
2853    pub verify_hashes: bool,
2854
2855    /// Disable validation of hashes in the requirements file.
2856    ///
2857    /// By default, uv will verify any available hashes in the requirements file, but will not
2858    /// require that all requirements have an associated hash. To enforce hash validation, use
2859    /// `--require-hashes`.
2860    #[arg(
2861        long,
2862        env = EnvVars::UV_NO_VERIFY_HASHES,
2863        value_parser = clap::builder::BoolishValueParser::new(),
2864        overrides_with("verify_hashes"),
2865    )]
2866    pub no_verify_hashes: bool,
2867
2868    /// The Python interpreter to use for the build environment.
2869    ///
2870    /// By default, builds are executed in isolated virtual environments. The discovered interpreter
2871    /// will be used to create those environments, and will be symlinked or copied in depending on
2872    /// the platform.
2873    ///
2874    /// See `uv help python` to view supported request formats.
2875    #[arg(
2876        long,
2877        short,
2878        env = EnvVars::UV_PYTHON,
2879        verbatim_doc_comment,
2880        help_heading = "Python options",
2881        value_parser = parse_maybe_string,
2882    )]
2883    pub python: Option<Maybe<String>>,
2884
2885    #[command(flatten)]
2886    pub resolver: ResolverArgs,
2887
2888    #[command(flatten)]
2889    pub build: BuildOptionsArgs,
2890
2891    #[command(flatten)]
2892    pub refresh: RefreshArgs,
2893}
2894
2895#[derive(Args)]
2896pub struct VenvArgs {
2897    /// The Python interpreter to use for the virtual environment.
2898    ///
2899    /// During virtual environment creation, uv will not look for Python interpreters in virtual
2900    /// environments.
2901    ///
2902    /// See `uv help python` for details on Python discovery and supported request formats.
2903    #[arg(
2904        long,
2905        short,
2906        env = EnvVars::UV_PYTHON,
2907        verbatim_doc_comment,
2908        help_heading = "Python options",
2909        value_parser = parse_maybe_string,
2910    )]
2911    pub python: Option<Maybe<String>>,
2912
2913    /// Ignore virtual environments when searching for the Python interpreter.
2914    ///
2915    /// This is the default behavior and has no effect.
2916    #[arg(
2917        long,
2918        env = EnvVars::UV_SYSTEM_PYTHON,
2919        value_parser = clap::builder::BoolishValueParser::new(),
2920        overrides_with("no_system"),
2921        hide = true,
2922    )]
2923    pub system: bool,
2924
2925    /// This flag is included for compatibility only, it has no effect.
2926    ///
2927    /// uv will never search for interpreters in virtual environments when creating a virtual
2928    /// environment.
2929    #[arg(long, overrides_with("system"), hide = true)]
2930    pub no_system: bool,
2931
2932    /// Avoid discovering a project or workspace.
2933    ///
2934    /// By default, uv searches for projects in the current directory or any parent directory to
2935    /// determine the default path of the virtual environment and check for Python version
2936    /// constraints, if any.
2937    #[arg(long, alias = "no-workspace")]
2938    pub no_project: bool,
2939
2940    /// Install seed packages (one or more of: `pip`, `setuptools`, and `wheel`) into the virtual environment.
2941    ///
2942    /// Note that `setuptools` and `wheel` are not included in Python 3.12+ environments.
2943    #[arg(long, value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_VENV_SEED)]
2944    pub seed: bool,
2945
2946    /// Remove any existing files or directories at the target path.
2947    ///
2948    /// By default, `uv venv` will exit with an error if the given path is non-empty. The
2949    /// `--clear` option will instead clear a non-empty path before creating a new virtual
2950    /// environment.
2951    #[clap(long, short, overrides_with = "allow_existing", value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_VENV_CLEAR)]
2952    pub clear: bool,
2953
2954    /// Fail without prompting if any existing files or directories are present at the target path.
2955    ///
2956    /// By default, when a TTY is available, `uv venv` will prompt to clear a non-empty directory.
2957    /// When `--no-clear` is used, the command will exit with an error instead of prompting.
2958    #[clap(
2959        long,
2960        overrides_with = "clear",
2961        conflicts_with = "allow_existing",
2962        hide = true
2963    )]
2964    pub no_clear: bool,
2965
2966    /// Preserve any existing files or directories at the target path.
2967    ///
2968    /// By default, `uv venv` will exit with an error if the given path is non-empty. The
2969    /// `--allow-existing` option will instead write to the given path, regardless of its contents,
2970    /// and without clearing it beforehand.
2971    ///
2972    /// WARNING: This option can lead to unexpected behavior if the existing virtual environment and
2973    /// the newly-created virtual environment are linked to different Python interpreters.
2974    #[clap(long, overrides_with = "clear")]
2975    pub allow_existing: bool,
2976
2977    /// The path to the virtual environment to create.
2978    ///
2979    /// Default to `.venv` in the working directory.
2980    ///
2981    /// Relative paths are resolved relative to the working directory.
2982    pub path: Option<PathBuf>,
2983
2984    /// Provide an alternative prompt prefix for the virtual environment.
2985    ///
2986    /// By default, the prompt is dependent on whether a path was provided to `uv venv`. If provided
2987    /// (e.g, `uv venv project`), the prompt is set to the directory name. If not provided
2988    /// (`uv venv`), the prompt is set to the current directory's name.
2989    ///
2990    /// If "." is provided, the current directory name will be used regardless of whether a path was
2991    /// provided to `uv venv`.
2992    #[arg(long, verbatim_doc_comment)]
2993    pub prompt: Option<String>,
2994
2995    /// Give the virtual environment access to the system site packages directory.
2996    ///
2997    /// Unlike `pip`, when a virtual environment is created with `--system-site-packages`, uv will
2998    /// _not_ take system site packages into account when running commands like `uv pip list` or `uv
2999    /// pip install`. The `--system-site-packages` flag will provide the virtual environment with
3000    /// access to the system site packages directory at runtime, but will not affect the behavior of
3001    /// uv commands.
3002    #[arg(long)]
3003    pub system_site_packages: bool,
3004
3005    /// Make the virtual environment relocatable.
3006    ///
3007    /// A relocatable virtual environment can be moved around and redistributed without invalidating
3008    /// its associated entrypoint and activation scripts.
3009    ///
3010    /// Note that this can only be guaranteed for standard `console_scripts` and `gui_scripts`.
3011    /// Other scripts may be adjusted if they ship with a generic `#!python[w]` shebang, and
3012    /// binaries are left as-is.
3013    ///
3014    /// As a result of making the environment relocatable (by way of writing relative, rather than
3015    /// absolute paths), the entrypoints and scripts themselves will _not_ be relocatable. In other
3016    /// words, copying those entrypoints and scripts to a location outside the environment will not
3017    /// work, as they reference paths relative to the environment itself.
3018    #[arg(long)]
3019    pub relocatable: bool,
3020
3021    #[command(flatten)]
3022    pub index_args: IndexArgs,
3023
3024    /// The strategy to use when resolving against multiple index URLs.
3025    ///
3026    /// By default, uv will stop at the first index on which a given package is available, and
3027    /// limit resolutions to those present on that first index (`first-index`). This prevents
3028    /// "dependency confusion" attacks, whereby an attacker can upload a malicious package under the
3029    /// same name to an alternate index.
3030    #[arg(long, value_enum, env = EnvVars::UV_INDEX_STRATEGY)]
3031    pub index_strategy: Option<IndexStrategy>,
3032
3033    /// Attempt to use `keyring` for authentication for index URLs.
3034    ///
3035    /// At present, only `--keyring-provider subprocess` is supported, which configures uv to use
3036    /// the `keyring` CLI to handle authentication.
3037    ///
3038    /// Defaults to `disabled`.
3039    #[arg(long, value_enum, env = EnvVars::UV_KEYRING_PROVIDER)]
3040    pub keyring_provider: Option<KeyringProviderType>,
3041
3042    /// Limit candidate packages to those that were uploaded prior to the given date.
3043    ///
3044    /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
3045    /// format (e.g., `2006-12-02`) in your system's configured time zone.
3046    #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER)]
3047    pub exclude_newer: Option<ExcludeNewerTimestamp>,
3048
3049    /// Limit candidate packages for a specific package to those that were uploaded prior to the given date.
3050    ///
3051    /// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp
3052    /// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone.
3053    ///
3054    /// Can be provided multiple times for different packages.
3055    #[arg(long)]
3056    pub exclude_newer_package: Option<Vec<ExcludeNewerPackageEntry>>,
3057
3058    /// The method to use when installing packages from the global cache.
3059    ///
3060    /// This option is only used for installing seed packages.
3061    ///
3062    /// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
3063    /// Windows.
3064    ///
3065    /// WARNING: The use of symlink link mode is discouraged, as they create tight coupling between
3066    /// the cache and the target environment. For example, clearing the cache (`uv cache clean`)
3067    /// will break all installed packages by way of removing the underlying source files. Use
3068    /// symlinks with caution.
3069    #[arg(long, value_enum, env = EnvVars::UV_LINK_MODE)]
3070    pub link_mode: Option<uv_install_wheel::LinkMode>,
3071
3072    #[command(flatten)]
3073    pub refresh: RefreshArgs,
3074
3075    #[command(flatten)]
3076    pub compat_args: compat::VenvCompatArgs,
3077}
3078
3079#[derive(Parser, Debug, Clone)]
3080pub enum ExternalCommand {
3081    #[command(external_subcommand)]
3082    Cmd(Vec<OsString>),
3083}
3084
3085impl Deref for ExternalCommand {
3086    type Target = Vec<OsString>;
3087
3088    fn deref(&self) -> &Self::Target {
3089        match self {
3090            Self::Cmd(cmd) => cmd,
3091        }
3092    }
3093}
3094
3095impl DerefMut for ExternalCommand {
3096    fn deref_mut(&mut self) -> &mut Self::Target {
3097        match self {
3098            Self::Cmd(cmd) => cmd,
3099        }
3100    }
3101}
3102
3103impl ExternalCommand {
3104    pub fn split(&self) -> (Option<&OsString>, &[OsString]) {
3105        match self.as_slice() {
3106            [] => (None, &[]),
3107            [cmd, args @ ..] => (Some(cmd), args),
3108        }
3109    }
3110}
3111
3112#[derive(Debug, Default, Copy, Clone, clap::ValueEnum)]
3113pub enum AuthorFrom {
3114    /// Fetch the author information from some sources (e.g., Git) automatically.
3115    #[default]
3116    Auto,
3117    /// Fetch the author information from Git configuration only.
3118    Git,
3119    /// Do not infer the author information.
3120    None,
3121}
3122
3123#[derive(Args)]
3124pub struct InitArgs {
3125    /// The path to use for the project/script.
3126    ///
3127    /// Defaults to the current working directory when initializing an app or library; required when
3128    /// initializing a script. Accepts relative and absolute paths.
3129    ///
3130    /// If a `pyproject.toml` is found in any of the parent directories of the target path, the
3131    /// project will be added as a workspace member of the parent, unless `--no-workspace` is
3132    /// provided.
3133    #[arg(required_if_eq("script", "true"))]
3134    pub path: Option<PathBuf>,
3135
3136    /// The name of the project.
3137    ///
3138    /// Defaults to the name of the directory.
3139    #[arg(long, conflicts_with = "script")]
3140    pub name: Option<PackageName>,
3141
3142    /// Only create a `pyproject.toml`.
3143    ///
3144    /// Disables creating extra files like `README.md`, the `src/` tree, `.python-version` files,
3145    /// etc.
3146    #[arg(long, conflicts_with = "script")]
3147    pub bare: bool,
3148
3149    /// Create a virtual project, rather than a package.
3150    ///
3151    /// This option is deprecated and will be removed in a future release.
3152    #[arg(long, hide = true, conflicts_with = "package")]
3153    pub r#virtual: bool,
3154
3155    /// Set up the project to be built as a Python package.
3156    ///
3157    /// Defines a `[build-system]` for the project.
3158    ///
3159    /// This is the default behavior when using `--lib` or `--build-backend`.
3160    ///
3161    /// When using `--app`, this will include a `[project.scripts]` entrypoint and use a `src/`
3162    /// project structure.
3163    #[arg(long, overrides_with = "no_package")]
3164    pub r#package: bool,
3165
3166    /// Do not set up the project to be built as a Python package.
3167    ///
3168    /// Does not include a `[build-system]` for the project.
3169    ///
3170    /// This is the default behavior when using `--app`.
3171    #[arg(long, overrides_with = "package", conflicts_with_all = ["lib", "build_backend"])]
3172    pub r#no_package: bool,
3173
3174    /// Create a project for an application.
3175    ///
3176    /// This is the default behavior if `--lib` is not requested.
3177    ///
3178    /// This project kind is for web servers, scripts, and command-line interfaces.
3179    ///
3180    /// By default, an application is not intended to be built and distributed as a Python package.
3181    /// The `--package` option can be used to create an application that is distributable, e.g., if
3182    /// you want to distribute a command-line interface via PyPI.
3183    #[arg(long, alias = "application", conflicts_with_all = ["lib", "script"])]
3184    pub r#app: bool,
3185
3186    /// Create a project for a library.
3187    ///
3188    /// A library is a project that is intended to be built and distributed as a Python package.
3189    #[arg(long, alias = "library", conflicts_with_all=["app", "script"])]
3190    pub r#lib: bool,
3191
3192    /// Create a script.
3193    ///
3194    /// A script is a standalone file with embedded metadata enumerating its dependencies, along
3195    /// with any Python version requirements, as defined in the PEP 723 specification.
3196    ///
3197    /// PEP 723 scripts can be executed directly with `uv run`.
3198    ///
3199    /// By default, adds a requirement on the system Python version; use `--python` to specify an
3200    /// alternative Python version requirement.
3201    #[arg(long, conflicts_with_all=["app", "lib", "package", "build_backend", "description"])]
3202    pub r#script: bool,
3203
3204    /// Set the project description.
3205    #[arg(long, conflicts_with = "script", overrides_with = "no_description")]
3206    pub description: Option<String>,
3207
3208    /// Disable the description for the project.
3209    #[arg(long, conflicts_with = "script", overrides_with = "description")]
3210    pub no_description: bool,
3211
3212    /// Initialize a version control system for the project.
3213    ///
3214    /// By default, uv will initialize a Git repository (`git`). Use `--vcs none` to explicitly
3215    /// avoid initializing a version control system.
3216    #[arg(long, value_enum, conflicts_with = "script")]
3217    pub vcs: Option<VersionControlSystem>,
3218
3219    /// Initialize a build-backend of choice for the project.
3220    ///
3221    /// Implicitly sets `--package`.
3222    #[arg(long, value_enum, conflicts_with_all=["script", "no_package"], env = EnvVars::UV_INIT_BUILD_BACKEND)]
3223    pub build_backend: Option<ProjectBuildBackend>,
3224
3225    /// Invalid option name for build backend.
3226    #[arg(
3227        long,
3228        required(false),
3229        action(clap::ArgAction::SetTrue),
3230        value_parser=clap::builder::UnknownArgumentValueParser::suggest_arg("--build-backend"),
3231        hide(true)
3232    )]
3233    backend: Option<String>,
3234
3235    /// Do not create a `README.md` file.
3236    #[arg(long)]
3237    pub no_readme: bool,
3238
3239    /// Fill in the `authors` field in the `pyproject.toml`.
3240    ///
3241    /// By default, uv will attempt to infer the author information from some sources (e.g., Git)
3242    /// (`auto`). Use `--author-from git` to only infer from Git configuration. Use `--author-from
3243    /// none` to avoid inferring the author information.
3244    #[arg(long, value_enum)]
3245    pub author_from: Option<AuthorFrom>,
3246
3247    /// Do not create a `.python-version` file for the project.
3248    ///
3249    /// By default, uv will create a `.python-version` file containing the minor version of the
3250    /// discovered Python interpreter, which will cause subsequent uv commands to use that version.
3251    #[arg(long)]
3252    pub no_pin_python: bool,
3253
3254    /// Create a `.python-version` file for the project.
3255    ///
3256    /// This is the default.
3257    #[arg(long, hide = true)]
3258    pub pin_python: bool,
3259
3260    /// Avoid discovering a workspace and create a standalone project.
3261    ///
3262    /// By default, uv searches for workspaces in the current directory or any parent directory.
3263    #[arg(long, alias = "no-project")]
3264    pub no_workspace: bool,
3265
3266    /// The Python interpreter to use to determine the minimum supported Python version.
3267    ///
3268    /// See `uv help python` to view supported request formats.
3269    #[arg(
3270        long,
3271        short,
3272        env = EnvVars::UV_PYTHON,
3273        verbatim_doc_comment,
3274        help_heading = "Python options",
3275        value_parser = parse_maybe_string,
3276    )]
3277    pub python: Option<Maybe<String>>,
3278}
3279
3280#[derive(Args)]
3281pub struct RunArgs {
3282    /// Include optional dependencies from the specified extra name.
3283    ///
3284    /// May be provided more than once.
3285    ///
3286    /// Optional dependencies are defined via `project.optional-dependencies` in a `pyproject.toml`.
3287    ///
3288    /// This option is only available when running in a project.
3289    #[arg(long, conflicts_with = "all_extras", conflicts_with = "only_group", value_parser = extra_name_with_clap_error)]
3290    pub extra: Option<Vec<ExtraName>>,
3291
3292    /// Include all optional dependencies.
3293    ///
3294    /// Optional dependencies are defined via `project.optional-dependencies` in a `pyproject.toml`.
3295    ///
3296    /// This option is only available when running in a project.
3297    #[arg(long, conflicts_with = "extra", conflicts_with = "only_group")]
3298    pub all_extras: bool,
3299
3300    /// Exclude the specified optional dependencies, if `--all-extras` is supplied.
3301    ///
3302    /// May be provided multiple times.
3303    #[arg(long)]
3304    pub no_extra: Vec<ExtraName>,
3305
3306    #[arg(long, overrides_with("all_extras"), hide = true)]
3307    pub no_all_extras: bool,
3308
3309    /// Include the development dependency group.
3310    ///
3311    /// Development dependencies are defined via `dependency-groups.dev` or
3312    /// `tool.uv.dev-dependencies` in a `pyproject.toml`.
3313    ///
3314    /// This option is an alias for `--group dev`.
3315    ///
3316    /// This option is only available when running in a project.
3317    #[arg(long, overrides_with("no_dev"), hide = true, env = EnvVars::UV_DEV, value_parser = clap::builder::BoolishValueParser::new())]
3318    pub dev: bool,
3319
3320    /// Disable the development dependency group.
3321    ///
3322    /// This option is an alias of `--no-group dev`.
3323    /// See `--no-default-groups` to disable all default groups instead.
3324    ///
3325    /// This option is only available when running in a project.
3326    #[arg(long, overrides_with("dev"), env = EnvVars::UV_NO_DEV, value_parser = clap::builder::BoolishValueParser::new())]
3327    pub no_dev: bool,
3328
3329    /// Include dependencies from the specified dependency group.
3330    ///
3331    /// May be provided multiple times.
3332    #[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
3333    pub group: Vec<GroupName>,
3334
3335    /// Disable the specified dependency group.
3336    ///
3337    /// This option always takes precedence over default groups,
3338    /// `--all-groups`, and `--group`.
3339    ///
3340    /// May be provided multiple times.
3341    #[arg(long, env = EnvVars::UV_NO_GROUP, value_delimiter = ' ')]
3342    pub no_group: Vec<GroupName>,
3343
3344    /// Ignore the default dependency groups.
3345    ///
3346    /// uv includes the groups defined in `tool.uv.default-groups` by default.
3347    /// This disables that option, however, specific groups can still be included with `--group`.
3348    #[arg(long, env = EnvVars::UV_NO_DEFAULT_GROUPS)]
3349    pub no_default_groups: bool,
3350
3351    /// Only include dependencies from the specified dependency group.
3352    ///
3353    /// The project and its dependencies will be omitted.
3354    ///
3355    /// May be provided multiple times. Implies `--no-default-groups`.
3356    #[arg(long, conflicts_with_all = ["group", "dev", "all_groups"])]
3357    pub only_group: Vec<GroupName>,
3358
3359    /// Include dependencies from all dependency groups.
3360    ///
3361    /// `--no-group` can be used to exclude specific groups.
3362    #[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
3363    pub all_groups: bool,
3364
3365    /// Run a Python module.
3366    ///
3367    /// Equivalent to `python -m <module>`.
3368    #[arg(short, long, conflicts_with_all = ["script", "gui_script"])]
3369    pub module: bool,
3370
3371    /// Only include the development dependency group.
3372    ///
3373    /// The project and its dependencies will be omitted.
3374    ///
3375    /// This option is an alias for `--only-group dev`. Implies `--no-default-groups`.
3376    #[arg(long, conflicts_with_all = ["group", "all_groups", "no_dev"])]
3377    pub only_dev: bool,
3378
3379    /// Install any non-editable dependencies, including the project and any workspace members, as
3380    /// editable.
3381    #[arg(long, overrides_with = "no_editable", hide = true)]
3382    pub editable: bool,
3383
3384    /// Install any editable dependencies, including the project and any workspace members, as
3385    /// non-editable.
3386    #[arg(long, overrides_with = "editable", value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_NO_EDITABLE)]
3387    pub no_editable: bool,
3388
3389    /// Do not remove extraneous packages present in the environment.
3390    #[arg(long, overrides_with("exact"), alias = "no-exact", hide = true)]
3391    pub inexact: bool,
3392
3393    /// Perform an exact sync, removing extraneous packages.
3394    ///
3395    /// When enabled, uv will remove any extraneous packages from the environment. By default, `uv
3396    /// run` will make the minimum necessary changes to satisfy the requirements.
3397    #[arg(long, overrides_with("inexact"))]
3398    pub exact: bool,
3399
3400    /// Load environment variables from a `.env` file.
3401    ///
3402    /// Can be provided multiple times, with subsequent files overriding values defined in previous
3403    /// files.
3404    #[arg(long, env = EnvVars::UV_ENV_FILE)]
3405    pub env_file: Vec<String>,
3406
3407    /// Avoid reading environment variables from a `.env` file.
3408    #[arg(long, value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_NO_ENV_FILE)]
3409    pub no_env_file: bool,
3410
3411    /// The command to run.
3412    ///
3413    /// If the path to a Python script (i.e., ending in `.py`), it will be
3414    /// executed with the Python interpreter.
3415    #[command(subcommand)]
3416    pub command: Option<ExternalCommand>,
3417
3418    /// Run with the given packages installed.
3419    ///
3420    /// When used in a project, these dependencies will be layered on top of the project environment
3421    /// in a separate, ephemeral environment. These dependencies are allowed to conflict with those
3422    /// specified by the project.
3423    #[arg(short = 'w', long)]
3424    pub with: Vec<comma::CommaSeparatedRequirements>,
3425
3426    /// Run with the given packages installed in editable mode.
3427    ///
3428    /// When used in a project, these dependencies will be layered on top of the project environment
3429    /// in a separate, ephemeral environment. These dependencies are allowed to conflict with those
3430    /// specified by the project.
3431    #[arg(long)]
3432    pub with_editable: Vec<comma::CommaSeparatedRequirements>,
3433
3434    /// Run with the packages listed in the given files.
3435    ///
3436    /// The following formats are supported: `requirements.txt`, `.py` files with inline metadata,
3437    /// and `pylock.toml`.
3438    ///
3439    /// The same environment semantics as `--with` apply.
3440    ///
3441    /// Using `pyproject.toml`, `setup.py`, or `setup.cfg` files is not allowed.
3442    #[arg(long, value_delimiter = ',', value_parser = parse_maybe_file_path)]
3443    pub with_requirements: Vec<Maybe<PathBuf>>,
3444
3445    /// Run the command in an isolated virtual environment.
3446    ///
3447    /// Usually, the project environment is reused for performance. This option forces a fresh
3448    /// environment to be used for the project, enforcing strict isolation between dependencies and
3449    /// declaration of requirements.
3450    ///
3451    /// An editable installation is still used for the project.
3452    ///
3453    /// When used with `--with` or `--with-requirements`, the additional dependencies will still be
3454    /// layered in a second environment.
3455    #[arg(long, env = EnvVars::UV_ISOLATED, value_parser = clap::builder::BoolishValueParser::new())]
3456    pub isolated: bool,
3457
3458    /// Prefer the active virtual environment over the project's virtual environment.
3459    ///
3460    /// If the project virtual environment is active or no virtual environment is active, this has
3461    /// no effect.
3462    #[arg(long, overrides_with = "no_active")]
3463    pub active: bool,
3464
3465    /// Prefer project's virtual environment over an active environment.
3466    ///
3467    /// This is the default behavior.
3468    #[arg(long, overrides_with = "active", hide = true)]
3469    pub no_active: bool,
3470
3471    /// Avoid syncing the virtual environment.
3472    ///
3473    /// Implies `--frozen`, as the project dependencies will be ignored (i.e., the lockfile will not
3474    /// be updated, since the environment will not be synced regardless).
3475    #[arg(long, env = EnvVars::UV_NO_SYNC, value_parser = clap::builder::BoolishValueParser::new())]
3476    pub no_sync: bool,
3477
3478    /// Assert that the `uv.lock` will remain unchanged.
3479    ///
3480    /// Requires that the lockfile is up-to-date. If the lockfile is missing or
3481    /// needs to be updated, uv will exit with an error.
3482    #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])]
3483    pub locked: bool,
3484
3485    /// Run without updating the `uv.lock` file.
3486    ///
3487    /// Instead of checking if the lockfile is up-to-date, uses the versions in the lockfile as the
3488    /// source of truth. If the lockfile is missing, uv will exit with an error. If the
3489    /// `pyproject.toml` includes changes to dependencies that have not been included in the
3490    /// lockfile yet, they will not be present in the environment.
3491    #[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["locked", "upgrade", "no_sources"])]
3492    pub frozen: bool,
3493
3494    /// Run the given path as a Python script.
3495    ///
3496    /// Using `--script` will attempt to parse the path as a PEP 723 script,
3497    /// irrespective of its extension.
3498    #[arg(long, short, conflicts_with_all = ["module", "gui_script"])]
3499    pub script: bool,
3500
3501    /// Run the given path as a Python GUI script.
3502    ///
3503    /// Using `--gui-script` will attempt to parse the path as a PEP 723 script and run it with
3504    /// `pythonw.exe`, irrespective of its extension. Only available on Windows.
3505    #[arg(long, conflicts_with_all = ["script", "module"])]
3506    pub gui_script: bool,
3507
3508    #[command(flatten)]
3509    pub installer: ResolverInstallerArgs,
3510
3511    #[command(flatten)]
3512    pub build: BuildOptionsArgs,
3513
3514    #[command(flatten)]
3515    pub refresh: RefreshArgs,
3516
3517    /// Run the command with all workspace members installed.
3518    ///
3519    /// The workspace's environment (`.venv`) is updated to include all workspace members.
3520    ///
3521    /// Any extras or groups specified via `--extra`, `--group`, or related options will be applied
3522    /// to all workspace members.
3523    #[arg(long, conflicts_with = "package")]
3524    pub all_packages: bool,
3525
3526    /// Run the command in a specific package in the workspace.
3527    ///
3528    /// If the workspace member does not exist, uv will exit with an error.
3529    #[arg(long, conflicts_with = "all_packages")]
3530    pub package: Option<PackageName>,
3531
3532    /// Avoid discovering the project or workspace.
3533    ///
3534    /// Instead of searching for projects in the current directory and parent directories, run in an
3535    /// isolated, ephemeral environment populated by the `--with` requirements.
3536    ///
3537    /// If a virtual environment is active or found in a current or parent directory, it will be
3538    /// used as if there was no project or workspace.
3539    #[arg(long, alias = "no_workspace", conflicts_with = "package")]
3540    pub no_project: bool,
3541
3542    /// The Python interpreter to use for the run environment.
3543    ///
3544    /// If the interpreter request is satisfied by a discovered environment, the environment will be
3545    /// used.
3546    ///
3547    /// See `uv help python` to view supported request formats.
3548    #[arg(
3549        long,
3550        short,
3551        env = EnvVars::UV_PYTHON,
3552        verbatim_doc_comment,
3553        help_heading = "Python options",
3554        value_parser = parse_maybe_string,
3555    )]
3556    pub python: Option<Maybe<String>>,
3557
3558    /// Whether to show resolver and installer output from any environment modifications.
3559    ///
3560    /// By default, environment modifications are omitted, but enabled under `--verbose`.
3561    #[arg(long, env = EnvVars::UV_SHOW_RESOLUTION, value_parser = clap::builder::BoolishValueParser::new(), hide = true)]
3562    pub show_resolution: bool,
3563
3564    /// Number of times that `uv run` will allow recursive invocations.
3565    ///
3566    /// The current recursion depth is tracked by environment variable. If environment variables are
3567    /// cleared, uv will fail to detect the recursion depth.
3568    ///
3569    /// If uv reaches the maximum recursion depth, it will exit with an error.
3570    #[arg(long, hide = true, env = EnvVars::UV_RUN_MAX_RECURSION_DEPTH)]
3571    pub max_recursion_depth: Option<u32>,
3572
3573    /// The platform for which requirements should be installed.
3574    ///
3575    /// Represented as a "target triple", a string that describes the target platform in terms of
3576    /// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
3577    /// `aarch64-apple-darwin`.
3578    ///
3579    /// When targeting macOS (Darwin), the default minimum version is `13.0`. Use
3580    /// `MACOSX_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
3581    ///
3582    /// When targeting iOS, the default minimum version is `13.0`. Use
3583    /// `IPHONEOS_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
3584    ///
3585    /// When targeting Android, the default minimum Android API level is `24`. Use
3586    /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`.
3587    ///
3588    /// WARNING: When specified, uv will select wheels that are compatible with the _target_
3589    /// platform; as a result, the installed distributions may not be compatible with the _current_
3590    /// platform. Conversely, any distributions that are built from source may be incompatible with
3591    /// the _target_ platform, as they will be built for the _current_ platform. The
3592    /// `--python-platform` option is intended for advanced use cases.
3593    #[arg(long)]
3594    pub python_platform: Option<TargetTriple>,
3595}
3596
3597#[derive(Args)]
3598pub struct SyncArgs {
3599    /// Include optional dependencies from the specified extra name.
3600    ///
3601    /// May be provided more than once.
3602    ///
3603    /// When multiple extras or groups are specified that appear in `tool.uv.conflicts`, uv will
3604    /// report an error.
3605    ///
3606    /// Note that all optional dependencies are always included in the resolution; this option only
3607    /// affects the selection of packages to install.
3608    #[arg(long, conflicts_with = "all_extras", conflicts_with = "only_group", value_parser = extra_name_with_clap_error)]
3609    pub extra: Option<Vec<ExtraName>>,
3610
3611    /// Select the output format.
3612    #[arg(long, value_enum, default_value_t = SyncFormat::default())]
3613    pub output_format: SyncFormat,
3614
3615    /// Include all optional dependencies.
3616    ///
3617    /// When two or more extras are declared as conflicting in `tool.uv.conflicts`, using this flag
3618    /// will always result in an error.
3619    ///
3620    /// Note that all optional dependencies are always included in the resolution; this option only
3621    /// affects the selection of packages to install.
3622    #[arg(long, conflicts_with = "extra", conflicts_with = "only_group")]
3623    pub all_extras: bool,
3624
3625    /// Exclude the specified optional dependencies, if `--all-extras` is supplied.
3626    ///
3627    /// May be provided multiple times.
3628    #[arg(long)]
3629    pub no_extra: Vec<ExtraName>,
3630
3631    #[arg(long, overrides_with("all_extras"), hide = true)]
3632    pub no_all_extras: bool,
3633
3634    /// Include the development dependency group.
3635    ///
3636    /// This option is an alias for `--group dev`.
3637    #[arg(long, overrides_with("no_dev"), hide = true, env = EnvVars::UV_DEV, value_parser = clap::builder::BoolishValueParser::new())]
3638    pub dev: bool,
3639
3640    /// Disable the development dependency group.
3641    ///
3642    /// This option is an alias of `--no-group dev`.
3643    /// See `--no-default-groups` to disable all default groups instead.
3644    #[arg(long, overrides_with("dev"), env = EnvVars::UV_NO_DEV, value_parser = clap::builder::BoolishValueParser::new())]
3645    pub no_dev: bool,
3646
3647    /// Only include the development dependency group.
3648    ///
3649    /// The project and its dependencies will be omitted.
3650    ///
3651    /// This option is an alias for `--only-group dev`. Implies `--no-default-groups`.
3652    #[arg(long, conflicts_with_all = ["group", "all_groups", "no_dev"])]
3653    pub only_dev: bool,
3654
3655    /// Include dependencies from the specified dependency group.
3656    ///
3657    /// When multiple extras or groups are specified that appear in
3658    /// `tool.uv.conflicts`, uv will report an error.
3659    ///
3660    /// May be provided multiple times.
3661    #[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
3662    pub group: Vec<GroupName>,
3663
3664    /// Disable the specified dependency group.
3665    ///
3666    /// This option always takes precedence over default groups,
3667    /// `--all-groups`, and `--group`.
3668    ///
3669    /// May be provided multiple times.
3670    #[arg(long, env = EnvVars::UV_NO_GROUP, value_delimiter = ' ')]
3671    pub no_group: Vec<GroupName>,
3672
3673    /// Ignore the default dependency groups.
3674    ///
3675    /// uv includes the groups defined in `tool.uv.default-groups` by default.
3676    /// This disables that option, however, specific groups can still be included with `--group`.
3677    #[arg(long, env = EnvVars::UV_NO_DEFAULT_GROUPS)]
3678    pub no_default_groups: bool,
3679
3680    /// Only include dependencies from the specified dependency group.
3681    ///
3682    /// The project and its dependencies will be omitted.
3683    ///
3684    /// May be provided multiple times. Implies `--no-default-groups`.
3685    #[arg(long, conflicts_with_all = ["group", "dev", "all_groups"])]
3686    pub only_group: Vec<GroupName>,
3687
3688    /// Include dependencies from all dependency groups.
3689    ///
3690    /// `--no-group` can be used to exclude specific groups.
3691    #[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
3692    pub all_groups: bool,
3693
3694    /// Install any non-editable dependencies, including the project and any workspace members, as
3695    /// editable.
3696    #[arg(long, overrides_with = "no_editable", hide = true)]
3697    pub editable: bool,
3698
3699    /// Install any editable dependencies, including the project and any workspace members, as
3700    /// non-editable.
3701    #[arg(long, overrides_with = "editable", value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_NO_EDITABLE)]
3702    pub no_editable: bool,
3703
3704    /// Do not remove extraneous packages present in the environment.
3705    ///
3706    /// When enabled, uv will make the minimum necessary changes to satisfy the requirements.
3707    /// By default, syncing will remove any extraneous packages from the environment
3708    #[arg(long, overrides_with("exact"), alias = "no-exact")]
3709    pub inexact: bool,
3710
3711    /// Perform an exact sync, removing extraneous packages.
3712    #[arg(long, overrides_with("inexact"), hide = true)]
3713    pub exact: bool,
3714
3715    /// Sync dependencies to the active virtual environment.
3716    ///
3717    /// Instead of creating or updating the virtual environment for the project or script, the
3718    /// active virtual environment will be preferred, if the `VIRTUAL_ENV` environment variable is
3719    /// set.
3720    #[arg(long, overrides_with = "no_active")]
3721    pub active: bool,
3722
3723    /// Prefer project's virtual environment over an active environment.
3724    ///
3725    /// This is the default behavior.
3726    #[arg(long, overrides_with = "active", hide = true)]
3727    pub no_active: bool,
3728
3729    /// Do not install the current project.
3730    ///
3731    /// By default, the current project is installed into the environment with all of its
3732    /// dependencies. The `--no-install-project` option allows the project to be excluded, but all
3733    /// of its dependencies are still installed. This is particularly useful in situations like
3734    /// building Docker images where installing the project separately from its dependencies allows
3735    /// optimal layer caching.
3736    ///
3737    /// The inverse `--only-install-project` can be used to install _only_ the project itself,
3738    /// excluding all dependencies.
3739    #[arg(long, conflicts_with = "only_install_project")]
3740    pub no_install_project: bool,
3741
3742    /// Only install the current project.
3743    #[arg(long, conflicts_with = "no_install_project", hide = true)]
3744    pub only_install_project: bool,
3745
3746    /// Do not install any workspace members, including the root project.
3747    ///
3748    /// By default, all workspace members and their dependencies are installed into the
3749    /// environment. The `--no-install-workspace` option allows exclusion of all the workspace
3750    /// members while retaining their dependencies. This is particularly useful in situations like
3751    /// building Docker images where installing the workspace separately from its dependencies
3752    /// allows optimal layer caching.
3753    ///
3754    /// The inverse `--only-install-workspace` can be used to install _only_ workspace members,
3755    /// excluding all other dependencies.
3756    #[arg(long, conflicts_with = "only_install_workspace")]
3757    pub no_install_workspace: bool,
3758
3759    /// Only install workspace members, including the root project.
3760    #[arg(long, conflicts_with = "no_install_workspace", hide = true)]
3761    pub only_install_workspace: bool,
3762
3763    /// Do not install local path dependencies
3764    ///
3765    /// Skips the current project, workspace members, and any other local (path or editable)
3766    /// packages. Only remote/indexed dependencies are installed. Useful in Docker builds to cache
3767    /// heavy third-party dependencies first and layer local packages separately.
3768    ///
3769    /// The inverse `--only-install-local` can be used to install _only_ local packages, excluding
3770    /// all remote dependencies.
3771    #[arg(long, conflicts_with = "only_install_local")]
3772    pub no_install_local: bool,
3773
3774    /// Only install local path dependencies
3775    #[arg(long, conflicts_with = "no_install_local", hide = true)]
3776    pub only_install_local: bool,
3777
3778    /// Do not install the given package(s).
3779    ///
3780    /// By default, all of the project's dependencies are installed into the environment. The
3781    /// `--no-install-package` option allows exclusion of specific packages. Note this can result
3782    /// in a broken environment, and should be used with caution.
3783    ///
3784    /// The inverse `--only-install-package` can be used to install _only_ the specified packages,
3785    /// excluding all others.
3786    #[arg(long, conflicts_with = "only_install_package")]
3787    pub no_install_package: Vec<PackageName>,
3788
3789    /// Only install the given package(s).
3790    #[arg(long, conflicts_with = "no_install_package", hide = true)]
3791    pub only_install_package: Vec<PackageName>,
3792
3793    /// Assert that the `uv.lock` will remain unchanged.
3794    ///
3795    /// Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated,
3796    /// uv will exit with an error.
3797    #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])]
3798    pub locked: bool,
3799
3800    /// Sync without updating the `uv.lock` file.
3801    ///
3802    /// Instead of checking if the lockfile is up-to-date, uses the versions in the lockfile as the
3803    /// source of truth. If the lockfile is missing, uv will exit with an error. If the
3804    /// `pyproject.toml` includes changes to dependencies that have not been included in the
3805    /// lockfile yet, they will not be present in the environment.
3806    #[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["locked", "upgrade", "no_sources"])]
3807    pub frozen: bool,
3808
3809    /// Perform a dry run, without writing the lockfile or modifying the project environment.
3810    ///
3811    /// In dry-run mode, uv will resolve the project's dependencies and report on the resulting
3812    /// changes to both the lockfile and the project environment, but will not modify either.
3813    #[arg(long)]
3814    pub dry_run: bool,
3815
3816    #[command(flatten)]
3817    pub installer: ResolverInstallerArgs,
3818
3819    #[command(flatten)]
3820    pub build: BuildOptionsArgs,
3821
3822    #[command(flatten)]
3823    pub refresh: RefreshArgs,
3824
3825    /// Sync all packages in the workspace.
3826    ///
3827    /// The workspace's environment (`.venv`) is updated to include all workspace members.
3828    ///
3829    /// Any extras or groups specified via `--extra`, `--group`, or related options will be applied
3830    /// to all workspace members.
3831    #[arg(long, conflicts_with = "package")]
3832    pub all_packages: bool,
3833
3834    /// Sync for specific packages in the workspace.
3835    ///
3836    /// The workspace's environment (`.venv`) is updated to reflect the subset of dependencies
3837    /// declared by the specified workspace member packages.
3838    ///
3839    /// If any workspace member does not exist, uv will exit with an error.
3840    #[arg(long, conflicts_with = "all_packages")]
3841    pub package: Vec<PackageName>,
3842
3843    /// Sync the environment for a Python script, rather than the current project.
3844    ///
3845    /// If provided, uv will sync the dependencies based on the script's inline metadata table, in
3846    /// adherence with PEP 723.
3847    #[arg(
3848        long,
3849        conflicts_with = "all_packages",
3850        conflicts_with = "package",
3851        conflicts_with = "no_install_project",
3852        conflicts_with = "no_install_workspace",
3853        conflicts_with = "no_install_local",
3854        conflicts_with = "extra",
3855        conflicts_with = "all_extras",
3856        conflicts_with = "no_extra",
3857        conflicts_with = "no_all_extras",
3858        conflicts_with = "dev",
3859        conflicts_with = "no_dev",
3860        conflicts_with = "only_dev",
3861        conflicts_with = "group",
3862        conflicts_with = "no_group",
3863        conflicts_with = "no_default_groups",
3864        conflicts_with = "only_group",
3865        conflicts_with = "all_groups"
3866    )]
3867    pub script: Option<PathBuf>,
3868
3869    /// The Python interpreter to use for the project environment.
3870    ///
3871    /// By default, the first interpreter that meets the project's `requires-python` constraint is
3872    /// used.
3873    ///
3874    /// If a Python interpreter in a virtual environment is provided, the packages will not be
3875    /// synced to the given environment. The interpreter will be used to create a virtual
3876    /// environment in the project.
3877    ///
3878    /// See `uv help python` for details on Python discovery and supported request formats.
3879    #[arg(
3880        long,
3881        short,
3882        env = EnvVars::UV_PYTHON,
3883        verbatim_doc_comment,
3884        help_heading = "Python options",
3885        value_parser = parse_maybe_string,
3886    )]
3887    pub python: Option<Maybe<String>>,
3888
3889    /// The platform for which requirements should be installed.
3890    ///
3891    /// Represented as a "target triple", a string that describes the target platform in terms of
3892    /// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
3893    /// `aarch64-apple-darwin`.
3894    ///
3895    /// When targeting macOS (Darwin), the default minimum version is `13.0`. Use
3896    /// `MACOSX_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
3897    ///
3898    /// When targeting iOS, the default minimum version is `13.0`. Use
3899    /// `IPHONEOS_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
3900    ///
3901    /// When targeting Android, the default minimum Android API level is `24`. Use
3902    /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`.
3903    ///
3904    /// WARNING: When specified, uv will select wheels that are compatible with the _target_
3905    /// platform; as a result, the installed distributions may not be compatible with the _current_
3906    /// platform. Conversely, any distributions that are built from source may be incompatible with
3907    /// the _target_ platform, as they will be built for the _current_ platform. The
3908    /// `--python-platform` option is intended for advanced use cases.
3909    #[arg(long)]
3910    pub python_platform: Option<TargetTriple>,
3911
3912    /// Check if the Python environment is synchronized with the project.
3913    ///
3914    /// If the environment is not up to date, uv will exit with an error.
3915    #[arg(long, overrides_with("no_check"))]
3916    pub check: bool,
3917
3918    #[arg(long, overrides_with("check"), hide = true)]
3919    pub no_check: bool,
3920}
3921
3922#[derive(Args)]
3923pub struct LockArgs {
3924    /// Check if the lockfile is up-to-date.
3925    ///
3926    /// Asserts that the `uv.lock` would remain unchanged after a resolution. If the lockfile is
3927    /// missing or needs to be updated, uv will exit with an error.
3928    ///
3929    /// Equivalent to `--locked`.
3930    #[arg(long, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["check_exists", "upgrade"], overrides_with = "check")]
3931    pub check: bool,
3932
3933    /// Check if the lockfile is up-to-date.
3934    ///
3935    /// Asserts that the `uv.lock` would remain unchanged after a resolution. If the lockfile is
3936    /// missing or needs to be updated, uv will exit with an error.
3937    ///
3938    /// Equivalent to `--check`.
3939    #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["check_exists", "upgrade"], hide = true)]
3940    pub locked: bool,
3941
3942    /// Assert that a `uv.lock` exists without checking if it is up-to-date.
3943    ///
3944    /// Equivalent to `--frozen`.
3945    #[arg(long, alias = "frozen", env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["check", "locked"])]
3946    pub check_exists: bool,
3947
3948    /// Perform a dry run, without writing the lockfile.
3949    ///
3950    /// In dry-run mode, uv will resolve the project's dependencies and report on the resulting
3951    /// changes, but will not write the lockfile to disk.
3952    #[arg(
3953        long,
3954        conflicts_with = "check_exists",
3955        conflicts_with = "check",
3956        conflicts_with = "locked"
3957    )]
3958    pub dry_run: bool,
3959
3960    /// Lock the specified Python script, rather than the current project.
3961    ///
3962    /// If provided, uv will lock the script (based on its inline metadata table, in adherence with
3963    /// PEP 723) to a `.lock` file adjacent to the script itself.
3964    #[arg(long)]
3965    pub script: Option<PathBuf>,
3966
3967    #[command(flatten)]
3968    pub resolver: ResolverArgs,
3969
3970    #[command(flatten)]
3971    pub build: BuildOptionsArgs,
3972
3973    #[command(flatten)]
3974    pub refresh: RefreshArgs,
3975
3976    /// The Python interpreter to use during resolution.
3977    ///
3978    /// A Python interpreter is required for building source distributions to determine package
3979    /// metadata when there are not wheels.
3980    ///
3981    /// The interpreter is also used as the fallback value for the minimum Python version if
3982    /// `requires-python` is not set.
3983    ///
3984    /// See `uv help python` for details on Python discovery and supported request formats.
3985    #[arg(
3986        long,
3987        short,
3988        env = EnvVars::UV_PYTHON,
3989        verbatim_doc_comment,
3990        help_heading = "Python options",
3991        value_parser = parse_maybe_string,
3992    )]
3993    pub python: Option<Maybe<String>>,
3994}
3995
3996#[derive(Args)]
3997#[command(group = clap::ArgGroup::new("sources").required(true).multiple(true))]
3998pub struct AddArgs {
3999    /// The packages to add, as PEP 508 requirements (e.g., `ruff==0.5.0`).
4000    #[arg(group = "sources")]
4001    pub packages: Vec<String>,
4002
4003    /// Add the packages listed in the given files.
4004    ///
4005    /// The following formats are supported: `requirements.txt`, `.py` files with inline metadata,
4006    /// `pylock.toml`, `pyproject.toml`, `setup.py`, and `setup.cfg`.
4007    #[arg(long, short, alias = "requirement", group = "sources", value_parser = parse_file_path)]
4008    pub requirements: Vec<PathBuf>,
4009
4010    /// Constrain versions using the given requirements files.
4011    ///
4012    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
4013    /// requirement that's installed. The constraints will _not_ be added to the project's
4014    /// `pyproject.toml` file, but _will_ be respected during dependency resolution.
4015    ///
4016    /// This is equivalent to pip's `--constraint` option.
4017    #[arg(long, short, alias = "constraint", env = EnvVars::UV_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
4018    pub constraints: Vec<Maybe<PathBuf>>,
4019
4020    /// Apply this marker to all added packages.
4021    #[arg(long, short, value_parser = MarkerTree::from_str)]
4022    pub marker: Option<MarkerTree>,
4023
4024    /// Add the requirements to the development dependency group.
4025    ///
4026    /// This option is an alias for `--group dev`.
4027    #[arg(
4028        long,
4029        conflicts_with("optional"),
4030        conflicts_with("group"),
4031        conflicts_with("script"),
4032        env = EnvVars::UV_DEV,
4033        value_parser = clap::builder::BoolishValueParser::new()
4034    )]
4035    pub dev: bool,
4036
4037    /// Add the requirements to the package's optional dependencies for the specified extra.
4038    ///
4039    /// The group may then be activated when installing the project with the `--extra` flag.
4040    ///
4041    /// To enable an optional extra for this requirement instead, see `--extra`.
4042    #[arg(long, conflicts_with("dev"), conflicts_with("group"))]
4043    pub optional: Option<ExtraName>,
4044
4045    /// Add the requirements to the specified dependency group.
4046    ///
4047    /// These requirements will not be included in the published metadata for the project.
4048    #[arg(
4049        long,
4050        conflicts_with("dev"),
4051        conflicts_with("optional"),
4052        conflicts_with("script")
4053    )]
4054    pub group: Option<GroupName>,
4055
4056    /// Add the requirements as editable.
4057    #[arg(long, overrides_with = "no_editable")]
4058    pub editable: bool,
4059
4060    #[arg(long, overrides_with = "editable", hide = true, value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_NO_EDITABLE)]
4061    pub no_editable: bool,
4062
4063    /// Add a dependency as provided.
4064    ///
4065    /// By default, uv will use the `tool.uv.sources` section to record source information for Git,
4066    /// local, editable, and direct URL requirements. When `--raw` is provided, uv will add source
4067    /// requirements to `project.dependencies`, rather than `tool.uv.sources`.
4068    ///
4069    /// Additionally, by default, uv will add bounds to your dependency, e.g., `foo>=1.0.0`. When
4070    /// `--raw` is provided, uv will add the dependency without bounds.
4071    #[arg(
4072        long,
4073        conflicts_with = "editable",
4074        conflicts_with = "no_editable",
4075        conflicts_with = "rev",
4076        conflicts_with = "tag",
4077        conflicts_with = "branch",
4078        alias = "raw-sources"
4079    )]
4080    pub raw: bool,
4081
4082    /// The kind of version specifier to use when adding dependencies.
4083    ///
4084    /// When adding a dependency to the project, if no constraint or URL is provided, a constraint
4085    /// is added based on the latest compatible version of the package. By default, a lower bound
4086    /// constraint is used, e.g., `>=1.2.3`.
4087    ///
4088    /// When `--frozen` is provided, no resolution is performed, and dependencies are always added
4089    /// without constraints.
4090    ///
4091    /// This option is in preview and may change in any future release.
4092    #[arg(long, value_enum)]
4093    pub bounds: Option<AddBoundsKind>,
4094
4095    /// Commit to use when adding a dependency from Git.
4096    #[arg(long, group = "git-ref", action = clap::ArgAction::Set)]
4097    pub rev: Option<String>,
4098
4099    /// Tag to use when adding a dependency from Git.
4100    #[arg(long, group = "git-ref", action = clap::ArgAction::Set)]
4101    pub tag: Option<String>,
4102
4103    /// Branch to use when adding a dependency from Git.
4104    #[arg(long, group = "git-ref", action = clap::ArgAction::Set)]
4105    pub branch: Option<String>,
4106
4107    /// Whether to use Git LFS when adding a dependency from Git.
4108    #[arg(long, env = EnvVars::UV_GIT_LFS, value_parser = clap::builder::BoolishValueParser::new())]
4109    pub lfs: bool,
4110
4111    /// Extras to enable for the dependency.
4112    ///
4113    /// May be provided more than once.
4114    ///
4115    /// To add this dependency to an optional extra instead, see `--optional`.
4116    #[arg(long)]
4117    pub extra: Option<Vec<ExtraName>>,
4118
4119    /// Avoid syncing the virtual environment.
4120    #[arg(long, env = EnvVars::UV_NO_SYNC, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")]
4121    pub no_sync: bool,
4122
4123    /// Assert that the `uv.lock` will remain unchanged.
4124    ///
4125    /// Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated,
4126    /// uv will exit with an error.
4127    #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])]
4128    pub locked: bool,
4129
4130    /// Add dependencies without re-locking the project.
4131    ///
4132    /// The project environment will not be synced.
4133    #[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["locked", "upgrade", "no_sources"])]
4134    pub frozen: bool,
4135
4136    /// Prefer the active virtual environment over the project's virtual environment.
4137    ///
4138    /// If the project virtual environment is active or no virtual environment is active, this has
4139    /// no effect.
4140    #[arg(long, overrides_with = "no_active")]
4141    pub active: bool,
4142
4143    /// Prefer project's virtual environment over an active environment.
4144    ///
4145    /// This is the default behavior.
4146    #[arg(long, overrides_with = "active", hide = true)]
4147    pub no_active: bool,
4148
4149    #[command(flatten)]
4150    pub installer: ResolverInstallerArgs,
4151
4152    #[command(flatten)]
4153    pub build: BuildOptionsArgs,
4154
4155    #[command(flatten)]
4156    pub refresh: RefreshArgs,
4157
4158    /// Add the dependency to a specific package in the workspace.
4159    #[arg(long, conflicts_with = "isolated")]
4160    pub package: Option<PackageName>,
4161
4162    /// Add the dependency to the specified Python script, rather than to a project.
4163    ///
4164    /// If provided, uv will add the dependency to the script's inline metadata table, in adherence
4165    /// with PEP 723. If no such inline metadata table is present, a new one will be created and
4166    /// added to the script. When executed via `uv run`, uv will create a temporary environment for
4167    /// the script with all inline dependencies installed.
4168    #[arg(
4169        long,
4170        conflicts_with = "dev",
4171        conflicts_with = "optional",
4172        conflicts_with = "package",
4173        conflicts_with = "workspace"
4174    )]
4175    pub script: Option<PathBuf>,
4176
4177    /// The Python interpreter to use for resolving and syncing.
4178    ///
4179    /// See `uv help python` for details on Python discovery and supported request formats.
4180    #[arg(
4181        long,
4182        short,
4183        env = EnvVars::UV_PYTHON,
4184        verbatim_doc_comment,
4185        help_heading = "Python options",
4186        value_parser = parse_maybe_string,
4187    )]
4188    pub python: Option<Maybe<String>>,
4189
4190    /// Add the dependency as a workspace member.
4191    ///
4192    /// By default, uv will add path dependencies that are within the workspace directory
4193    /// as workspace members. When used with a path dependency, the package will be added
4194    /// to the workspace's `members` list in the root `pyproject.toml` file.
4195    #[arg(long, overrides_with = "no_workspace")]
4196    pub workspace: bool,
4197
4198    /// Don't add the dependency as a workspace member.
4199    ///
4200    /// By default, when adding a dependency that's a local path and is within the workspace
4201    /// directory, uv will add it as a workspace member; pass `--no-workspace` to add the package
4202    /// as direct path dependency instead.
4203    #[arg(long, overrides_with = "workspace")]
4204    pub no_workspace: bool,
4205
4206    /// Do not install the current project.
4207    ///
4208    /// By default, the current project is installed into the environment with all of its
4209    /// dependencies. The `--no-install-project` option allows the project to be excluded, but all of
4210    /// its dependencies are still installed. This is particularly useful in situations like building
4211    /// Docker images where installing the project separately from its dependencies allows optimal
4212    /// layer caching.
4213    ///
4214    /// The inverse `--only-install-project` can be used to install _only_ the project itself,
4215    /// excluding all dependencies.
4216    #[arg(
4217        long,
4218        conflicts_with = "frozen",
4219        conflicts_with = "no_sync",
4220        conflicts_with = "only_install_project"
4221    )]
4222    pub no_install_project: bool,
4223
4224    /// Only install the current project.
4225    #[arg(
4226        long,
4227        conflicts_with = "frozen",
4228        conflicts_with = "no_sync",
4229        conflicts_with = "no_install_project",
4230        hide = true
4231    )]
4232    pub only_install_project: bool,
4233
4234    /// Do not install any workspace members, including the current project.
4235    ///
4236    /// By default, all workspace members and their dependencies are installed into the
4237    /// environment. The `--no-install-workspace` option allows exclusion of all the workspace
4238    /// members while retaining their dependencies. This is particularly useful in situations like
4239    /// building Docker images where installing the workspace separately from its dependencies
4240    /// allows optimal layer caching.
4241    ///
4242    /// The inverse `--only-install-workspace` can be used to install _only_ workspace members,
4243    /// excluding all other dependencies.
4244    #[arg(
4245        long,
4246        conflicts_with = "frozen",
4247        conflicts_with = "no_sync",
4248        conflicts_with = "only_install_workspace"
4249    )]
4250    pub no_install_workspace: bool,
4251
4252    /// Only install workspace members, including the current project.
4253    #[arg(
4254        long,
4255        conflicts_with = "frozen",
4256        conflicts_with = "no_sync",
4257        conflicts_with = "no_install_workspace",
4258        hide = true
4259    )]
4260    pub only_install_workspace: bool,
4261
4262    /// Do not install local path dependencies
4263    ///
4264    /// Skips the current project, workspace members, and any other local (path or editable)
4265    /// packages. Only remote/indexed dependencies are installed. Useful in Docker builds to cache
4266    /// heavy third-party dependencies first and layer local packages separately.
4267    ///
4268    /// The inverse `--only-install-local` can be used to install _only_ local packages, excluding
4269    /// all remote dependencies.
4270    #[arg(
4271        long,
4272        conflicts_with = "frozen",
4273        conflicts_with = "no_sync",
4274        conflicts_with = "only_install_local"
4275    )]
4276    pub no_install_local: bool,
4277
4278    /// Only install local path dependencies
4279    #[arg(
4280        long,
4281        conflicts_with = "frozen",
4282        conflicts_with = "no_sync",
4283        conflicts_with = "no_install_local",
4284        hide = true
4285    )]
4286    pub only_install_local: bool,
4287
4288    /// Do not install the given package(s).
4289    ///
4290    /// By default, all project's dependencies are installed into the environment. The
4291    /// `--no-install-package` option allows exclusion of specific packages. Note this can result
4292    /// in a broken environment, and should be used with caution.
4293    ///
4294    /// The inverse `--only-install-package` can be used to install _only_ the specified packages,
4295    /// excluding all others.
4296    #[arg(
4297        long,
4298        conflicts_with = "frozen",
4299        conflicts_with = "no_sync",
4300        conflicts_with = "only_install_package"
4301    )]
4302    pub no_install_package: Vec<PackageName>,
4303
4304    /// Only install the given package(s).
4305    #[arg(
4306        long,
4307        conflicts_with = "frozen",
4308        conflicts_with = "no_sync",
4309        conflicts_with = "no_install_package",
4310        hide = true
4311    )]
4312    pub only_install_package: Vec<PackageName>,
4313}
4314
4315#[derive(Args)]
4316pub struct RemoveArgs {
4317    /// The names of the dependencies to remove (e.g., `ruff`).
4318    #[arg(required = true)]
4319    pub packages: Vec<Requirement<VerbatimParsedUrl>>,
4320
4321    /// Remove the packages from the development dependency group.
4322    ///
4323    /// This option is an alias for `--group dev`.
4324    #[arg(long, conflicts_with("optional"), conflicts_with("group"), env = EnvVars::UV_DEV, value_parser = clap::builder::BoolishValueParser::new())]
4325    pub dev: bool,
4326
4327    /// Remove the packages from the project's optional dependencies for the specified extra.
4328    #[arg(
4329        long,
4330        conflicts_with("dev"),
4331        conflicts_with("group"),
4332        conflicts_with("script")
4333    )]
4334    pub optional: Option<ExtraName>,
4335
4336    /// Remove the packages from the specified dependency group.
4337    #[arg(
4338        long,
4339        conflicts_with("dev"),
4340        conflicts_with("optional"),
4341        conflicts_with("script")
4342    )]
4343    pub group: Option<GroupName>,
4344
4345    /// Avoid syncing the virtual environment after re-locking the project.
4346    #[arg(long, env = EnvVars::UV_NO_SYNC, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")]
4347    pub no_sync: bool,
4348
4349    /// Prefer the active virtual environment over the project's virtual environment.
4350    ///
4351    /// If the project virtual environment is active or no virtual environment is active, this has
4352    /// no effect.
4353    #[arg(long, overrides_with = "no_active")]
4354    pub active: bool,
4355
4356    /// Prefer project's virtual environment over an active environment.
4357    ///
4358    /// This is the default behavior.
4359    #[arg(long, overrides_with = "active", hide = true)]
4360    pub no_active: bool,
4361
4362    /// Assert that the `uv.lock` will remain unchanged.
4363    ///
4364    /// Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated,
4365    /// uv will exit with an error.
4366    #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])]
4367    pub locked: bool,
4368
4369    /// Remove dependencies without re-locking the project.
4370    ///
4371    /// The project environment will not be synced.
4372    #[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["locked", "upgrade", "no_sources"])]
4373    pub frozen: bool,
4374
4375    #[command(flatten)]
4376    pub installer: ResolverInstallerArgs,
4377
4378    #[command(flatten)]
4379    pub build: BuildOptionsArgs,
4380
4381    #[command(flatten)]
4382    pub refresh: RefreshArgs,
4383
4384    /// Remove the dependencies from a specific package in the workspace.
4385    #[arg(long, conflicts_with = "isolated")]
4386    pub package: Option<PackageName>,
4387
4388    /// Remove the dependency from the specified Python script, rather than from a project.
4389    ///
4390    /// If provided, uv will remove the dependency from the script's inline metadata table, in
4391    /// adherence with PEP 723.
4392    #[arg(long)]
4393    pub script: Option<PathBuf>,
4394
4395    /// The Python interpreter to use for resolving and syncing.
4396    ///
4397    /// See `uv help python` for details on Python discovery and supported request formats.
4398    #[arg(
4399        long,
4400        short,
4401        env = EnvVars::UV_PYTHON,
4402        verbatim_doc_comment,
4403        help_heading = "Python options",
4404        value_parser = parse_maybe_string,
4405    )]
4406    pub python: Option<Maybe<String>>,
4407}
4408
4409#[derive(Args)]
4410pub struct TreeArgs {
4411    /// Show a platform-independent dependency tree.
4412    ///
4413    /// Shows resolved package versions for all Python versions and platforms, rather than filtering
4414    /// to those that are relevant for the current environment.
4415    ///
4416    /// Multiple versions may be shown for a each package.
4417    #[arg(long)]
4418    pub universal: bool,
4419
4420    #[command(flatten)]
4421    pub tree: DisplayTreeArgs,
4422
4423    /// Include the development dependency group.
4424    ///
4425    /// Development dependencies are defined via `dependency-groups.dev` or
4426    /// `tool.uv.dev-dependencies` in a `pyproject.toml`.
4427    ///
4428    /// This option is an alias for `--group dev`.
4429    #[arg(long, overrides_with("no_dev"), hide = true, env = EnvVars::UV_DEV, value_parser = clap::builder::BoolishValueParser::new())]
4430    pub dev: bool,
4431
4432    /// Only include the development dependency group.
4433    ///
4434    /// The project and its dependencies will be omitted.
4435    ///
4436    /// This option is an alias for `--only-group dev`. Implies `--no-default-groups`.
4437    #[arg(long, conflicts_with_all = ["group", "all_groups", "no_dev"])]
4438    pub only_dev: bool,
4439
4440    /// Disable the development dependency group.
4441    ///
4442    /// This option is an alias of `--no-group dev`.
4443    /// See `--no-default-groups` to disable all default groups instead.
4444    #[arg(long, overrides_with("dev"), env = EnvVars::UV_NO_DEV, value_parser = clap::builder::BoolishValueParser::new())]
4445    pub no_dev: bool,
4446
4447    /// Include dependencies from the specified dependency group.
4448    ///
4449    /// May be provided multiple times.
4450    #[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
4451    pub group: Vec<GroupName>,
4452
4453    /// Disable the specified dependency group.
4454    ///
4455    /// This option always takes precedence over default groups,
4456    /// `--all-groups`, and `--group`.
4457    ///
4458    /// May be provided multiple times.
4459    #[arg(long, env = EnvVars::UV_NO_GROUP, value_delimiter = ' ')]
4460    pub no_group: Vec<GroupName>,
4461
4462    /// Ignore the default dependency groups.
4463    ///
4464    /// uv includes the groups defined in `tool.uv.default-groups` by default.
4465    /// This disables that option, however, specific groups can still be included with `--group`.
4466    #[arg(long, env = EnvVars::UV_NO_DEFAULT_GROUPS)]
4467    pub no_default_groups: bool,
4468
4469    /// Only include dependencies from the specified dependency group.
4470    ///
4471    /// The project and its dependencies will be omitted.
4472    ///
4473    /// May be provided multiple times. Implies `--no-default-groups`.
4474    #[arg(long, conflicts_with_all = ["group", "dev", "all_groups"])]
4475    pub only_group: Vec<GroupName>,
4476
4477    /// Include dependencies from all dependency groups.
4478    ///
4479    /// `--no-group` can be used to exclude specific groups.
4480    #[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
4481    pub all_groups: bool,
4482
4483    /// Assert that the `uv.lock` will remain unchanged.
4484    ///
4485    /// Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated,
4486    /// uv will exit with an error.
4487    #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])]
4488    pub locked: bool,
4489
4490    /// Display the requirements without locking the project.
4491    ///
4492    /// If the lockfile is missing, uv will exit with an error.
4493    #[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["locked", "upgrade", "no_sources"])]
4494    pub frozen: bool,
4495
4496    #[command(flatten)]
4497    pub build: BuildOptionsArgs,
4498
4499    #[command(flatten)]
4500    pub resolver: ResolverArgs,
4501
4502    /// Show the dependency tree the specified PEP 723 Python script, rather than the current
4503    /// project.
4504    ///
4505    /// If provided, uv will resolve the dependencies based on its inline metadata table, in
4506    /// adherence with PEP 723.
4507    #[arg(long)]
4508    pub script: Option<PathBuf>,
4509
4510    /// The Python version to use when filtering the tree.
4511    ///
4512    /// For example, pass `--python-version 3.10` to display the dependencies that would be included
4513    /// when installing on Python 3.10.
4514    ///
4515    /// Defaults to the version of the discovered Python interpreter.
4516    #[arg(long, conflicts_with = "universal")]
4517    pub python_version: Option<PythonVersion>,
4518
4519    /// The platform to use when filtering the tree.
4520    ///
4521    /// For example, pass `--platform windows` to display the dependencies that would be included
4522    /// when installing on Windows.
4523    ///
4524    /// Represented as a "target triple", a string that describes the target platform in terms of
4525    /// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
4526    /// `aarch64-apple-darwin`.
4527    #[arg(long, conflicts_with = "universal")]
4528    pub python_platform: Option<TargetTriple>,
4529
4530    /// The Python interpreter to use for locking and filtering.
4531    ///
4532    /// By default, the tree is filtered to match the platform as reported by the Python
4533    /// interpreter. Use `--universal` to display the tree for all platforms, or use
4534    /// `--python-version` or `--python-platform` to override a subset of markers.
4535    ///
4536    /// See `uv help python` for details on Python discovery and supported request formats.
4537    #[arg(
4538        long,
4539        short,
4540        env = EnvVars::UV_PYTHON,
4541        verbatim_doc_comment,
4542        help_heading = "Python options",
4543        value_parser = parse_maybe_string,
4544    )]
4545    pub python: Option<Maybe<String>>,
4546}
4547
4548#[derive(Args)]
4549pub struct ExportArgs {
4550    #[allow(clippy::doc_markdown)]
4551    /// The format to which `uv.lock` should be exported.
4552    ///
4553    /// Supports `requirements.txt`, `pylock.toml` (PEP 751) and CycloneDX v1.5 JSON output formats.
4554    ///
4555    /// uv will infer the output format from the file extension of the output file, if
4556    /// provided. Otherwise, defaults to `requirements.txt`.
4557    #[arg(long, value_enum)]
4558    pub format: Option<ExportFormat>,
4559
4560    /// Export the entire workspace.
4561    ///
4562    /// The dependencies for all workspace members will be included in the exported requirements
4563    /// file.
4564    ///
4565    /// Any extras or groups specified via `--extra`, `--group`, or related options will be applied
4566    /// to all workspace members.
4567    #[arg(long, conflicts_with = "package")]
4568    pub all_packages: bool,
4569
4570    /// Export the dependencies for specific packages in the workspace.
4571    ///
4572    /// If any workspace member does not exist, uv will exit with an error.
4573    #[arg(long, conflicts_with = "all_packages")]
4574    pub package: Vec<PackageName>,
4575
4576    /// Prune the given package from the dependency tree.
4577    ///
4578    /// Pruned packages will be excluded from the exported requirements file, as will any
4579    /// dependencies that are no longer required after the pruned package is removed.
4580    #[arg(long, conflicts_with = "all_packages", value_name = "PACKAGE")]
4581    pub prune: Vec<PackageName>,
4582
4583    /// Include optional dependencies from the specified extra name.
4584    ///
4585    /// May be provided more than once.
4586    #[arg(long, conflicts_with = "all_extras", conflicts_with = "only_group", value_parser = extra_name_with_clap_error)]
4587    pub extra: Option<Vec<ExtraName>>,
4588
4589    /// Include all optional dependencies.
4590    #[arg(long, conflicts_with = "extra", conflicts_with = "only_group")]
4591    pub all_extras: bool,
4592
4593    /// Exclude the specified optional dependencies, if `--all-extras` is supplied.
4594    ///
4595    /// May be provided multiple times.
4596    #[arg(long)]
4597    pub no_extra: Vec<ExtraName>,
4598
4599    #[arg(long, overrides_with("all_extras"), hide = true)]
4600    pub no_all_extras: bool,
4601
4602    /// Include the development dependency group.
4603    ///
4604    /// This option is an alias for `--group dev`.
4605    #[arg(long, overrides_with("no_dev"), hide = true, env = EnvVars::UV_DEV, value_parser = clap::builder::BoolishValueParser::new())]
4606    pub dev: bool,
4607
4608    /// Disable the development dependency group.
4609    ///
4610    /// This option is an alias of `--no-group dev`.
4611    /// See `--no-default-groups` to disable all default groups instead.
4612    #[arg(long, overrides_with("dev"), env = EnvVars::UV_NO_DEV, value_parser = clap::builder::BoolishValueParser::new())]
4613    pub no_dev: bool,
4614
4615    /// Only include the development dependency group.
4616    ///
4617    /// The project and its dependencies will be omitted.
4618    ///
4619    /// This option is an alias for `--only-group dev`. Implies `--no-default-groups`.
4620    #[arg(long, conflicts_with_all = ["group", "all_groups", "no_dev"])]
4621    pub only_dev: bool,
4622
4623    /// Include dependencies from the specified dependency group.
4624    ///
4625    /// May be provided multiple times.
4626    #[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
4627    pub group: Vec<GroupName>,
4628
4629    /// Disable the specified dependency group.
4630    ///
4631    /// This option always takes precedence over default groups,
4632    /// `--all-groups`, and `--group`.
4633    ///
4634    /// May be provided multiple times.
4635    #[arg(long, env = EnvVars::UV_NO_GROUP, value_delimiter = ' ')]
4636    pub no_group: Vec<GroupName>,
4637
4638    /// Ignore the default dependency groups.
4639    ///
4640    /// uv includes the groups defined in `tool.uv.default-groups` by default.
4641    /// This disables that option, however, specific groups can still be included with `--group`.
4642    #[arg(long, env = EnvVars::UV_NO_DEFAULT_GROUPS)]
4643    pub no_default_groups: bool,
4644
4645    /// Only include dependencies from the specified dependency group.
4646    ///
4647    /// The project and its dependencies will be omitted.
4648    ///
4649    /// May be provided multiple times. Implies `--no-default-groups`.
4650    #[arg(long, conflicts_with_all = ["group", "dev", "all_groups"])]
4651    pub only_group: Vec<GroupName>,
4652
4653    /// Include dependencies from all dependency groups.
4654    ///
4655    /// `--no-group` can be used to exclude specific groups.
4656    #[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
4657    pub all_groups: bool,
4658
4659    /// Exclude comment annotations indicating the source of each package.
4660    #[arg(long, overrides_with("annotate"))]
4661    pub no_annotate: bool,
4662
4663    #[arg(long, overrides_with("no_annotate"), hide = true)]
4664    pub annotate: bool,
4665
4666    /// Exclude the comment header at the top of the generated output file.
4667    #[arg(long, overrides_with("header"))]
4668    pub no_header: bool,
4669
4670    #[arg(long, overrides_with("no_header"), hide = true)]
4671    pub header: bool,
4672
4673    /// Export any non-editable dependencies, including the project and any workspace members, as
4674    /// editable.
4675    #[arg(long, overrides_with = "no_editable", hide = true)]
4676    pub editable: bool,
4677
4678    /// Export any editable dependencies, including the project and any workspace members, as
4679    /// non-editable.
4680    #[arg(long, overrides_with = "editable", value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_NO_EDITABLE)]
4681    pub no_editable: bool,
4682
4683    /// Include hashes for all dependencies.
4684    #[arg(long, overrides_with("no_hashes"), hide = true)]
4685    pub hashes: bool,
4686
4687    /// Omit hashes in the generated output.
4688    #[arg(long, overrides_with("hashes"))]
4689    pub no_hashes: bool,
4690
4691    /// Write the exported requirements to the given file.
4692    #[arg(long, short)]
4693    pub output_file: Option<PathBuf>,
4694
4695    /// Do not emit the current project.
4696    ///
4697    /// By default, the current project is included in the exported requirements file with all of
4698    /// its dependencies. The `--no-emit-project` option allows the project to be excluded, but all
4699    /// of its dependencies to remain included.
4700    ///
4701    /// The inverse `--only-emit-project` can be used to emit _only_ the project itself, excluding
4702    /// all dependencies.
4703    #[arg(
4704        long,
4705        alias = "no-install-project",
4706        conflicts_with = "only_emit_project"
4707    )]
4708    pub no_emit_project: bool,
4709
4710    /// Only emit the current project.
4711    #[arg(
4712        long,
4713        alias = "only-install-project",
4714        conflicts_with = "no_emit_project",
4715        hide = true
4716    )]
4717    pub only_emit_project: bool,
4718
4719    /// Do not emit any workspace members, including the root project.
4720    ///
4721    /// By default, all workspace members and their dependencies are included in the exported
4722    /// requirements file, with all of their dependencies. The `--no-emit-workspace` option allows
4723    /// exclusion of all the workspace members while retaining their dependencies.
4724    ///
4725    /// The inverse `--only-emit-workspace` can be used to emit _only_ workspace members, excluding
4726    /// all other dependencies.
4727    #[arg(
4728        long,
4729        alias = "no-install-workspace",
4730        conflicts_with = "only_emit_workspace"
4731    )]
4732    pub no_emit_workspace: bool,
4733
4734    /// Only emit workspace members, including the root project.
4735    #[arg(
4736        long,
4737        alias = "only-install-workspace",
4738        conflicts_with = "no_emit_workspace",
4739        hide = true
4740    )]
4741    pub only_emit_workspace: bool,
4742
4743    /// Do not include local path dependencies in the exported requirements.
4744    ///
4745    /// Omits the current project, workspace members, and any other local (path or editable)
4746    /// packages from the export. Only remote/indexed dependencies are written. Useful for Docker
4747    /// and CI flows that want to export and cache third-party dependencies first.
4748    ///
4749    /// The inverse `--only-emit-local` can be used to emit _only_ local packages, excluding all
4750    /// remote dependencies.
4751    #[arg(long, alias = "no-install-local", conflicts_with = "only_emit_local")]
4752    pub no_emit_local: bool,
4753
4754    /// Only include local path dependencies in the exported requirements.
4755    #[arg(
4756        long,
4757        alias = "only-install-local",
4758        conflicts_with = "no_emit_local",
4759        hide = true
4760    )]
4761    pub only_emit_local: bool,
4762
4763    /// Do not emit the given package(s).
4764    ///
4765    /// By default, all project's dependencies are included in the exported requirements
4766    /// file. The `--no-emit-package` option allows exclusion of specific packages.
4767    ///
4768    /// The inverse `--only-emit-package` can be used to emit _only_ the specified packages,
4769    /// excluding all others.
4770    #[arg(
4771        long,
4772        alias = "no-install-package",
4773        conflicts_with = "only_emit_package"
4774    )]
4775    pub no_emit_package: Vec<PackageName>,
4776
4777    /// Only emit the given package(s).
4778    #[arg(
4779        long,
4780        alias = "only-install-package",
4781        conflicts_with = "no_emit_package",
4782        hide = true
4783    )]
4784    pub only_emit_package: Vec<PackageName>,
4785
4786    /// Assert that the `uv.lock` will remain unchanged.
4787    ///
4788    /// Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated,
4789    /// uv will exit with an error.
4790    #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["frozen", "upgrade"])]
4791    pub locked: bool,
4792
4793    /// Do not update the `uv.lock` before exporting.
4794    ///
4795    /// If a `uv.lock` does not exist, uv will exit with an error.
4796    #[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["locked", "upgrade", "no_sources"])]
4797    pub frozen: bool,
4798
4799    #[command(flatten)]
4800    pub resolver: ResolverArgs,
4801
4802    #[command(flatten)]
4803    pub build: BuildOptionsArgs,
4804
4805    #[command(flatten)]
4806    pub refresh: RefreshArgs,
4807
4808    /// Export the dependencies for the specified PEP 723 Python script, rather than the current
4809    /// project.
4810    ///
4811    /// If provided, uv will resolve the dependencies based on its inline metadata table, in
4812    /// adherence with PEP 723.
4813    #[arg(long, conflicts_with_all = ["all_packages", "package", "no_emit_project", "no_emit_workspace"])]
4814    pub script: Option<PathBuf>,
4815
4816    /// The Python interpreter to use during resolution.
4817    ///
4818    /// A Python interpreter is required for building source distributions to determine package
4819    /// metadata when there are not wheels.
4820    ///
4821    /// The interpreter is also used as the fallback value for the minimum Python version if
4822    /// `requires-python` is not set.
4823    ///
4824    /// See `uv help python` for details on Python discovery and supported request formats.
4825    #[arg(
4826        long,
4827        short,
4828        env = EnvVars::UV_PYTHON,
4829        verbatim_doc_comment,
4830        help_heading = "Python options",
4831        value_parser = parse_maybe_string,
4832    )]
4833    pub python: Option<Maybe<String>>,
4834}
4835
4836#[derive(Args)]
4837pub struct FormatArgs {
4838    /// Check if files are formatted without applying changes.
4839    #[arg(long)]
4840    pub check: bool,
4841
4842    /// Show a diff of formatting changes without applying them.
4843    ///
4844    /// Implies `--check`.
4845    #[arg(long)]
4846    pub diff: bool,
4847
4848    /// The version of Ruff to use for formatting.
4849    ///
4850    /// By default, a version of Ruff pinned by uv will be used.
4851    #[arg(long)]
4852    pub version: Option<String>,
4853
4854    /// Additional arguments to pass to Ruff.
4855    ///
4856    /// For example, use `uv format -- --line-length 100` to set the line length or
4857    /// `uv format -- src/module/foo.py` to format a specific file.
4858    #[arg(last = true)]
4859    pub extra_args: Vec<String>,
4860
4861    /// Avoid discovering a project or workspace.
4862    ///
4863    /// Instead of running the formatter in the context of the current project, run it in the
4864    /// context of the current directory. This is useful when the current directory is not a
4865    /// project.
4866    #[arg(long)]
4867    pub no_project: bool,
4868}
4869
4870#[derive(Args)]
4871pub struct AuthNamespace {
4872    #[command(subcommand)]
4873    pub command: AuthCommand,
4874}
4875
4876#[derive(Subcommand)]
4877pub enum AuthCommand {
4878    /// Login to a service
4879    Login(AuthLoginArgs),
4880    /// Logout of a service
4881    Logout(AuthLogoutArgs),
4882    /// Show the authentication token for a service
4883    Token(AuthTokenArgs),
4884    /// Show the path to the uv credentials directory.
4885    ///
4886    /// By default, credentials are stored in the uv data directory at
4887    /// `$XDG_DATA_HOME/uv/credentials` or `$HOME/.local/share/uv/credentials` on Unix and
4888    /// `%APPDATA%\uv\data\credentials` on Windows.
4889    ///
4890    /// The credentials directory may be overridden with `$UV_CREDENTIALS_DIR`.
4891    ///
4892    /// Credentials are only stored in this directory when the plaintext backend is used, as
4893    /// opposed to the native backend, which uses the system keyring.
4894    Dir(AuthDirArgs),
4895}
4896
4897#[derive(Args)]
4898pub struct ToolNamespace {
4899    #[command(subcommand)]
4900    pub command: ToolCommand,
4901}
4902
4903#[derive(Subcommand)]
4904pub enum ToolCommand {
4905    /// Run a command provided by a Python package.
4906    ///
4907    /// By default, the package to install is assumed to match the command name.
4908    ///
4909    /// The name of the command can include an exact version in the format `<package>@<version>`,
4910    /// e.g., `uv tool run ruff@0.3.0`. If more complex version specification is desired or if the
4911    /// command is provided by a different package, use `--from`.
4912    ///
4913    /// `uvx` can be used to invoke Python, e.g., with `uvx python` or `uvx python@<version>`. A
4914    /// Python interpreter will be started in an isolated virtual environment.
4915    ///
4916    /// If the tool was previously installed, i.e., via `uv tool install`, the installed version
4917    /// will be used unless a version is requested or the `--isolated` flag is used.
4918    ///
4919    /// `uvx` is provided as a convenient alias for `uv tool run`, their behavior is identical.
4920    ///
4921    /// If no command is provided, the installed tools are displayed.
4922    ///
4923    /// Packages are installed into an ephemeral virtual environment in the uv cache directory.
4924    #[command(
4925        after_help = "Use `uvx` as a shortcut for `uv tool run`.\n\n\
4926        Use `uv help tool run` for more details.",
4927        after_long_help = ""
4928    )]
4929    Run(ToolRunArgs),
4930    /// Hidden alias for `uv tool run` for the `uvx` command
4931    #[command(
4932        hide = true,
4933        override_usage = "uvx [OPTIONS] [COMMAND]",
4934        about = "Run a command provided by a Python package.",
4935        after_help = "Use `uv help tool run` for more details.",
4936        after_long_help = "",
4937        display_name = "uvx",
4938        long_version = crate::version::uv_self_version()
4939    )]
4940    Uvx(UvxArgs),
4941    /// Install commands provided by a Python package.
4942    ///
4943    /// Packages are installed into an isolated virtual environment in the uv tools directory. The
4944    /// executables are linked the tool executable directory, which is determined according to the
4945    /// XDG standard and can be retrieved with `uv tool dir --bin`.
4946    ///
4947    /// If the tool was previously installed, the existing tool will generally be replaced.
4948    Install(ToolInstallArgs),
4949    /// Upgrade installed tools.
4950    ///
4951    /// If a tool was installed with version constraints, they will be respected on upgrade — to
4952    /// upgrade a tool beyond the originally provided constraints, use `uv tool install` again.
4953    ///
4954    /// If a tool was installed with specific settings, they will be respected on upgraded. For
4955    /// example, if `--prereleases allow` was provided during installation, it will continue to be
4956    /// respected in upgrades.
4957    #[command(alias = "update")]
4958    Upgrade(ToolUpgradeArgs),
4959    /// List installed tools.
4960    #[command(alias = "ls")]
4961    List(ToolListArgs),
4962    /// Uninstall a tool.
4963    Uninstall(ToolUninstallArgs),
4964    /// Ensure that the tool executable directory is on the `PATH`.
4965    ///
4966    /// If the tool executable directory is not present on the `PATH`, uv will attempt to add it to
4967    /// the relevant shell configuration files.
4968    ///
4969    /// If the shell configuration files already include a blurb to add the executable directory to
4970    /// the path, but the directory is not present on the `PATH`, uv will exit with an error.
4971    ///
4972    /// The tool executable directory is determined according to the XDG standard and can be
4973    /// retrieved with `uv tool dir --bin`.
4974    #[command(alias = "ensurepath")]
4975    UpdateShell,
4976    /// Show the path to the uv tools directory.
4977    ///
4978    /// The tools directory is used to store environments and metadata for installed tools.
4979    ///
4980    /// By default, tools are stored in the uv data directory at `$XDG_DATA_HOME/uv/tools` or
4981    /// `$HOME/.local/share/uv/tools` on Unix and `%APPDATA%\uv\data\tools` on Windows.
4982    ///
4983    /// The tool installation directory may be overridden with `$UV_TOOL_DIR`.
4984    ///
4985    /// To instead view the directory uv installs executables into, use the `--bin` flag.
4986    Dir(ToolDirArgs),
4987}
4988
4989#[derive(Args)]
4990pub struct ToolRunArgs {
4991    /// The command to run.
4992    ///
4993    /// WARNING: The documentation for [`Self::command`] is not included in help output
4994    #[command(subcommand)]
4995    pub command: Option<ExternalCommand>,
4996
4997    /// Use the given package to provide the command.
4998    ///
4999    /// By default, the package name is assumed to match the command name.
5000    #[arg(long)]
5001    pub from: Option<String>,
5002
5003    /// Run with the given packages installed.
5004    #[arg(short = 'w', long)]
5005    pub with: Vec<comma::CommaSeparatedRequirements>,
5006
5007    /// Run with the given packages installed in editable mode
5008    ///
5009    /// When used in a project, these dependencies will be layered on top of the uv tool's
5010    /// environment in a separate, ephemeral environment. These dependencies are allowed to conflict
5011    /// with those specified.
5012    #[arg(long)]
5013    pub with_editable: Vec<comma::CommaSeparatedRequirements>,
5014
5015    /// Run with the packages listed in the given files.
5016    ///
5017    /// The following formats are supported: `requirements.txt`, `.py` files with inline metadata,
5018    /// and `pylock.toml`.
5019    #[arg(long, value_delimiter = ',', value_parser = parse_maybe_file_path)]
5020    pub with_requirements: Vec<Maybe<PathBuf>>,
5021
5022    /// Constrain versions using the given requirements files.
5023    ///
5024    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
5025    /// requirement that's installed. However, including a package in a constraints file will _not_
5026    /// trigger the installation of that package.
5027    ///
5028    /// This is equivalent to pip's `--constraint` option.
5029    #[arg(long, short, alias = "constraint", env = EnvVars::UV_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
5030    pub constraints: Vec<Maybe<PathBuf>>,
5031
5032    /// Constrain build dependencies using the given requirements files when building source
5033    /// distributions.
5034    ///
5035    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
5036    /// requirement that's installed. However, including a package in a constraints file will _not_
5037    /// trigger the installation of that package.
5038    #[arg(long, short, alias = "build-constraint", env = EnvVars::UV_BUILD_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
5039    pub build_constraints: Vec<Maybe<PathBuf>>,
5040
5041    /// Override versions using the given requirements files.
5042    ///
5043    /// Overrides files are `requirements.txt`-like files that force a specific version of a
5044    /// requirement to be installed, regardless of the requirements declared by any constituent
5045    /// package, and regardless of whether this would be considered an invalid resolution.
5046    ///
5047    /// While constraints are _additive_, in that they're combined with the requirements of the
5048    /// constituent packages, overrides are _absolute_, in that they completely replace the
5049    /// requirements of the constituent packages.
5050    #[arg(long, alias = "override", env = EnvVars::UV_OVERRIDE, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
5051    pub overrides: Vec<Maybe<PathBuf>>,
5052
5053    /// Run the tool in an isolated virtual environment, ignoring any already-installed tools.
5054    #[arg(long, env = EnvVars::UV_ISOLATED, value_parser = clap::builder::BoolishValueParser::new())]
5055    pub isolated: bool,
5056
5057    /// Load environment variables from a `.env` file.
5058    ///
5059    /// Can be provided multiple times, with subsequent files overriding values defined in previous
5060    /// files.
5061    #[arg(long, value_delimiter = ' ', env = EnvVars::UV_ENV_FILE)]
5062    pub env_file: Vec<PathBuf>,
5063
5064    /// Avoid reading environment variables from a `.env` file.
5065    #[arg(long, value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_NO_ENV_FILE)]
5066    pub no_env_file: bool,
5067
5068    #[command(flatten)]
5069    pub installer: ResolverInstallerArgs,
5070
5071    #[command(flatten)]
5072    pub build: BuildOptionsArgs,
5073
5074    #[command(flatten)]
5075    pub refresh: RefreshArgs,
5076
5077    /// Whether to use Git LFS when adding a dependency from Git.
5078    #[arg(long, env = EnvVars::UV_GIT_LFS, value_parser = clap::builder::BoolishValueParser::new())]
5079    pub lfs: bool,
5080
5081    /// The Python interpreter to use to build the run environment.
5082    ///
5083    /// See `uv help python` for details on Python discovery and supported request formats.
5084    #[arg(
5085        long,
5086        short,
5087        env = EnvVars::UV_PYTHON,
5088        verbatim_doc_comment,
5089        help_heading = "Python options",
5090        value_parser = parse_maybe_string,
5091    )]
5092    pub python: Option<Maybe<String>>,
5093
5094    /// Whether to show resolver and installer output from any environment modifications.
5095    ///
5096    /// By default, environment modifications are omitted, but enabled under `--verbose`.
5097    #[arg(long, env = EnvVars::UV_SHOW_RESOLUTION, value_parser = clap::builder::BoolishValueParser::new(), hide = true)]
5098    pub show_resolution: bool,
5099
5100    /// The platform for which requirements should be installed.
5101    ///
5102    /// Represented as a "target triple", a string that describes the target platform in terms of
5103    /// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
5104    /// `aarch64-apple-darwin`.
5105    ///
5106    /// When targeting macOS (Darwin), the default minimum version is `13.0`. Use
5107    /// `MACOSX_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
5108    ///
5109    /// When targeting iOS, the default minimum version is `13.0`. Use
5110    /// `IPHONEOS_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
5111    ///
5112    /// When targeting Android, the default minimum Android API level is `24`. Use
5113    /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`.
5114    ///
5115    /// WARNING: When specified, uv will select wheels that are compatible with the _target_
5116    /// platform; as a result, the installed distributions may not be compatible with the _current_
5117    /// platform. Conversely, any distributions that are built from source may be incompatible with
5118    /// the _target_ platform, as they will be built for the _current_ platform. The
5119    /// `--python-platform` option is intended for advanced use cases.
5120    #[arg(long)]
5121    pub python_platform: Option<TargetTriple>,
5122
5123    #[arg(long, hide = true)]
5124    pub generate_shell_completion: Option<clap_complete_command::Shell>,
5125}
5126
5127#[derive(Args)]
5128pub struct UvxArgs {
5129    #[command(flatten)]
5130    pub tool_run: ToolRunArgs,
5131
5132    /// Display the uvx version.
5133    #[arg(short = 'V', long, action = clap::ArgAction::Version)]
5134    pub version: Option<bool>,
5135}
5136
5137#[derive(Args)]
5138pub struct ToolInstallArgs {
5139    /// The package to install commands from.
5140    pub package: String,
5141
5142    /// The package to install commands from.
5143    ///
5144    /// This option is provided for parity with `uv tool run`, but is redundant with `package`.
5145    #[arg(long, hide = true)]
5146    pub from: Option<String>,
5147
5148    /// Include the following additional requirements.
5149    #[arg(short = 'w', long)]
5150    pub with: Vec<comma::CommaSeparatedRequirements>,
5151
5152    /// Run with the packages listed in the given files.
5153    ///
5154    /// The following formats are supported: `requirements.txt`, `.py` files with inline metadata,
5155    /// and `pylock.toml`.
5156    #[arg(long, value_delimiter = ',', value_parser = parse_maybe_file_path)]
5157    pub with_requirements: Vec<Maybe<PathBuf>>,
5158
5159    /// Install the target package in editable mode, such that changes in the package's source
5160    /// directory are reflected without reinstallation.
5161    #[arg(short, long)]
5162    pub editable: bool,
5163
5164    /// Include the given packages in editable mode.
5165    #[arg(long)]
5166    pub with_editable: Vec<comma::CommaSeparatedRequirements>,
5167
5168    /// Install executables from the following packages.
5169    #[arg(long)]
5170    pub with_executables_from: Vec<comma::CommaSeparatedRequirements>,
5171
5172    /// Constrain versions using the given requirements files.
5173    ///
5174    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
5175    /// requirement that's installed. However, including a package in a constraints file will _not_
5176    /// trigger the installation of that package.
5177    ///
5178    /// This is equivalent to pip's `--constraint` option.
5179    #[arg(long, short, alias = "constraint", env = EnvVars::UV_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
5180    pub constraints: Vec<Maybe<PathBuf>>,
5181
5182    /// Override versions using the given requirements files.
5183    ///
5184    /// Overrides files are `requirements.txt`-like files that force a specific version of a
5185    /// requirement to be installed, regardless of the requirements declared by any constituent
5186    /// package, and regardless of whether this would be considered an invalid resolution.
5187    ///
5188    /// While constraints are _additive_, in that they're combined with the requirements of the
5189    /// constituent packages, overrides are _absolute_, in that they completely replace the
5190    /// requirements of the constituent packages.
5191    #[arg(long, alias = "override", env = EnvVars::UV_OVERRIDE, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
5192    pub overrides: Vec<Maybe<PathBuf>>,
5193
5194    /// Exclude packages from resolution using the given requirements files.
5195    ///
5196    /// Excludes files are `requirements.txt`-like files that specify packages to exclude
5197    /// from the resolution. When a package is excluded, it will be omitted from the
5198    /// dependency list entirely and its own dependencies will be ignored during the resolution
5199    /// phase. Excludes are unconditional in that requirement specifiers and markers are ignored;
5200    /// any package listed in the provided file will be omitted from all resolved environments.
5201    #[arg(long, alias = "exclude", env = EnvVars::UV_EXCLUDE, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
5202    pub excludes: Vec<Maybe<PathBuf>>,
5203
5204    /// Constrain build dependencies using the given requirements files when building source
5205    /// distributions.
5206    ///
5207    /// Constraints files are `requirements.txt`-like files that only control the _version_ of a
5208    /// requirement that's installed. However, including a package in a constraints file will _not_
5209    /// trigger the installation of that package.
5210    #[arg(long, short, alias = "build-constraint", env = EnvVars::UV_BUILD_CONSTRAINT, value_delimiter = ' ', value_parser = parse_maybe_file_path)]
5211    pub build_constraints: Vec<Maybe<PathBuf>>,
5212
5213    #[command(flatten)]
5214    pub installer: ResolverInstallerArgs,
5215
5216    #[command(flatten)]
5217    pub build: BuildOptionsArgs,
5218
5219    #[command(flatten)]
5220    pub refresh: RefreshArgs,
5221
5222    /// Force installation of the tool.
5223    ///
5224    /// Will replace any existing entry points with the same name in the executable directory.
5225    #[arg(long)]
5226    pub force: bool,
5227
5228    /// Whether to use Git LFS when adding a dependency from Git.
5229    #[arg(long, env = EnvVars::UV_GIT_LFS, value_parser = clap::builder::BoolishValueParser::new())]
5230    pub lfs: bool,
5231
5232    /// The Python interpreter to use to build the tool environment.
5233    ///
5234    /// See `uv help python` for details on Python discovery and supported request formats.
5235    #[arg(
5236        long,
5237        short,
5238        env = EnvVars::UV_PYTHON,
5239        verbatim_doc_comment,
5240        help_heading = "Python options",
5241        value_parser = parse_maybe_string,
5242    )]
5243    pub python: Option<Maybe<String>>,
5244
5245    /// The platform for which requirements should be installed.
5246    ///
5247    /// Represented as a "target triple", a string that describes the target platform in terms of
5248    /// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
5249    /// `aarch64-apple-darwin`.
5250    ///
5251    /// When targeting macOS (Darwin), the default minimum version is `13.0`. Use
5252    /// `MACOSX_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
5253    ///
5254    /// When targeting iOS, the default minimum version is `13.0`. Use
5255    /// `IPHONEOS_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
5256    ///
5257    /// When targeting Android, the default minimum Android API level is `24`. Use
5258    /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`.
5259    ///
5260    /// WARNING: When specified, uv will select wheels that are compatible with the _target_
5261    /// platform; as a result, the installed distributions may not be compatible with the _current_
5262    /// platform. Conversely, any distributions that are built from source may be incompatible with
5263    /// the _target_ platform, as they will be built for the _current_ platform. The
5264    /// `--python-platform` option is intended for advanced use cases.
5265    #[arg(long)]
5266    pub python_platform: Option<TargetTriple>,
5267}
5268
5269#[derive(Args)]
5270pub struct ToolListArgs {
5271    /// Whether to display the path to each tool environment and installed executable.
5272    #[arg(long)]
5273    pub show_paths: bool,
5274
5275    /// Whether to display the version specifier(s) used to install each tool.
5276    #[arg(long)]
5277    pub show_version_specifiers: bool,
5278
5279    /// Whether to display the additional requirements installed with each tool.
5280    #[arg(long)]
5281    pub show_with: bool,
5282
5283    /// Whether to display the extra requirements installed with each tool.
5284    #[arg(long)]
5285    pub show_extras: bool,
5286
5287    /// Whether to display the Python version associated with each tool.
5288    #[arg(long)]
5289    pub show_python: bool,
5290
5291    // Hide unused global Python options.
5292    #[arg(long, hide = true)]
5293    pub python_preference: Option<PythonPreference>,
5294
5295    #[arg(long, hide = true)]
5296    pub no_python_downloads: bool,
5297}
5298
5299#[derive(Args)]
5300pub struct ToolDirArgs {
5301    /// Show the directory into which `uv tool` will install executables.
5302    ///
5303    /// By default, `uv tool dir` shows the directory into which the tool Python environments
5304    /// themselves are installed, rather than the directory containing the linked executables.
5305    ///
5306    /// The tool executable directory is determined according to the XDG standard and is derived
5307    /// from the following environment variables, in order of preference:
5308    ///
5309    /// - `$UV_TOOL_BIN_DIR`
5310    /// - `$XDG_BIN_HOME`
5311    /// - `$XDG_DATA_HOME/../bin`
5312    /// - `$HOME/.local/bin`
5313    #[arg(long, verbatim_doc_comment)]
5314    pub bin: bool,
5315}
5316
5317#[derive(Args)]
5318pub struct ToolUninstallArgs {
5319    /// The name of the tool to uninstall.
5320    #[arg(required = true)]
5321    pub name: Vec<PackageName>,
5322
5323    /// Uninstall all tools.
5324    #[arg(long, conflicts_with("name"))]
5325    pub all: bool,
5326}
5327
5328#[derive(Args)]
5329pub struct ToolUpgradeArgs {
5330    /// The name of the tool to upgrade, along with an optional version specifier.
5331    #[arg(required = true)]
5332    pub name: Vec<String>,
5333
5334    /// Upgrade all tools.
5335    #[arg(long, conflicts_with("name"))]
5336    pub all: bool,
5337
5338    /// Upgrade a tool, and specify it to use the given Python interpreter to build its environment.
5339    /// Use with `--all` to apply to all tools.
5340    ///
5341    /// See `uv help python` for details on Python discovery and supported request formats.
5342    #[arg(
5343        long,
5344        short,
5345        env = EnvVars::UV_PYTHON,
5346        verbatim_doc_comment,
5347        help_heading = "Python options",
5348        value_parser = parse_maybe_string,
5349    )]
5350    pub python: Option<Maybe<String>>,
5351
5352    /// The platform for which requirements should be installed.
5353    ///
5354    /// Represented as a "target triple", a string that describes the target platform in terms of
5355    /// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
5356    /// `aarch64-apple-darwin`.
5357    ///
5358    /// When targeting macOS (Darwin), the default minimum version is `13.0`. Use
5359    /// `MACOSX_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
5360    ///
5361    /// When targeting iOS, the default minimum version is `13.0`. Use
5362    /// `IPHONEOS_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `14.0`.
5363    ///
5364    /// When targeting Android, the default minimum Android API level is `24`. Use
5365    /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`.
5366    ///
5367    /// WARNING: When specified, uv will select wheels that are compatible with the _target_
5368    /// platform; as a result, the installed distributions may not be compatible with the _current_
5369    /// platform. Conversely, any distributions that are built from source may be incompatible with
5370    /// the _target_ platform, as they will be built for the _current_ platform. The
5371    /// `--python-platform` option is intended for advanced use cases.
5372    #[arg(long)]
5373    pub python_platform: Option<TargetTriple>,
5374
5375    // The following is equivalent to flattening `ResolverInstallerArgs`, with the `--upgrade`, and
5376    // `--upgrade-package` options hidden, and the `--no-upgrade` option removed.
5377    /// Allow package upgrades, ignoring pinned versions in any existing output file. Implies
5378    /// `--refresh`.
5379    #[arg(hide = true, long, short = 'U', help_heading = "Resolver options")]
5380    pub upgrade: bool,
5381
5382    /// Allow upgrades for a specific package, ignoring pinned versions in any existing output
5383    /// file. Implies `--refresh-package`.
5384    #[arg(hide = true, long, short = 'P', help_heading = "Resolver options")]
5385    pub upgrade_package: Vec<Requirement<VerbatimParsedUrl>>,
5386
5387    #[command(flatten)]
5388    pub index_args: IndexArgs,
5389
5390    /// Reinstall all packages, regardless of whether they're already installed. Implies
5391    /// `--refresh`.
5392    #[arg(
5393        long,
5394        alias = "force-reinstall",
5395        overrides_with("no_reinstall"),
5396        help_heading = "Installer options"
5397    )]
5398    pub reinstall: bool,
5399
5400    #[arg(
5401        long,
5402        overrides_with("reinstall"),
5403        hide = true,
5404        help_heading = "Installer options"
5405    )]
5406    pub no_reinstall: bool,
5407
5408    /// Reinstall a specific package, regardless of whether it's already installed. Implies
5409    /// `--refresh-package`.
5410    #[arg(long, help_heading = "Installer options")]
5411    pub reinstall_package: Vec<PackageName>,
5412
5413    /// The strategy to use when resolving against multiple index URLs.
5414    ///
5415    /// By default, uv will stop at the first index on which a given package is available, and limit
5416    /// resolutions to those present on that first index (`first-index`). This prevents "dependency
5417    /// confusion" attacks, whereby an attacker can upload a malicious package under the same name
5418    /// to an alternate index.
5419    #[arg(
5420        long,
5421        value_enum,
5422        env = EnvVars::UV_INDEX_STRATEGY,
5423        help_heading = "Index options"
5424    )]
5425    pub index_strategy: Option<IndexStrategy>,
5426
5427    /// Attempt to use `keyring` for authentication for index URLs.
5428    ///
5429    /// At present, only `--keyring-provider subprocess` is supported, which configures uv to use
5430    /// the `keyring` CLI to handle authentication.
5431    ///
5432    /// Defaults to `disabled`.
5433    #[arg(
5434        long,
5435        value_enum,
5436        env = EnvVars::UV_KEYRING_PROVIDER,
5437        help_heading = "Index options"
5438    )]
5439    pub keyring_provider: Option<KeyringProviderType>,
5440
5441    /// The strategy to use when selecting between the different compatible versions for a given
5442    /// package requirement.
5443    ///
5444    /// By default, uv will use the latest compatible version of each package (`highest`).
5445    #[arg(
5446        long,
5447        value_enum,
5448        env = EnvVars::UV_RESOLUTION,
5449        help_heading = "Resolver options"
5450    )]
5451    pub resolution: Option<ResolutionMode>,
5452
5453    /// The strategy to use when considering pre-release versions.
5454    ///
5455    /// By default, uv will accept pre-releases for packages that _only_ publish pre-releases, along
5456    /// with first-party requirements that contain an explicit pre-release marker in the declared
5457    /// specifiers (`if-necessary-or-explicit`).
5458    #[arg(
5459        long,
5460        value_enum,
5461        env = EnvVars::UV_PRERELEASE,
5462        help_heading = "Resolver options"
5463    )]
5464    pub prerelease: Option<PrereleaseMode>,
5465
5466    #[arg(long, hide = true)]
5467    pub pre: bool,
5468
5469    /// The strategy to use when selecting multiple versions of a given package across Python
5470    /// versions and platforms.
5471    ///
5472    /// By default, uv will optimize for selecting the latest version of each package for each
5473    /// supported Python version (`requires-python`), while minimizing the number of selected
5474    /// versions across platforms.
5475    ///
5476    /// Under `fewest`, uv will minimize the number of selected versions for each package,
5477    /// preferring older versions that are compatible with a wider range of supported Python
5478    /// versions or platforms.
5479    #[arg(
5480        long,
5481        value_enum,
5482        env = EnvVars::UV_FORK_STRATEGY,
5483        help_heading = "Resolver options"
5484    )]
5485    pub fork_strategy: Option<ForkStrategy>,
5486
5487    /// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
5488    #[arg(
5489        long,
5490        short = 'C',
5491        alias = "config-settings",
5492        help_heading = "Build options"
5493    )]
5494    pub config_setting: Option<Vec<ConfigSettingEntry>>,
5495
5496    /// Settings to pass to the PEP 517 build backend for a specific package, specified as `PACKAGE:KEY=VALUE` pairs.
5497    #[arg(
5498        long,
5499        alias = "config-settings-package",
5500        help_heading = "Build options"
5501    )]
5502    pub config_setting_package: Option<Vec<ConfigSettingPackageEntry>>,
5503
5504    /// Disable isolation when building source distributions.
5505    ///
5506    /// Assumes that build dependencies specified by PEP 518 are already installed.
5507    #[arg(
5508        long,
5509        overrides_with("build_isolation"),
5510        help_heading = "Build options",
5511        env = EnvVars::UV_NO_BUILD_ISOLATION,
5512        value_parser = clap::builder::BoolishValueParser::new(),
5513    )]
5514    pub no_build_isolation: bool,
5515
5516    /// Disable isolation when building source distributions for a specific package.
5517    ///
5518    /// Assumes that the packages' build dependencies specified by PEP 518 are already installed.
5519    #[arg(long, help_heading = "Build options")]
5520    pub no_build_isolation_package: Vec<PackageName>,
5521
5522    #[arg(
5523        long,
5524        overrides_with("no_build_isolation"),
5525        hide = true,
5526        help_heading = "Build options"
5527    )]
5528    pub build_isolation: bool,
5529
5530    /// Limit candidate packages to those that were uploaded prior to the given date.
5531    ///
5532    /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
5533    /// format (e.g., `2006-12-02`) in your system's configured time zone.
5534    #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
5535    pub exclude_newer: Option<ExcludeNewerTimestamp>,
5536
5537    /// Limit candidate packages for specific packages to those that were uploaded prior to the given date.
5538    ///
5539    /// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp
5540    /// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone.
5541    ///
5542    /// Can be provided multiple times for different packages.
5543    #[arg(long, help_heading = "Resolver options")]
5544    pub exclude_newer_package: Option<Vec<ExcludeNewerPackageEntry>>,
5545
5546    /// The method to use when installing packages from the global cache.
5547    ///
5548    /// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
5549    /// Windows.
5550    ///
5551    /// WARNING: The use of symlink link mode is discouraged, as they create tight coupling between
5552    /// the cache and the target environment. For example, clearing the cache (`uv cache clean`)
5553    /// will break all installed packages by way of removing the underlying source files. Use
5554    /// symlinks with caution.
5555    #[arg(
5556        long,
5557        value_enum,
5558        env = EnvVars::UV_LINK_MODE,
5559        help_heading = "Installer options"
5560    )]
5561    pub link_mode: Option<uv_install_wheel::LinkMode>,
5562
5563    /// Compile Python files to bytecode after installation.
5564    ///
5565    /// By default, uv does not compile Python (`.py`) files to bytecode (`__pycache__/*.pyc`);
5566    /// instead, compilation is performed lazily the first time a module is imported. For use-cases
5567    /// in which start time is critical, such as CLI applications and Docker containers, this option
5568    /// can be enabled to trade longer installation times for faster start times.
5569    ///
5570    /// When enabled, uv will process the entire site-packages directory (including packages that
5571    /// are not being modified by the current operation) for consistency. Like pip, it will also
5572    /// ignore errors.
5573    #[arg(
5574        long,
5575        alias = "compile",
5576        overrides_with("no_compile_bytecode"),
5577        help_heading = "Installer options",
5578        env = EnvVars::UV_COMPILE_BYTECODE,
5579        value_parser = clap::builder::BoolishValueParser::new(),
5580    )]
5581    pub compile_bytecode: bool,
5582
5583    #[arg(
5584        long,
5585        alias = "no-compile",
5586        overrides_with("compile_bytecode"),
5587        hide = true,
5588        help_heading = "Installer options"
5589    )]
5590    pub no_compile_bytecode: bool,
5591
5592    /// Ignore the `tool.uv.sources` table when resolving dependencies. Used to lock against the
5593    /// standards-compliant, publishable package metadata, as opposed to using any workspace, Git,
5594    /// URL, or local path sources.
5595    #[arg(
5596        long,
5597        env = EnvVars::UV_NO_SOURCES,
5598        value_parser = clap::builder::BoolishValueParser::new(),
5599        help_heading = "Resolver options",
5600    )]
5601    pub no_sources: bool,
5602
5603    #[command(flatten)]
5604    pub build: BuildOptionsArgs,
5605}
5606
5607#[derive(Args)]
5608pub struct PythonNamespace {
5609    #[command(subcommand)]
5610    pub command: PythonCommand,
5611}
5612
5613#[derive(Subcommand)]
5614pub enum PythonCommand {
5615    /// List the available Python installations.
5616    ///
5617    /// By default, installed Python versions and the downloads for latest available patch version
5618    /// of each supported Python major version are shown.
5619    ///
5620    /// Use `--managed-python` to view only managed Python versions.
5621    ///
5622    /// Use `--no-managed-python` to omit managed Python versions.
5623    ///
5624    /// Use `--all-versions` to view all available patch versions.
5625    ///
5626    /// Use `--only-installed` to omit available downloads.
5627    #[command(alias = "ls")]
5628    List(PythonListArgs),
5629
5630    /// Download and install Python versions.
5631    ///
5632    /// Supports CPython and PyPy. CPython distributions are downloaded from the Astral
5633    /// `python-build-standalone` project. PyPy distributions are downloaded from `python.org`. The
5634    /// available Python versions are bundled with each uv release. To install new Python versions,
5635    /// you may need upgrade uv.
5636    ///
5637    /// Python versions are installed into the uv Python directory, which can be retrieved with `uv
5638    /// python dir`.
5639    ///
5640    /// By default, Python executables are added to a directory on the path with a minor version
5641    /// suffix, e.g., `python3.13`. To install `python3` and `python`, use the `--default` flag. Use
5642    /// `uv python dir --bin` to see the target directory.
5643    ///
5644    /// Multiple Python versions may be requested.
5645    ///
5646    /// See `uv help python` to view supported request formats.
5647    Install(PythonInstallArgs),
5648
5649    /// Upgrade installed Python versions.
5650    ///
5651    /// Upgrades versions to the latest supported patch release. Requires the `python-upgrade`
5652    /// preview feature.
5653    ///
5654    /// A target Python minor version to upgrade may be provided, e.g., `3.13`. Multiple versions
5655    /// may be provided to perform more than one upgrade.
5656    ///
5657    /// If no target version is provided, then uv will upgrade all managed CPython versions.
5658    ///
5659    /// During an upgrade, uv will not uninstall outdated patch versions.
5660    ///
5661    /// When an upgrade is performed, virtual environments created by uv will automatically
5662    /// use the new version. However, if the virtual environment was created before the
5663    /// upgrade functionality was added, it will continue to use the old Python version; to enable
5664    /// upgrades, the environment must be recreated.
5665    ///
5666    /// Upgrades are not yet supported for alternative implementations, like PyPy.
5667    Upgrade(PythonUpgradeArgs),
5668
5669    /// Search for a Python installation.
5670    ///
5671    /// Displays the path to the Python executable.
5672    ///
5673    /// See `uv help python` to view supported request formats and details on discovery behavior.
5674    Find(PythonFindArgs),
5675
5676    /// Pin to a specific Python version.
5677    ///
5678    /// Writes the pinned Python version to a `.python-version` file, which is used by other uv
5679    /// commands to determine the required Python version.
5680    ///
5681    /// If no version is provided, uv will look for an existing `.python-version` file and display
5682    /// the currently pinned version. If no `.python-version` file is found, uv will exit with an
5683    /// error.
5684    ///
5685    /// See `uv help python` to view supported request formats.
5686    Pin(PythonPinArgs),
5687
5688    /// Show the uv Python installation directory.
5689    ///
5690    /// By default, Python installations are stored in the uv data directory at
5691    /// `$XDG_DATA_HOME/uv/python` or `$HOME/.local/share/uv/python` on Unix and
5692    /// `%APPDATA%\uv\data\python` on Windows.
5693    ///
5694    /// The Python installation directory may be overridden with `$UV_PYTHON_INSTALL_DIR`.
5695    ///
5696    /// To view the directory where uv installs Python executables instead, use the `--bin` flag.
5697    /// The Python executable directory may be overridden with `$UV_PYTHON_BIN_DIR`. Note that
5698    /// Python executables are only installed when preview mode is enabled.
5699    Dir(PythonDirArgs),
5700
5701    /// Uninstall Python versions.
5702    Uninstall(PythonUninstallArgs),
5703
5704    /// Ensure that the Python executable directory is on the `PATH`.
5705    ///
5706    /// If the Python executable directory is not present on the `PATH`, uv will attempt to add it to
5707    /// the relevant shell configuration files.
5708    ///
5709    /// If the shell configuration files already include a blurb to add the executable directory to
5710    /// the path, but the directory is not present on the `PATH`, uv will exit with an error.
5711    ///
5712    /// The Python executable directory is determined according to the XDG standard and can be
5713    /// retrieved with `uv python dir --bin`.
5714    #[command(alias = "ensurepath")]
5715    UpdateShell,
5716}
5717
5718#[derive(Args)]
5719pub struct PythonListArgs {
5720    /// A Python request to filter by.
5721    ///
5722    /// See `uv help python` to view supported request formats.
5723    pub request: Option<String>,
5724
5725    /// List all Python versions, including old patch versions.
5726    ///
5727    /// By default, only the latest patch version is shown for each minor version.
5728    #[arg(long)]
5729    pub all_versions: bool,
5730
5731    /// List Python downloads for all platforms.
5732    ///
5733    /// By default, only downloads for the current platform are shown.
5734    #[arg(long)]
5735    pub all_platforms: bool,
5736
5737    /// List Python downloads for all architectures.
5738    ///
5739    /// By default, only downloads for the current architecture are shown.
5740    #[arg(long, alias = "all_architectures")]
5741    pub all_arches: bool,
5742
5743    /// Only show installed Python versions.
5744    ///
5745    /// By default, installed distributions and available downloads for the current platform are shown.
5746    #[arg(long, conflicts_with("only_downloads"))]
5747    pub only_installed: bool,
5748
5749    /// Only show available Python downloads.
5750    ///
5751    /// By default, installed distributions and available downloads for the current platform are shown.
5752    #[arg(long, conflicts_with("only_installed"))]
5753    pub only_downloads: bool,
5754
5755    /// Show the URLs of available Python downloads.
5756    ///
5757    /// By default, these display as `<download available>`.
5758    #[arg(long)]
5759    pub show_urls: bool,
5760
5761    /// Select the output format.
5762    #[arg(long, value_enum, default_value_t = PythonListFormat::default())]
5763    pub output_format: PythonListFormat,
5764
5765    /// URL pointing to JSON of custom Python installations.
5766    #[arg(long)]
5767    pub python_downloads_json_url: Option<String>,
5768}
5769
5770#[derive(Args)]
5771pub struct PythonDirArgs {
5772    /// Show the directory into which `uv python` will install Python executables.
5773    ///
5774    /// Note that this directory is only used when installing Python with preview mode enabled.
5775    ///
5776    /// The Python executable directory is determined according to the XDG standard and is derived
5777    /// from the following environment variables, in order of preference:
5778    ///
5779    /// - `$UV_PYTHON_BIN_DIR`
5780    /// - `$XDG_BIN_HOME`
5781    /// - `$XDG_DATA_HOME/../bin`
5782    /// - `$HOME/.local/bin`
5783    #[arg(long, verbatim_doc_comment)]
5784    pub bin: bool,
5785}
5786
5787#[derive(Args)]
5788pub struct PythonInstallArgs {
5789    /// The directory to store the Python installation in.
5790    ///
5791    /// If provided, `UV_PYTHON_INSTALL_DIR` will need to be set for subsequent operations for uv to
5792    /// discover the Python installation.
5793    ///
5794    /// See `uv python dir` to view the current Python installation directory. Defaults to
5795    /// `~/.local/share/uv/python`.
5796    #[arg(long, short, env = EnvVars::UV_PYTHON_INSTALL_DIR)]
5797    pub install_dir: Option<PathBuf>,
5798
5799    /// Install a Python executable into the `bin` directory.
5800    ///
5801    /// This is the default behavior. If this flag is provided explicitly, uv will error if the
5802    /// executable cannot be installed.
5803    ///
5804    /// This can also be set with `UV_PYTHON_INSTALL_BIN=1`.
5805    ///
5806    /// See `UV_PYTHON_BIN_DIR` to customize the target directory.
5807    #[arg(long, overrides_with("no_bin"), hide = true)]
5808    pub bin: bool,
5809
5810    /// Do not install a Python executable into the `bin` directory.
5811    ///
5812    /// This can also be set with `UV_PYTHON_INSTALL_BIN=0`.
5813    #[arg(long, overrides_with("bin"), conflicts_with("default"))]
5814    pub no_bin: bool,
5815
5816    /// Register the Python installation in the Windows registry.
5817    ///
5818    /// This is the default behavior on Windows. If this flag is provided explicitly, uv will error if the
5819    /// registry entry cannot be created.
5820    ///
5821    /// This can also be set with `UV_PYTHON_INSTALL_REGISTRY=1`.
5822    #[arg(long, overrides_with("no_registry"), hide = true)]
5823    pub registry: bool,
5824
5825    /// Do not register the Python installation in the Windows registry.
5826    ///
5827    /// This can also be set with `UV_PYTHON_INSTALL_REGISTRY=0`.
5828    #[arg(long, overrides_with("registry"))]
5829    pub no_registry: bool,
5830
5831    /// The Python version(s) to install.
5832    ///
5833    /// If not provided, the requested Python version(s) will be read from the `UV_PYTHON`
5834    /// environment variable then `.python-versions` or `.python-version` files. If none of the
5835    /// above are present, uv will check if it has installed any Python versions. If not, it will
5836    /// install the latest stable version of Python.
5837    ///
5838    /// See `uv help python` to view supported request formats.
5839    #[arg(env = EnvVars::UV_PYTHON)]
5840    pub targets: Vec<String>,
5841
5842    /// Set the URL to use as the source for downloading Python installations.
5843    ///
5844    /// The provided URL will replace
5845    /// `https://github.com/astral-sh/python-build-standalone/releases/download` in, e.g.,
5846    /// `https://github.com/astral-sh/python-build-standalone/releases/download/20240713/cpython-3.12.4%2B20240713-aarch64-apple-darwin-install_only.tar.gz`.
5847    ///
5848    /// Distributions can be read from a local directory by using the `file://` URL scheme.
5849    #[arg(long)]
5850    pub mirror: Option<String>,
5851
5852    /// Set the URL to use as the source for downloading PyPy installations.
5853    ///
5854    /// The provided URL will replace `https://downloads.python.org/pypy` in, e.g.,
5855    /// `https://downloads.python.org/pypy/pypy3.8-v7.3.7-osx64.tar.bz2`.
5856    ///
5857    /// Distributions can be read from a local directory by using the `file://` URL scheme.
5858    #[arg(long)]
5859    pub pypy_mirror: Option<String>,
5860
5861    /// URL pointing to JSON of custom Python installations.
5862    #[arg(long)]
5863    pub python_downloads_json_url: Option<String>,
5864
5865    /// Reinstall the requested Python version, if it's already installed.
5866    ///
5867    /// By default, uv will exit successfully if the version is already
5868    /// installed.
5869    #[arg(long, short)]
5870    pub reinstall: bool,
5871
5872    /// Replace existing Python executables during installation.
5873    ///
5874    /// By default, uv will refuse to replace executables that it does not manage.
5875    ///
5876    /// Implies `--reinstall`.
5877    #[arg(long, short)]
5878    pub force: bool,
5879
5880    /// Upgrade existing Python installations to the latest patch version.
5881    ///
5882    /// By default, uv will not upgrade already-installed Python versions to newer patch releases.
5883    /// With `--upgrade`, uv will upgrade to the latest available patch version for the specified
5884    /// minor version(s).
5885    ///
5886    /// If the requested versions are not yet installed, uv will install them.
5887    ///
5888    /// This option is only supported for minor version requests, e.g., `3.12`; uv will exit with an
5889    /// error if a patch version, e.g., `3.12.2`, is requested.
5890    #[arg(long, short = 'U')]
5891    pub upgrade: bool,
5892
5893    /// Use as the default Python version.
5894    ///
5895    /// By default, only a `python{major}.{minor}` executable is installed, e.g., `python3.10`. When
5896    /// the `--default` flag is used, `python{major}`, e.g., `python3`, and `python` executables are
5897    /// also installed.
5898    ///
5899    /// Alternative Python variants will still include their tag. For example, installing
5900    /// 3.13+freethreaded with `--default` will include in `python3t` and `pythont`, not `python3`
5901    /// and `python`.
5902    ///
5903    /// If multiple Python versions are requested, uv will exit with an error.
5904    #[arg(long, conflicts_with("no_bin"))]
5905    pub default: bool,
5906}
5907
5908impl PythonInstallArgs {
5909    #[must_use]
5910    pub fn install_mirrors(&self) -> PythonInstallMirrors {
5911        PythonInstallMirrors {
5912            python_install_mirror: self.mirror.clone(),
5913            pypy_install_mirror: self.pypy_mirror.clone(),
5914            python_downloads_json_url: self.python_downloads_json_url.clone(),
5915        }
5916    }
5917}
5918
5919#[derive(Args)]
5920pub struct PythonUpgradeArgs {
5921    /// The directory Python installations are stored in.
5922    ///
5923    /// If provided, `UV_PYTHON_INSTALL_DIR` will need to be set for subsequent operations for uv to
5924    /// discover the Python installation.
5925    ///
5926    /// See `uv python dir` to view the current Python installation directory. Defaults to
5927    /// `~/.local/share/uv/python`.
5928    #[arg(long, short, env = EnvVars::UV_PYTHON_INSTALL_DIR)]
5929    pub install_dir: Option<PathBuf>,
5930
5931    /// The Python minor version(s) to upgrade.
5932    ///
5933    /// If no target version is provided, then uv will upgrade all managed CPython versions.
5934    #[arg(env = EnvVars::UV_PYTHON)]
5935    pub targets: Vec<String>,
5936
5937    /// Set the URL to use as the source for downloading Python installations.
5938    ///
5939    /// The provided URL will replace
5940    /// `https://github.com/astral-sh/python-build-standalone/releases/download` in, e.g.,
5941    /// `https://github.com/astral-sh/python-build-standalone/releases/download/20240713/cpython-3.12.4%2B20240713-aarch64-apple-darwin-install_only.tar.gz`.
5942    ///
5943    /// Distributions can be read from a local directory by using the `file://` URL scheme.
5944    #[arg(long)]
5945    pub mirror: Option<String>,
5946
5947    /// Set the URL to use as the source for downloading PyPy installations.
5948    ///
5949    /// The provided URL will replace `https://downloads.python.org/pypy` in, e.g.,
5950    /// `https://downloads.python.org/pypy/pypy3.8-v7.3.7-osx64.tar.bz2`.
5951    ///
5952    /// Distributions can be read from a local directory by using the `file://` URL scheme.
5953    #[arg(long)]
5954    pub pypy_mirror: Option<String>,
5955
5956    /// Reinstall the latest Python patch, if it's already installed.
5957    ///
5958    /// By default, uv will exit successfully if the latest patch is already
5959    /// installed.
5960    #[arg(long, short)]
5961    pub reinstall: bool,
5962
5963    /// URL pointing to JSON of custom Python installations.
5964    #[arg(long)]
5965    pub python_downloads_json_url: Option<String>,
5966}
5967
5968impl PythonUpgradeArgs {
5969    #[must_use]
5970    pub fn install_mirrors(&self) -> PythonInstallMirrors {
5971        PythonInstallMirrors {
5972            python_install_mirror: self.mirror.clone(),
5973            pypy_install_mirror: self.pypy_mirror.clone(),
5974            python_downloads_json_url: self.python_downloads_json_url.clone(),
5975        }
5976    }
5977}
5978
5979#[derive(Args)]
5980pub struct PythonUninstallArgs {
5981    /// The directory where the Python was installed.
5982    #[arg(long, short, env = EnvVars::UV_PYTHON_INSTALL_DIR)]
5983    pub install_dir: Option<PathBuf>,
5984
5985    /// The Python version(s) to uninstall.
5986    ///
5987    /// See `uv help python` to view supported request formats.
5988    #[arg(required = true)]
5989    pub targets: Vec<String>,
5990
5991    /// Uninstall all managed Python versions.
5992    #[arg(long, conflicts_with("targets"))]
5993    pub all: bool,
5994}
5995
5996#[derive(Args)]
5997pub struct PythonFindArgs {
5998    /// The Python request.
5999    ///
6000    /// See `uv help python` to view supported request formats.
6001    pub request: Option<String>,
6002
6003    /// Avoid discovering a project or workspace.
6004    ///
6005    /// Otherwise, when no request is provided, the Python requirement of a project in the current
6006    /// directory or parent directories will be used.
6007    #[arg(long, alias = "no_workspace")]
6008    pub no_project: bool,
6009
6010    /// Only find system Python interpreters.
6011    ///
6012    /// By default, uv will report the first Python interpreter it would use, including those in an
6013    /// active virtual environment or a virtual environment in the current working directory or any
6014    /// parent directory.
6015    ///
6016    /// The `--system` option instructs uv to skip virtual environment Python interpreters and
6017    /// restrict its search to the system path.
6018    #[arg(
6019        long,
6020        env = EnvVars::UV_SYSTEM_PYTHON,
6021        value_parser = clap::builder::BoolishValueParser::new(),
6022        overrides_with("no_system")
6023    )]
6024    pub system: bool,
6025
6026    #[arg(long, overrides_with("system"), hide = true)]
6027    pub no_system: bool,
6028
6029    /// Find the environment for a Python script, rather than the current project.
6030    #[arg(
6031        long,
6032        conflicts_with = "request",
6033        conflicts_with = "no_project",
6034        conflicts_with = "system",
6035        conflicts_with = "no_system"
6036    )]
6037    pub script: Option<PathBuf>,
6038
6039    /// Show the Python version that would be used instead of the path to the interpreter.
6040    #[arg(long)]
6041    pub show_version: bool,
6042
6043    /// URL pointing to JSON of custom Python installations.
6044    #[arg(long)]
6045    pub python_downloads_json_url: Option<String>,
6046}
6047
6048#[derive(Args)]
6049pub struct PythonPinArgs {
6050    /// The Python version request.
6051    ///
6052    /// uv supports more formats than other tools that read `.python-version` files, i.e., `pyenv`.
6053    /// If compatibility with those tools is needed, only use version numbers instead of complex
6054    /// requests such as `cpython@3.10`.
6055    ///
6056    /// If no request is provided, the currently pinned version will be shown.
6057    ///
6058    /// See `uv help python` to view supported request formats.
6059    pub request: Option<String>,
6060
6061    /// Write the resolved Python interpreter path instead of the request.
6062    ///
6063    /// Ensures that the exact same interpreter is used.
6064    ///
6065    /// This option is usually not safe to use when committing the `.python-version` file to version
6066    /// control.
6067    #[arg(long, overrides_with("resolved"))]
6068    pub resolved: bool,
6069
6070    #[arg(long, overrides_with("no_resolved"), hide = true)]
6071    pub no_resolved: bool,
6072
6073    /// Avoid validating the Python pin is compatible with the project or workspace.
6074    ///
6075    /// By default, a project or workspace is discovered in the current directory or any parent
6076    /// directory. If a workspace is found, the Python pin is validated against the workspace's
6077    /// `requires-python` constraint.
6078    #[arg(long, alias = "no-workspace")]
6079    pub no_project: bool,
6080
6081    /// Update the global Python version pin.
6082    ///
6083    /// Writes the pinned Python version to a `.python-version` file in the uv user configuration
6084    /// directory: `XDG_CONFIG_HOME/uv` on Linux/macOS and `%APPDATA%/uv` on Windows.
6085    ///
6086    /// When a local Python version pin is not found in the working directory or an ancestor
6087    /// directory, this version will be used instead.
6088    #[arg(long)]
6089    pub global: bool,
6090
6091    /// Remove the Python version pin.
6092    #[arg(long, conflicts_with = "request", conflicts_with = "resolved")]
6093    pub rm: bool,
6094}
6095
6096#[derive(Args)]
6097pub struct AuthLogoutArgs {
6098    /// The domain or URL of the service to logout from.
6099    pub service: Service,
6100
6101    /// The username to logout.
6102    #[arg(long, short)]
6103    pub username: Option<String>,
6104
6105    /// The keyring provider to use for storage of credentials.
6106    ///
6107    /// Only `--keyring-provider native` is supported for `logout`, which uses the system keyring
6108    /// via an integration built into uv.
6109    #[arg(
6110        long,
6111        value_enum,
6112        env = EnvVars::UV_KEYRING_PROVIDER,
6113    )]
6114    pub keyring_provider: Option<KeyringProviderType>,
6115}
6116
6117#[derive(Args)]
6118pub struct AuthLoginArgs {
6119    /// The domain or URL of the service to log into.
6120    pub service: Service,
6121
6122    /// The username to use for the service.
6123    #[arg(long, short, conflicts_with = "token")]
6124    pub username: Option<String>,
6125
6126    /// The password to use for the service.
6127    ///
6128    /// Use `-` to read the password from stdin.
6129    #[arg(long, conflicts_with = "token")]
6130    pub password: Option<String>,
6131
6132    /// The token to use for the service.
6133    ///
6134    /// The username will be set to `__token__`.
6135    ///
6136    /// Use `-` to read the token from stdin.
6137    #[arg(long, short, conflicts_with = "username", conflicts_with = "password")]
6138    pub token: Option<String>,
6139
6140    /// The keyring provider to use for storage of credentials.
6141    ///
6142    /// Only `--keyring-provider native` is supported for `login`, which uses the system keyring via
6143    /// an integration built into uv.
6144    #[arg(
6145        long,
6146        value_enum,
6147        env = EnvVars::UV_KEYRING_PROVIDER,
6148    )]
6149    pub keyring_provider: Option<KeyringProviderType>,
6150}
6151
6152#[derive(Args)]
6153pub struct AuthTokenArgs {
6154    /// The domain or URL of the service to lookup.
6155    pub service: Service,
6156
6157    /// The username to lookup.
6158    #[arg(long, short)]
6159    pub username: Option<String>,
6160
6161    /// The keyring provider to use for reading credentials.
6162    #[arg(
6163        long,
6164        value_enum,
6165        env = EnvVars::UV_KEYRING_PROVIDER,
6166    )]
6167    pub keyring_provider: Option<KeyringProviderType>,
6168}
6169
6170#[derive(Args)]
6171pub struct AuthDirArgs {
6172    /// The domain or URL of the service to lookup.
6173    pub service: Option<Service>,
6174}
6175
6176#[derive(Args)]
6177pub struct GenerateShellCompletionArgs {
6178    /// The shell to generate the completion script for
6179    pub shell: clap_complete_command::Shell,
6180
6181    // Hide unused global options.
6182    #[arg(long, short, hide = true)]
6183    pub no_cache: bool,
6184    #[arg(long, hide = true)]
6185    pub cache_dir: Option<PathBuf>,
6186
6187    #[arg(long, hide = true)]
6188    pub python_preference: Option<PythonPreference>,
6189    #[arg(long, hide = true)]
6190    pub no_python_downloads: bool,
6191
6192    #[arg(long, short, action = clap::ArgAction::Count, conflicts_with = "verbose", hide = true)]
6193    pub quiet: u8,
6194    #[arg(long, short, action = clap::ArgAction::Count, conflicts_with = "quiet", hide = true)]
6195    pub verbose: u8,
6196    #[arg(long, conflicts_with = "no_color", hide = true)]
6197    pub color: Option<ColorChoice>,
6198    #[arg(long, hide = true)]
6199    pub native_tls: bool,
6200    #[arg(long, hide = true)]
6201    pub offline: bool,
6202    #[arg(long, hide = true)]
6203    pub no_progress: bool,
6204    #[arg(long, hide = true)]
6205    pub config_file: Option<PathBuf>,
6206    #[arg(long, hide = true)]
6207    pub no_config: bool,
6208    #[arg(long, short, action = clap::ArgAction::HelpShort, hide = true)]
6209    pub help: Option<bool>,
6210    #[arg(short = 'V', long, hide = true)]
6211    pub version: bool,
6212}
6213
6214#[derive(Args)]
6215pub struct IndexArgs {
6216    /// The URLs to use when resolving dependencies, in addition to the default index.
6217    ///
6218    /// Accepts either a repository compliant with PEP 503 (the simple repository API), or a local
6219    /// directory laid out in the same format.
6220    ///
6221    /// All indexes provided via this flag take priority over the index specified by
6222    /// `--default-index` (which defaults to PyPI). When multiple `--index` flags are provided,
6223    /// earlier values take priority.
6224    ///
6225    /// Index names are not supported as values. Relative paths must be disambiguated from index
6226    /// names with `./` or `../` on Unix or `.\\`, `..\\`, `./` or `../` on Windows.
6227    //
6228    // The nested Vec structure (`Vec<Vec<Maybe<Index>>>`) is required for clap's
6229    // value parsing mechanism, which processes one value at a time, in order to handle
6230    // `UV_INDEX` the same way pip handles `PIP_EXTRA_INDEX_URL`.
6231    #[arg(long, env = EnvVars::UV_INDEX, value_parser = parse_indices, help_heading = "Index options")]
6232    pub index: Option<Vec<Vec<Maybe<Index>>>>,
6233
6234    /// The URL of the default package index (by default: <https://pypi.org/simple>).
6235    ///
6236    /// Accepts either a repository compliant with PEP 503 (the simple repository API), or a local
6237    /// directory laid out in the same format.
6238    ///
6239    /// The index given by this flag is given lower priority than all other indexes specified via
6240    /// the `--index` flag.
6241    #[arg(long, env = EnvVars::UV_DEFAULT_INDEX, value_parser = parse_default_index, help_heading = "Index options")]
6242    pub default_index: Option<Maybe<Index>>,
6243
6244    /// (Deprecated: use `--default-index` instead) The URL of the Python package index (by default:
6245    /// <https://pypi.org/simple>).
6246    ///
6247    /// Accepts either a repository compliant with PEP 503 (the simple repository API), or a local
6248    /// directory laid out in the same format.
6249    ///
6250    /// The index given by this flag is given lower priority than all other indexes specified via
6251    /// the `--extra-index-url` flag.
6252    #[arg(long, short, env = EnvVars::UV_INDEX_URL, value_parser = parse_index_url, help_heading = "Index options")]
6253    pub index_url: Option<Maybe<PipIndex>>,
6254
6255    /// (Deprecated: use `--index` instead) Extra URLs of package indexes to use, in addition to
6256    /// `--index-url`.
6257    ///
6258    /// Accepts either a repository compliant with PEP 503 (the simple repository API), or a local
6259    /// directory laid out in the same format.
6260    ///
6261    /// All indexes provided via this flag take priority over the index specified by `--index-url`
6262    /// (which defaults to PyPI). When multiple `--extra-index-url` flags are provided, earlier
6263    /// values take priority.
6264    #[arg(long, env = EnvVars::UV_EXTRA_INDEX_URL, value_delimiter = ' ', value_parser = parse_extra_index_url, help_heading = "Index options")]
6265    pub extra_index_url: Option<Vec<Maybe<PipExtraIndex>>>,
6266
6267    /// Locations to search for candidate distributions, in addition to those found in the registry
6268    /// indexes.
6269    ///
6270    /// If a path, the target must be a directory that contains packages as wheel files (`.whl`) or
6271    /// source distributions (e.g., `.tar.gz` or `.zip`) at the top level.
6272    ///
6273    /// If a URL, the page must contain a flat list of links to package files adhering to the
6274    /// formats described above.
6275    #[arg(
6276        long,
6277        short,
6278        env = EnvVars::UV_FIND_LINKS,
6279        value_delimiter = ',',
6280        value_parser = parse_find_links,
6281        help_heading = "Index options"
6282    )]
6283    pub find_links: Option<Vec<Maybe<PipFindLinks>>>,
6284
6285    /// Ignore the registry index (e.g., PyPI), instead relying on direct URL dependencies and those
6286    /// provided via `--find-links`.
6287    #[arg(long, help_heading = "Index options")]
6288    pub no_index: bool,
6289}
6290
6291#[derive(Args)]
6292pub struct RefreshArgs {
6293    /// Refresh all cached data.
6294    #[arg(
6295        long,
6296        conflicts_with("offline"),
6297        overrides_with("no_refresh"),
6298        help_heading = "Cache options"
6299    )]
6300    pub refresh: bool,
6301
6302    #[arg(
6303        long,
6304        conflicts_with("offline"),
6305        overrides_with("refresh"),
6306        hide = true,
6307        help_heading = "Cache options"
6308    )]
6309    pub no_refresh: bool,
6310
6311    /// Refresh cached data for a specific package.
6312    #[arg(long, help_heading = "Cache options")]
6313    pub refresh_package: Vec<PackageName>,
6314}
6315
6316#[derive(Args)]
6317pub struct BuildOptionsArgs {
6318    /// Don't build source distributions.
6319    ///
6320    /// When enabled, resolving will not run arbitrary Python code. The cached wheels of
6321    /// already-built source distributions will be reused, but operations that require building
6322    /// distributions will exit with an error.
6323    #[arg(
6324        long,
6325        env = EnvVars::UV_NO_BUILD,
6326        overrides_with("build"),
6327        value_parser = clap::builder::BoolishValueParser::new(),
6328        help_heading = "Build options",
6329    )]
6330    pub no_build: bool,
6331
6332    #[arg(
6333        long,
6334        overrides_with("no_build"),
6335        hide = true,
6336        help_heading = "Build options"
6337    )]
6338    pub build: bool,
6339
6340    /// Don't build source distributions for a specific package.
6341    #[arg(long, help_heading = "Build options", env = EnvVars::UV_NO_BUILD_PACKAGE, value_delimiter = ' ')]
6342    pub no_build_package: Vec<PackageName>,
6343
6344    /// Don't install pre-built wheels.
6345    ///
6346    /// The given packages will be built and installed from source. The resolver will still use
6347    /// pre-built wheels to extract package metadata, if available.
6348    #[arg(
6349        long,
6350        env = EnvVars::UV_NO_BINARY,
6351        overrides_with("binary"),
6352        value_parser = clap::builder::BoolishValueParser::new(),
6353        help_heading = "Build options"
6354    )]
6355    pub no_binary: bool,
6356
6357    #[arg(
6358        long,
6359        overrides_with("no_binary"),
6360        hide = true,
6361        help_heading = "Build options"
6362    )]
6363    pub binary: bool,
6364
6365    /// Don't install pre-built wheels for a specific package.
6366    #[arg(long, help_heading = "Build options", env = EnvVars::UV_NO_BINARY_PACKAGE, value_delimiter = ' ')]
6367    pub no_binary_package: Vec<PackageName>,
6368}
6369
6370/// Arguments that are used by commands that need to install (but not resolve) packages.
6371#[derive(Args)]
6372pub struct InstallerArgs {
6373    #[command(flatten)]
6374    pub index_args: IndexArgs,
6375
6376    /// Reinstall all packages, regardless of whether they're already installed. Implies
6377    /// `--refresh`.
6378    #[arg(
6379        long,
6380        alias = "force-reinstall",
6381        overrides_with("no_reinstall"),
6382        help_heading = "Installer options"
6383    )]
6384    pub reinstall: bool,
6385
6386    #[arg(
6387        long,
6388        overrides_with("reinstall"),
6389        hide = true,
6390        help_heading = "Installer options"
6391    )]
6392    pub no_reinstall: bool,
6393
6394    /// Reinstall a specific package, regardless of whether it's already installed. Implies
6395    /// `--refresh-package`.
6396    #[arg(long, help_heading = "Installer options")]
6397    pub reinstall_package: Vec<PackageName>,
6398
6399    /// The strategy to use when resolving against multiple index URLs.
6400    ///
6401    /// By default, uv will stop at the first index on which a given package is available, and limit
6402    /// resolutions to those present on that first index (`first-index`). This prevents "dependency
6403    /// confusion" attacks, whereby an attacker can upload a malicious package under the same name
6404    /// to an alternate index.
6405    #[arg(
6406        long,
6407        value_enum,
6408        env = EnvVars::UV_INDEX_STRATEGY,
6409        help_heading = "Index options"
6410    )]
6411    pub index_strategy: Option<IndexStrategy>,
6412
6413    /// Attempt to use `keyring` for authentication for index URLs.
6414    ///
6415    /// At present, only `--keyring-provider subprocess` is supported, which configures uv to use
6416    /// the `keyring` CLI to handle authentication.
6417    ///
6418    /// Defaults to `disabled`.
6419    #[arg(
6420        long,
6421        value_enum,
6422        env = EnvVars::UV_KEYRING_PROVIDER,
6423        help_heading = "Index options"
6424    )]
6425    pub keyring_provider: Option<KeyringProviderType>,
6426
6427    /// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
6428    #[arg(
6429        long,
6430        short = 'C',
6431        alias = "config-settings",
6432        help_heading = "Build options"
6433    )]
6434    pub config_setting: Option<Vec<ConfigSettingEntry>>,
6435
6436    /// Settings to pass to the PEP 517 build backend for a specific package, specified as `PACKAGE:KEY=VALUE` pairs.
6437    #[arg(
6438        long,
6439        alias = "config-settings-package",
6440        help_heading = "Build options"
6441    )]
6442    pub config_settings_package: Option<Vec<ConfigSettingPackageEntry>>,
6443
6444    /// Disable isolation when building source distributions.
6445    ///
6446    /// Assumes that build dependencies specified by PEP 518 are already installed.
6447    #[arg(
6448        long,
6449        overrides_with("build_isolation"),
6450        help_heading = "Build options",
6451        env = EnvVars::UV_NO_BUILD_ISOLATION,
6452        value_parser = clap::builder::BoolishValueParser::new(),
6453    )]
6454    pub no_build_isolation: bool,
6455
6456    #[arg(
6457        long,
6458        overrides_with("no_build_isolation"),
6459        hide = true,
6460        help_heading = "Build options"
6461    )]
6462    pub build_isolation: bool,
6463
6464    /// Limit candidate packages to those that were uploaded prior to the given date.
6465    ///
6466    /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
6467    /// format (e.g., `2006-12-02`) in your system's configured time zone.
6468    #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
6469    pub exclude_newer: Option<ExcludeNewerTimestamp>,
6470
6471    /// Limit candidate packages for specific packages to those that were uploaded prior to the given date.
6472    ///
6473    /// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp
6474    /// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone.
6475    ///
6476    /// Can be provided multiple times for different packages.
6477    #[arg(long, help_heading = "Resolver options")]
6478    pub exclude_newer_package: Option<Vec<ExcludeNewerPackageEntry>>,
6479
6480    /// The method to use when installing packages from the global cache.
6481    ///
6482    /// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
6483    /// Windows.
6484    ///
6485    /// WARNING: The use of symlink link mode is discouraged, as they create tight coupling between
6486    /// the cache and the target environment. For example, clearing the cache (`uv cache clean`)
6487    /// will break all installed packages by way of removing the underlying source files. Use
6488    /// symlinks with caution.
6489    #[arg(
6490        long,
6491        value_enum,
6492        env = EnvVars::UV_LINK_MODE,
6493        help_heading = "Installer options"
6494    )]
6495    pub link_mode: Option<uv_install_wheel::LinkMode>,
6496
6497    /// Compile Python files to bytecode after installation.
6498    ///
6499    /// By default, uv does not compile Python (`.py`) files to bytecode (`__pycache__/*.pyc`);
6500    /// instead, compilation is performed lazily the first time a module is imported. For use-cases
6501    /// in which start time is critical, such as CLI applications and Docker containers, this option
6502    /// can be enabled to trade longer installation times for faster start times.
6503    ///
6504    /// When enabled, uv will process the entire site-packages directory (including packages that
6505    /// are not being modified by the current operation) for consistency. Like pip, it will also
6506    /// ignore errors.
6507    #[arg(
6508        long,
6509        alias = "compile",
6510        overrides_with("no_compile_bytecode"),
6511        help_heading = "Installer options",
6512        env = EnvVars::UV_COMPILE_BYTECODE,
6513        value_parser = clap::builder::BoolishValueParser::new(),
6514    )]
6515    pub compile_bytecode: bool,
6516
6517    #[arg(
6518        long,
6519        alias = "no-compile",
6520        overrides_with("compile_bytecode"),
6521        hide = true,
6522        help_heading = "Installer options"
6523    )]
6524    pub no_compile_bytecode: bool,
6525
6526    /// Ignore the `tool.uv.sources` table when resolving dependencies. Used to lock against the
6527    /// standards-compliant, publishable package metadata, as opposed to using any workspace, Git,
6528    /// URL, or local path sources.
6529    #[arg(
6530        long,
6531        env = EnvVars::UV_NO_SOURCES,
6532        value_parser = clap::builder::BoolishValueParser::new(),
6533        help_heading = "Resolver options"
6534    )]
6535    pub no_sources: bool,
6536}
6537
6538/// Arguments that are used by commands that need to resolve (but not install) packages.
6539#[derive(Args)]
6540pub struct ResolverArgs {
6541    #[command(flatten)]
6542    pub index_args: IndexArgs,
6543
6544    /// Allow package upgrades, ignoring pinned versions in any existing output file. Implies
6545    /// `--refresh`.
6546    #[arg(
6547        long,
6548        short = 'U',
6549        overrides_with("no_upgrade"),
6550        help_heading = "Resolver options"
6551    )]
6552    pub upgrade: bool,
6553
6554    #[arg(
6555        long,
6556        overrides_with("upgrade"),
6557        hide = true,
6558        help_heading = "Resolver options"
6559    )]
6560    pub no_upgrade: bool,
6561
6562    /// Allow upgrades for a specific package, ignoring pinned versions in any existing output
6563    /// file. Implies `--refresh-package`.
6564    #[arg(long, short = 'P', help_heading = "Resolver options")]
6565    pub upgrade_package: Vec<Requirement<VerbatimParsedUrl>>,
6566
6567    /// The strategy to use when resolving against multiple index URLs.
6568    ///
6569    /// By default, uv will stop at the first index on which a given package is available, and limit
6570    /// resolutions to those present on that first index (`first-index`). This prevents "dependency
6571    /// confusion" attacks, whereby an attacker can upload a malicious package under the same name
6572    /// to an alternate index.
6573    #[arg(
6574        long,
6575        value_enum,
6576        env = EnvVars::UV_INDEX_STRATEGY,
6577        help_heading = "Index options"
6578    )]
6579    pub index_strategy: Option<IndexStrategy>,
6580
6581    /// Attempt to use `keyring` for authentication for index URLs.
6582    ///
6583    /// At present, only `--keyring-provider subprocess` is supported, which configures uv to use
6584    /// the `keyring` CLI to handle authentication.
6585    ///
6586    /// Defaults to `disabled`.
6587    #[arg(
6588        long,
6589        value_enum,
6590        env = EnvVars::UV_KEYRING_PROVIDER,
6591        help_heading = "Index options"
6592    )]
6593    pub keyring_provider: Option<KeyringProviderType>,
6594
6595    /// The strategy to use when selecting between the different compatible versions for a given
6596    /// package requirement.
6597    ///
6598    /// By default, uv will use the latest compatible version of each package (`highest`).
6599    #[arg(
6600        long,
6601        value_enum,
6602        env = EnvVars::UV_RESOLUTION,
6603        help_heading = "Resolver options"
6604    )]
6605    pub resolution: Option<ResolutionMode>,
6606
6607    /// The strategy to use when considering pre-release versions.
6608    ///
6609    /// By default, uv will accept pre-releases for packages that _only_ publish pre-releases, along
6610    /// with first-party requirements that contain an explicit pre-release marker in the declared
6611    /// specifiers (`if-necessary-or-explicit`).
6612    #[arg(
6613        long,
6614        value_enum,
6615        env = EnvVars::UV_PRERELEASE,
6616        help_heading = "Resolver options"
6617    )]
6618    pub prerelease: Option<PrereleaseMode>,
6619
6620    #[arg(long, hide = true, help_heading = "Resolver options")]
6621    pub pre: bool,
6622
6623    /// The strategy to use when selecting multiple versions of a given package across Python
6624    /// versions and platforms.
6625    ///
6626    /// By default, uv will optimize for selecting the latest version of each package for each
6627    /// supported Python version (`requires-python`), while minimizing the number of selected
6628    /// versions across platforms.
6629    ///
6630    /// Under `fewest`, uv will minimize the number of selected versions for each package,
6631    /// preferring older versions that are compatible with a wider range of supported Python
6632    /// versions or platforms.
6633    #[arg(
6634        long,
6635        value_enum,
6636        env = EnvVars::UV_FORK_STRATEGY,
6637        help_heading = "Resolver options"
6638    )]
6639    pub fork_strategy: Option<ForkStrategy>,
6640
6641    /// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
6642    #[arg(
6643        long,
6644        short = 'C',
6645        alias = "config-settings",
6646        help_heading = "Build options"
6647    )]
6648    pub config_setting: Option<Vec<ConfigSettingEntry>>,
6649
6650    /// Settings to pass to the PEP 517 build backend for a specific package, specified as `PACKAGE:KEY=VALUE` pairs.
6651    #[arg(
6652        long,
6653        alias = "config-settings-package",
6654        help_heading = "Build options"
6655    )]
6656    pub config_settings_package: Option<Vec<ConfigSettingPackageEntry>>,
6657
6658    /// Disable isolation when building source distributions.
6659    ///
6660    /// Assumes that build dependencies specified by PEP 518 are already installed.
6661    #[arg(
6662        long,
6663        overrides_with("build_isolation"),
6664        help_heading = "Build options",
6665        env = EnvVars::UV_NO_BUILD_ISOLATION,
6666        value_parser = clap::builder::BoolishValueParser::new(),
6667    )]
6668    pub no_build_isolation: bool,
6669
6670    /// Disable isolation when building source distributions for a specific package.
6671    ///
6672    /// Assumes that the packages' build dependencies specified by PEP 518 are already installed.
6673    #[arg(long, help_heading = "Build options")]
6674    pub no_build_isolation_package: Vec<PackageName>,
6675
6676    #[arg(
6677        long,
6678        overrides_with("no_build_isolation"),
6679        hide = true,
6680        help_heading = "Build options"
6681    )]
6682    pub build_isolation: bool,
6683
6684    /// Limit candidate packages to those that were uploaded prior to the given date.
6685    ///
6686    /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
6687    /// format (e.g., `2006-12-02`) in your system's configured time zone.
6688    #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
6689    pub exclude_newer: Option<ExcludeNewerTimestamp>,
6690
6691    /// Limit candidate packages for a specific package to those that were uploaded prior to the given date.
6692    ///
6693    /// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp
6694    /// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone.
6695    ///
6696    /// Can be provided multiple times for different packages.
6697    #[arg(long, help_heading = "Resolver options")]
6698    pub exclude_newer_package: Option<Vec<ExcludeNewerPackageEntry>>,
6699
6700    /// The method to use when installing packages from the global cache.
6701    ///
6702    /// This option is only used when building source distributions.
6703    ///
6704    /// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
6705    /// Windows.
6706    ///
6707    /// WARNING: The use of symlink link mode is discouraged, as they create tight coupling between
6708    /// the cache and the target environment. For example, clearing the cache (`uv cache clean`)
6709    /// will break all installed packages by way of removing the underlying source files. Use
6710    /// symlinks with caution.
6711    #[arg(
6712        long,
6713        value_enum,
6714        env = EnvVars::UV_LINK_MODE,
6715        help_heading = "Installer options"
6716    )]
6717    pub link_mode: Option<uv_install_wheel::LinkMode>,
6718
6719    /// Ignore the `tool.uv.sources` table when resolving dependencies. Used to lock against the
6720    /// standards-compliant, publishable package metadata, as opposed to using any workspace, Git,
6721    /// URL, or local path sources.
6722    #[arg(
6723        long,
6724        env = EnvVars::UV_NO_SOURCES,
6725        value_parser = clap::builder::BoolishValueParser::new(),
6726        help_heading = "Resolver options",
6727    )]
6728    pub no_sources: bool,
6729}
6730
6731/// Arguments that are used by commands that need to resolve and install packages.
6732#[derive(Args)]
6733pub struct ResolverInstallerArgs {
6734    #[command(flatten)]
6735    pub index_args: IndexArgs,
6736
6737    /// Allow package upgrades, ignoring pinned versions in any existing output file. Implies
6738    /// `--refresh`.
6739    #[arg(
6740        long,
6741        short = 'U',
6742        overrides_with("no_upgrade"),
6743        help_heading = "Resolver options"
6744    )]
6745    pub upgrade: bool,
6746
6747    #[arg(
6748        long,
6749        overrides_with("upgrade"),
6750        hide = true,
6751        help_heading = "Resolver options"
6752    )]
6753    pub no_upgrade: bool,
6754
6755    /// Allow upgrades for a specific package, ignoring pinned versions in any existing output file.
6756    /// Implies `--refresh-package`.
6757    #[arg(long, short = 'P', help_heading = "Resolver options")]
6758    pub upgrade_package: Vec<Requirement<VerbatimParsedUrl>>,
6759
6760    /// Reinstall all packages, regardless of whether they're already installed. Implies
6761    /// `--refresh`.
6762    #[arg(
6763        long,
6764        alias = "force-reinstall",
6765        overrides_with("no_reinstall"),
6766        help_heading = "Installer options"
6767    )]
6768    pub reinstall: bool,
6769
6770    #[arg(
6771        long,
6772        overrides_with("reinstall"),
6773        hide = true,
6774        help_heading = "Installer options"
6775    )]
6776    pub no_reinstall: bool,
6777
6778    /// Reinstall a specific package, regardless of whether it's already installed. Implies
6779    /// `--refresh-package`.
6780    #[arg(long, help_heading = "Installer options")]
6781    pub reinstall_package: Vec<PackageName>,
6782
6783    /// The strategy to use when resolving against multiple index URLs.
6784    ///
6785    /// By default, uv will stop at the first index on which a given package is available, and limit
6786    /// resolutions to those present on that first index (`first-index`). This prevents "dependency
6787    /// confusion" attacks, whereby an attacker can upload a malicious package under the same name
6788    /// to an alternate index.
6789    #[arg(
6790        long,
6791        value_enum,
6792        env = EnvVars::UV_INDEX_STRATEGY,
6793        help_heading = "Index options"
6794    )]
6795    pub index_strategy: Option<IndexStrategy>,
6796
6797    /// Attempt to use `keyring` for authentication for index URLs.
6798    ///
6799    /// At present, only `--keyring-provider subprocess` is supported, which configures uv to use
6800    /// the `keyring` CLI to handle authentication.
6801    ///
6802    /// Defaults to `disabled`.
6803    #[arg(
6804        long,
6805        value_enum,
6806        env = EnvVars::UV_KEYRING_PROVIDER,
6807        help_heading = "Index options"
6808    )]
6809    pub keyring_provider: Option<KeyringProviderType>,
6810
6811    /// The strategy to use when selecting between the different compatible versions for a given
6812    /// package requirement.
6813    ///
6814    /// By default, uv will use the latest compatible version of each package (`highest`).
6815    #[arg(
6816        long,
6817        value_enum,
6818        env = EnvVars::UV_RESOLUTION,
6819        help_heading = "Resolver options"
6820    )]
6821    pub resolution: Option<ResolutionMode>,
6822
6823    /// The strategy to use when considering pre-release versions.
6824    ///
6825    /// By default, uv will accept pre-releases for packages that _only_ publish pre-releases, along
6826    /// with first-party requirements that contain an explicit pre-release marker in the declared
6827    /// specifiers (`if-necessary-or-explicit`).
6828    #[arg(
6829        long,
6830        value_enum,
6831        env = EnvVars::UV_PRERELEASE,
6832        help_heading = "Resolver options"
6833    )]
6834    pub prerelease: Option<PrereleaseMode>,
6835
6836    #[arg(long, hide = true)]
6837    pub pre: bool,
6838
6839    /// The strategy to use when selecting multiple versions of a given package across Python
6840    /// versions and platforms.
6841    ///
6842    /// By default, uv will optimize for selecting the latest version of each package for each
6843    /// supported Python version (`requires-python`), while minimizing the number of selected
6844    /// versions across platforms.
6845    ///
6846    /// Under `fewest`, uv will minimize the number of selected versions for each package,
6847    /// preferring older versions that are compatible with a wider range of supported Python
6848    /// versions or platforms.
6849    #[arg(
6850        long,
6851        value_enum,
6852        env = EnvVars::UV_FORK_STRATEGY,
6853        help_heading = "Resolver options"
6854    )]
6855    pub fork_strategy: Option<ForkStrategy>,
6856
6857    /// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
6858    #[arg(
6859        long,
6860        short = 'C',
6861        alias = "config-settings",
6862        help_heading = "Build options"
6863    )]
6864    pub config_setting: Option<Vec<ConfigSettingEntry>>,
6865
6866    /// Settings to pass to the PEP 517 build backend for a specific package, specified as `PACKAGE:KEY=VALUE` pairs.
6867    #[arg(
6868        long,
6869        alias = "config-settings-package",
6870        help_heading = "Build options"
6871    )]
6872    pub config_settings_package: Option<Vec<ConfigSettingPackageEntry>>,
6873
6874    /// Disable isolation when building source distributions.
6875    ///
6876    /// Assumes that build dependencies specified by PEP 518 are already installed.
6877    #[arg(
6878        long,
6879        overrides_with("build_isolation"),
6880        help_heading = "Build options",
6881        env = EnvVars::UV_NO_BUILD_ISOLATION,
6882        value_parser = clap::builder::BoolishValueParser::new(),
6883    )]
6884    pub no_build_isolation: bool,
6885
6886    /// Disable isolation when building source distributions for a specific package.
6887    ///
6888    /// Assumes that the packages' build dependencies specified by PEP 518 are already installed.
6889    #[arg(long, help_heading = "Build options")]
6890    pub no_build_isolation_package: Vec<PackageName>,
6891
6892    #[arg(
6893        long,
6894        overrides_with("no_build_isolation"),
6895        hide = true,
6896        help_heading = "Build options"
6897    )]
6898    pub build_isolation: bool,
6899
6900    /// Limit candidate packages to those that were uploaded prior to the given date.
6901    ///
6902    /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
6903    /// format (e.g., `2006-12-02`) in your system's configured time zone.
6904    #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
6905    pub exclude_newer: Option<ExcludeNewerTimestamp>,
6906
6907    /// Limit candidate packages for specific packages to those that were uploaded prior to the given date.
6908    ///
6909    /// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp
6910    /// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone.
6911    ///
6912    /// Can be provided multiple times for different packages.
6913    #[arg(long, help_heading = "Resolver options")]
6914    pub exclude_newer_package: Option<Vec<ExcludeNewerPackageEntry>>,
6915
6916    /// The method to use when installing packages from the global cache.
6917    ///
6918    /// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
6919    /// Windows.
6920    ///
6921    /// WARNING: The use of symlink link mode is discouraged, as they create tight coupling between
6922    /// the cache and the target environment. For example, clearing the cache (`uv cache clean`)
6923    /// will break all installed packages by way of removing the underlying source files. Use
6924    /// symlinks with caution.
6925    #[arg(
6926        long,
6927        value_enum,
6928        env = EnvVars::UV_LINK_MODE,
6929        help_heading = "Installer options"
6930    )]
6931    pub link_mode: Option<uv_install_wheel::LinkMode>,
6932
6933    /// Compile Python files to bytecode after installation.
6934    ///
6935    /// By default, uv does not compile Python (`.py`) files to bytecode (`__pycache__/*.pyc`);
6936    /// instead, compilation is performed lazily the first time a module is imported. For use-cases
6937    /// in which start time is critical, such as CLI applications and Docker containers, this option
6938    /// can be enabled to trade longer installation times for faster start times.
6939    ///
6940    /// When enabled, uv will process the entire site-packages directory (including packages that
6941    /// are not being modified by the current operation) for consistency. Like pip, it will also
6942    /// ignore errors.
6943    #[arg(
6944        long,
6945        alias = "compile",
6946        overrides_with("no_compile_bytecode"),
6947        help_heading = "Installer options",
6948        env = EnvVars::UV_COMPILE_BYTECODE,
6949        value_parser = clap::builder::BoolishValueParser::new(),
6950    )]
6951    pub compile_bytecode: bool,
6952
6953    #[arg(
6954        long,
6955        alias = "no-compile",
6956        overrides_with("compile_bytecode"),
6957        hide = true,
6958        help_heading = "Installer options"
6959    )]
6960    pub no_compile_bytecode: bool,
6961
6962    /// Ignore the `tool.uv.sources` table when resolving dependencies. Used to lock against the
6963    /// standards-compliant, publishable package metadata, as opposed to using any workspace, Git,
6964    /// URL, or local path sources.
6965    #[arg(
6966        long,
6967        env = EnvVars::UV_NO_SOURCES,
6968        value_parser = clap::builder::BoolishValueParser::new(),
6969        help_heading = "Resolver options",
6970    )]
6971    pub no_sources: bool,
6972}
6973
6974/// Arguments that are used by commands that need to fetch from the Simple API.
6975#[derive(Args)]
6976pub struct FetchArgs {
6977    #[command(flatten)]
6978    pub index_args: IndexArgs,
6979
6980    /// The strategy to use when resolving against multiple index URLs.
6981    ///
6982    /// By default, uv will stop at the first index on which a given package is available, and limit
6983    /// resolutions to those present on that first index (`first-index`). This prevents "dependency
6984    /// confusion" attacks, whereby an attacker can upload a malicious package under the same name
6985    /// to an alternate index.
6986    #[arg(
6987        long,
6988        value_enum,
6989        env = EnvVars::UV_INDEX_STRATEGY,
6990        help_heading = "Index options"
6991    )]
6992    pub index_strategy: Option<IndexStrategy>,
6993
6994    /// Attempt to use `keyring` for authentication for index URLs.
6995    ///
6996    /// At present, only `--keyring-provider subprocess` is supported, which configures uv to use
6997    /// the `keyring` CLI to handle authentication.
6998    ///
6999    /// Defaults to `disabled`.
7000    #[arg(
7001        long,
7002        value_enum,
7003        env = EnvVars::UV_KEYRING_PROVIDER,
7004        help_heading = "Index options"
7005    )]
7006    pub keyring_provider: Option<KeyringProviderType>,
7007
7008    /// Limit candidate packages to those that were uploaded prior to the given date.
7009    ///
7010    /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
7011    /// format (e.g., `2006-12-02`) in your system's configured time zone.
7012    #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
7013    pub exclude_newer: Option<ExcludeNewerTimestamp>,
7014}
7015
7016#[derive(Args)]
7017pub struct DisplayTreeArgs {
7018    /// Maximum display depth of the dependency tree
7019    #[arg(long, short, default_value_t = 255)]
7020    pub depth: u8,
7021
7022    /// Prune the given package from the display of the dependency tree.
7023    #[arg(long)]
7024    pub prune: Vec<PackageName>,
7025
7026    /// Display only the specified packages.
7027    #[arg(long)]
7028    pub package: Vec<PackageName>,
7029
7030    /// Do not de-duplicate repeated dependencies. Usually, when a package has already displayed its
7031    /// dependencies, further occurrences will not re-display its dependencies, and will include a
7032    /// (*) to indicate it has already been shown. This flag will cause those duplicates to be
7033    /// repeated.
7034    #[arg(long)]
7035    pub no_dedupe: bool,
7036
7037    /// Show the reverse dependencies for the given package. This flag will invert the tree and
7038    /// display the packages that depend on the given package.
7039    #[arg(long, alias = "reverse")]
7040    pub invert: bool,
7041
7042    /// Show the latest available version of each package in the tree.
7043    #[arg(long)]
7044    pub outdated: bool,
7045
7046    /// Show compressed wheel sizes for packages in the tree.
7047    #[arg(long)]
7048    pub show_sizes: bool,
7049}
7050
7051#[derive(Args, Debug)]
7052pub struct PublishArgs {
7053    /// Paths to the files to upload. Accepts glob expressions.
7054    ///
7055    /// Defaults to the `dist` directory. Selects only wheels and source distributions
7056    /// and their attestations, while ignoring other files.
7057    #[arg(default_value = "dist/*")]
7058    pub files: Vec<String>,
7059
7060    /// The name of an index in the configuration to use for publishing.
7061    ///
7062    /// The index must have a `publish-url` setting, for example:
7063    ///
7064    /// ```toml
7065    /// [[tool.uv.index]]
7066    /// name = "pypi"
7067    /// url = "https://pypi.org/simple"
7068    /// publish-url = "https://upload.pypi.org/legacy/"
7069    /// ```
7070    ///
7071    /// The index `url` will be used to check for existing files to skip duplicate uploads.
7072    ///
7073    /// With these settings, the following two calls are equivalent:
7074    ///
7075    /// ```shell
7076    /// uv publish --index pypi
7077    /// uv publish --publish-url https://upload.pypi.org/legacy/ --check-url https://pypi.org/simple
7078    /// ```
7079    #[arg(
7080        long,
7081        verbatim_doc_comment,
7082        env = EnvVars::UV_PUBLISH_INDEX,
7083        conflicts_with = "publish_url",
7084        conflicts_with = "check_url"
7085    )]
7086    pub index: Option<String>,
7087
7088    /// The username for the upload.
7089    #[arg(short, long, env = EnvVars::UV_PUBLISH_USERNAME)]
7090    pub username: Option<String>,
7091
7092    /// The password for the upload.
7093    #[arg(short, long, env = EnvVars::UV_PUBLISH_PASSWORD)]
7094    pub password: Option<String>,
7095
7096    /// The token for the upload.
7097    ///
7098    /// Using a token is equivalent to passing `__token__` as `--username` and the token as
7099    /// `--password` password.
7100    #[arg(
7101        short,
7102        long,
7103        env = EnvVars::UV_PUBLISH_TOKEN,
7104        conflicts_with = "username",
7105        conflicts_with = "password"
7106    )]
7107    pub token: Option<String>,
7108
7109    /// Configure trusted publishing.
7110    ///
7111    /// By default, uv checks for trusted publishing when running in a supported environment, but
7112    /// ignores it if it isn't configured.
7113    ///
7114    /// uv's supported environments for trusted publishing include GitHub Actions and GitLab CI/CD.
7115    #[arg(long)]
7116    pub trusted_publishing: Option<TrustedPublishing>,
7117
7118    /// Attempt to use `keyring` for authentication for remote requirements files.
7119    ///
7120    /// At present, only `--keyring-provider subprocess` is supported, which configures uv to use
7121    /// the `keyring` CLI to handle authentication.
7122    ///
7123    /// Defaults to `disabled`.
7124    #[arg(long, value_enum, env = EnvVars::UV_KEYRING_PROVIDER)]
7125    pub keyring_provider: Option<KeyringProviderType>,
7126
7127    /// The URL of the upload endpoint (not the index URL).
7128    ///
7129    /// Note that there are typically different URLs for index access (e.g., `https:://.../simple`)
7130    /// and index upload.
7131    ///
7132    /// Defaults to PyPI's publish URL (<https://upload.pypi.org/legacy/>).
7133    #[arg(long, env = EnvVars::UV_PUBLISH_URL)]
7134    pub publish_url: Option<DisplaySafeUrl>,
7135
7136    /// Check an index URL for existing files to skip duplicate uploads.
7137    ///
7138    /// This option allows retrying publishing that failed after only some, but not all files have
7139    /// been uploaded, and handles errors due to parallel uploads of the same file.
7140    ///
7141    /// Before uploading, the index is checked. If the exact same file already exists in the index,
7142    /// the file will not be uploaded. If an error occurred during the upload, the index is checked
7143    /// again, to handle cases where the identical file was uploaded twice in parallel.
7144    ///
7145    /// The exact behavior will vary based on the index. When uploading to PyPI, uploading the same
7146    /// file succeeds even without `--check-url`, while most other indexes error. When uploading to
7147    /// pyx, the index URL can be inferred automatically from the publish URL.
7148    ///
7149    /// The index must provide one of the supported hashes (SHA-256, SHA-384, or SHA-512).
7150    #[arg(long, env = EnvVars::UV_PUBLISH_CHECK_URL)]
7151    pub check_url: Option<IndexUrl>,
7152
7153    #[arg(long, hide = true)]
7154    pub skip_existing: bool,
7155
7156    /// Perform a dry run without uploading files.
7157    ///
7158    /// When enabled, the command will check for existing files if `--check-url` is provided,
7159    /// and will perform validation against the index if supported, but will not upload any files.
7160    #[arg(long)]
7161    pub dry_run: bool,
7162
7163    /// Do not upload attestations for the published files.
7164    ///
7165    /// By default, uv attempts to upload matching PEP 740 attestations with each distribution
7166    /// that is published.
7167    #[arg(long, env = EnvVars::UV_PUBLISH_NO_ATTESTATIONS)]
7168    pub no_attestations: bool,
7169}
7170
7171#[derive(Args)]
7172pub struct WorkspaceNamespace {
7173    #[command(subcommand)]
7174    pub command: WorkspaceCommand,
7175}
7176
7177#[derive(Subcommand)]
7178pub enum WorkspaceCommand {
7179    /// View metadata about the current workspace.
7180    ///
7181    /// The output of this command is not yet stable.
7182    Metadata(MetadataArgs),
7183    /// Display the path of a workspace member.
7184    ///
7185    /// By default, the path to the workspace root directory is displayed.
7186    /// The `--package` option can be used to display the path to a workspace member instead.
7187    ///
7188    /// If used outside of a workspace, i.e., if a `pyproject.toml` cannot be found, uv will exit with an error.
7189    Dir(WorkspaceDirArgs),
7190    /// List the members of a workspace.
7191    ///
7192    /// Displays newline separated names of workspace members.
7193    #[command(hide = true)]
7194    List(WorkspaceListArgs),
7195}
7196
7197#[derive(Args, Debug)]
7198pub struct MetadataArgs;
7199
7200#[derive(Args, Debug)]
7201pub struct WorkspaceDirArgs {
7202    /// Display the path to a specific package in the workspace.
7203    #[arg(long)]
7204    pub package: Option<PackageName>,
7205}
7206
7207#[derive(Args, Debug)]
7208pub struct WorkspaceListArgs {
7209    /// Show paths instead of names.
7210    #[arg(long)]
7211    pub paths: bool,
7212}
7213
7214/// See [PEP 517](https://peps.python.org/pep-0517/) and
7215/// [PEP 660](https://peps.python.org/pep-0660/) for specifications of the parameters.
7216#[derive(Subcommand)]
7217pub enum BuildBackendCommand {
7218    /// PEP 517 hook `build_sdist`.
7219    BuildSdist { sdist_directory: PathBuf },
7220    /// PEP 517 hook `build_wheel`.
7221    BuildWheel {
7222        wheel_directory: PathBuf,
7223        #[arg(long)]
7224        metadata_directory: Option<PathBuf>,
7225    },
7226    /// PEP 660 hook `build_editable`.
7227    BuildEditable {
7228        wheel_directory: PathBuf,
7229        #[arg(long)]
7230        metadata_directory: Option<PathBuf>,
7231    },
7232    /// PEP 517 hook `get_requires_for_build_sdist`.
7233    GetRequiresForBuildSdist,
7234    /// PEP 517 hook `get_requires_for_build_wheel`.
7235    GetRequiresForBuildWheel,
7236    /// PEP 517 hook `prepare_metadata_for_build_wheel`.
7237    PrepareMetadataForBuildWheel { wheel_directory: PathBuf },
7238    /// PEP 660 hook `get_requires_for_build_editable`.
7239    GetRequiresForBuildEditable,
7240    /// PEP 660 hook `prepare_metadata_for_build_editable`.
7241    PrepareMetadataForBuildEditable { wheel_directory: PathBuf },
7242}