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