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