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