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