diff --git a/Cargo.lock b/Cargo.lock index 4ffc7beef67d5..fc2d998d38b09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2062,6 +2062,17 @@ dependencies = [ "quoted_printable", ] +[[package]] +name = "markdown" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef3aab6a1d529b112695f72beec5ee80e729cb45af58663ec902c8fac764ecdd" +dependencies = [ + "lazy_static", + "pipeline", + "regex", +] + [[package]] name = "matchers" version = "0.1.0" @@ -2563,6 +2574,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pipeline" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d15b6607fa632996eb8a17c9041cb6071cb75ac057abd45dece578723ea8c7c0" + [[package]] name = "pkg-config" version = "0.3.30" @@ -2711,7 +2728,7 @@ dependencies = [ "indexmap", "log", "priority-queue", - "rustc-hash 1.1.0", + "rustc-hash 2.0.0", "thiserror", ] @@ -4689,6 +4706,7 @@ dependencies = [ "fs-err", "install-wheel-rs", "itertools 0.13.0", + "markdown", "mimalloc", "owo-colors", "pep508_rs", @@ -4709,6 +4727,7 @@ dependencies = [ "tracing-subscriber", "uv-build", "uv-cache", + "uv-cli", "uv-client", "uv-configuration", "uv-dispatch", diff --git a/crates/uv-cli/Cargo.toml b/crates/uv-cli/Cargo.toml index 063490dd1fa68..2a1504205545e 100644 --- a/crates/uv-cli/Cargo.toml +++ b/crates/uv-cli/Cargo.toml @@ -29,7 +29,7 @@ uv-warnings = { workspace = true } anstream = { workspace = true } anyhow = { workspace = true } -clap = { workspace = true, features = ["derive"] } +clap = { workspace = true, features = ["derive", "string"] } clap_complete_command = { workspace = true } serde = { workspace = true } url = { workspace = true } diff --git a/crates/uv-dev/Cargo.toml b/crates/uv-dev/Cargo.toml index 02b5331412eff..3549bdb085700 100644 --- a/crates/uv-dev/Cargo.toml +++ b/crates/uv-dev/Cargo.toml @@ -23,6 +23,7 @@ pep508_rs = { workspace = true } pypi-types = { workspace = true } uv-build = { workspace = true } uv-cache = { workspace = true, features = ["clap"] } +uv-cli = { workspace = true } uv-client = { workspace = true } uv-configuration = { workspace = true } uv-dispatch = { workspace = true } @@ -43,6 +44,7 @@ anyhow = { workspace = true } clap = { workspace = true, features = ["derive", "wrap_help"] } fs-err = { workspace = true, features = ["tokio"] } itertools = { workspace = true } +markdown = "0.3.0" owo-colors = { workspace = true } poloto = { version = "19.1.2", optional = true } pretty_assertions = { version = "1.4.0" } diff --git a/crates/uv-dev/src/generate_cli_reference.rs b/crates/uv-dev/src/generate_cli_reference.rs new file mode 100644 index 0000000000000..f5a31aec487a7 --- /dev/null +++ b/crates/uv-dev/src/generate_cli_reference.rs @@ -0,0 +1,253 @@ +//! Generate a Markdown-compatible reference for the uv command-line interface. +use std::cmp::max; +use std::path::PathBuf; + +use anstream::println; +use anyhow::{bail, Result}; +use clap::{Command, CommandFactory}; +use itertools::Itertools; +use pretty_assertions::StrComparison; + +use crate::generate_all::Mode; +use crate::ROOT_DIR; + +use uv_cli::Cli; + +#[derive(clap::Args)] +pub(crate) struct Args { + /// Write the generated output to stdout (rather than to `settings.md`). + #[arg(long, default_value_t, value_enum)] + pub(crate) mode: Mode, +} + +pub(crate) fn main(args: &Args) -> Result<()> { + let reference_string = generate(); + let filename = "cli.md"; + let reference_path = PathBuf::from(ROOT_DIR) + .join("docs") + .join("reference") + .join(filename); + + match args.mode { + Mode::DryRun => { + println!("{reference_string}"); + } + Mode::Check => match fs_err::read_to_string(reference_path) { + Ok(current) => { + if current == reference_string { + println!("Up-to-date: {filename}"); + } else { + let comparison = StrComparison::new(¤t, &reference_string); + bail!("{filename} changed, please run `cargo dev generate-cli-reference`:\n{comparison}"); + } + } + Err(err) if err.kind() == std::io::ErrorKind::NotFound => { + bail!("{filename} not found, please run `cargo dev generate-cli-reference`"); + } + Err(err) => { + bail!("{filename} changed, please run `cargo dev generate-cli-reference`:\n{err}"); + } + }, + Mode::Write => match fs_err::read_to_string(&reference_path) { + Ok(current) => { + if current == reference_string { + println!("Up-to-date: {filename}"); + } else { + println!("Updating: {filename}"); + fs_err::write(reference_path, reference_string.as_bytes())?; + } + } + Err(err) if err.kind() == std::io::ErrorKind::NotFound => { + println!("Updating: {filename}"); + fs_err::write(reference_path, reference_string.as_bytes())?; + } + Err(err) => { + bail!("{filename} changed, please run `cargo dev generate-cli-reference`:\n{err}"); + } + }, + } + + Ok(()) +} + +fn generate() -> String { + let mut output = String::new(); + + let mut uv = Cli::command(); + + // It is very important to build the command before beginning inspection or subcommands + // will be missing all of the propagated options. + uv.build(); + + let mut parents = Vec::new(); + + output.push_str("# CLI Reference\n\n"); + generate_command(&mut output, &uv, &mut parents); + + output +} + +fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut Vec<&'a Command>) { + if command.is_hide_set() { + return; + } + + // Generate the command header. + let name = if parents.is_empty() { + command.get_name().to_string() + } else { + format!( + "{} {}", + parents.iter().map(|cmd| cmd.get_name()).join(" "), + command.get_name() + ) + }; + + // Display the top-level `uv` command at the same level as its children + let level = max(2, parents.len() + 1); + output.push_str(&format!("{} {name}\n\n", "#".repeat(level))); + + // Display the command description. + if let Some(about) = command.get_long_about().or_else(|| command.get_about()) { + output.push_str(&about.to_string()); + output.push_str("\n\n"); + }; + + // Display the usage + { + // This appears to be the simplest way to get rendered usage from Clap, + // it is complicated to render it manually. It's annoying that it + // requires a mutable reference but it doesn't really matter. + let mut command = command.clone(); + output.push_str("

Usage

\n\n"); + output.push_str(&format!( + "```\n{}\n```", + command + .render_usage() + .to_string() + .trim_start_matches("Usage: "), + )); + output.push_str("\n\n"); + } + + // Display a list of child commands + let mut subcommands = command.get_subcommands().peekable(); + let has_subcommands = subcommands.peek().is_some(); + if has_subcommands { + output.push_str("

Commands

\n\n"); + output.push_str("
"); + + for subcommand in subcommands { + if subcommand.is_hide_set() { + continue; + } + let subcommand_name = format!("{name} {}", subcommand.get_name()); + output.push_str(&format!( + "
{subcommand_name}
", + subcommand_name.replace(' ', "-") + )); + if let Some(about) = subcommand.get_about() { + output.push_str(&format!( + "
{}
\n", + markdown::to_html(&about.to_string()) + )); + } + } + + output.push_str("
\n\n"); + } + + // Do not display options for commands with children + if !has_subcommands { + // Display positional arguments + let mut arguments = command + .get_positionals() + .filter(|arg| !arg.is_hide_set()) + .peekable(); + + if arguments.peek().is_some() { + output.push_str("

Arguments

\n\n"); + output.push_str("
"); + + for arg in arguments { + output.push_str("
"); + output.push_str(&format!( + "{}", + arg.get_id().to_string().to_uppercase() + )); + output.push_str("
"); + if let Some(help) = arg.get_long_help().or_else(|| arg.get_help()) { + output.push_str("
"); + output.push_str(&format!("{}\n", markdown::to_html(&help.to_string()))); + output.push_str("
"); + } + } + + output.push_str("
\n\n"); + } + + // Display options + let mut options = command + .get_opts() + .filter(|arg| !arg.is_hide_set()) + .peekable(); + + if options.peek().is_some() { + output.push_str("

Options

\n\n"); + output.push_str("
"); + for opt in command.get_opts() { + if opt.is_hide_set() { + continue; + } + + let Some(long) = opt.get_long() else { continue }; + + output.push_str("
"); + output.push_str(&format!("--{long}")); + if let Some(short) = opt.get_short() { + output.push_str(&format!(", -{short}")); + } + output.push_str("
"); + if let Some(help) = opt.get_long_help().or_else(|| opt.get_help()) { + output.push_str("
"); + output.push_str(&format!("{}\n", markdown::to_html(&help.to_string()))); + output.push_str("
"); + } + } + + output.push_str("
"); + } + + output.push_str("\n\n"); + } + + parents.push(command); + + // Recurse to all of the subcommands. + for subcommand in command.get_subcommands() { + generate_command(output, subcommand, parents); + } + + parents.pop(); +} + +#[cfg(test)] +mod tests { + use std::env; + + use anyhow::Result; + + use crate::generate_all::Mode; + + use super::{main, Args}; + + #[test] + fn test_generate_cli_reference() -> Result<()> { + let mode = if env::var("UV_UPDATE_SCHEMA").as_deref() == Ok("1") { + Mode::Write + } else { + Mode::Check + }; + main(&Args { mode }) + } +} diff --git a/crates/uv-dev/src/main.rs b/crates/uv-dev/src/main.rs index b138bab590dec..7530167bee770 100644 --- a/crates/uv-dev/src/main.rs +++ b/crates/uv-dev/src/main.rs @@ -20,6 +20,7 @@ use crate::build::{build, BuildArgs}; use crate::clear_compile::ClearCompileArgs; use crate::compile::CompileArgs; use crate::generate_all::Args as GenerateAllArgs; +use crate::generate_cli_reference::Args as GenerateCliReferenceArgs; use crate::generate_json_schema::Args as GenerateJsonSchemaArgs; use crate::generate_options_reference::Args as GenerateOptionsReferenceArgs; #[cfg(feature = "render")] @@ -46,6 +47,7 @@ mod build; mod clear_compile; mod compile; mod generate_all; +mod generate_cli_reference; mod generate_json_schema; mod generate_options_reference; mod render_benchmarks; @@ -69,6 +71,8 @@ enum Cli { GenerateJSONSchema(GenerateJsonSchemaArgs), /// Generate the options reference for the documentation. GenerateOptionsReference(GenerateOptionsReferenceArgs), + /// Generate the CLI reference for the documentation. + GenerateCliReference(GenerateCliReferenceArgs), #[cfg(feature = "render")] /// Render the benchmarks. RenderBenchmarks(RenderBenchmarksArgs), @@ -88,6 +92,7 @@ async fn run() -> Result<()> { Cli::GenerateAll(args) => generate_all::main(&args)?, Cli::GenerateJSONSchema(args) => generate_json_schema::main(&args)?, Cli::GenerateOptionsReference(args) => generate_options_reference::main(&args)?, + Cli::GenerateCliReference(args) => generate_cli_reference::main(&args)?, #[cfg(feature = "render")] Cli::RenderBenchmarks(args) => render_benchmarks::render_benchmarks(&args)?, } diff --git a/docs/reference/cli.md b/docs/reference/cli.md new file mode 100644 index 0000000000000..cee2f8b8b24f7 --- /dev/null +++ b/docs/reference/cli.md @@ -0,0 +1,1580 @@ +# CLI Reference + +## uv + +An extremely fast Python package manager. + +

Usage

+ +``` +uv [OPTIONS] +``` + +

Commands

+ +
uv pip

Resolve and install Python packages

+
+
uv tool

Run and manage executable Python packages

+
+
uv python

Manage Python installations

+
+
uv venv

Create a virtual environment

+
+
uv cache

Manage the cache

+
+
uv version

Display uv’s version

+
+
uv help

Display documentation for a command

+
+
+ +## uv pip + +Resolve and install Python packages + +

Usage

+ +``` +uv pip [OPTIONS] +``` + +

Commands

+ +
uv pip compile

Compile a requirements.in file to a requirements.txt file

+
+
uv pip sync

Sync an environment with a requirements.txt file

+
+
uv pip install

Install packages into an environment

+
+
uv pip uninstall

Uninstall packages from an environment

+
+
uv pip freeze

List, in requirements format, packages installed in an environment

+
+
uv pip list

List, in tabular format, packages installed in an environment

+
+
uv pip show

Show information about one or more installed packages

+
+
uv pip tree

Display the dependency tree for an environment

+
+
uv pip check

Verify installed packages have compatible dependencies

+
+
+ +### uv pip compile + +Compile a `requirements.in` file to a `requirements.txt` file + +

Usage

+ +``` +uv pip compile [OPTIONS] ... +``` + +

Arguments

+ +
SRC_FILE

Include all packages listed in the given requirements.in files.

+ +

If a pyproject.toml, setup.py, or setup.cfg file is provided, uv will extract the requirements for the relevant project.

+ +

If - is provided, then requirements will be read from stdin.

+ +
+ +

Options

+ +
--constraint, -c

Constrain versions using the given requirements files.

+ +

Constraints files are requirements.txt-like files that only control the version of a requirement that’s installed. However, including a package in a constraints file will not trigger the installation of that package.

+ +

This is equivalent to pip’s --constraint option.

+ +
--override

Override versions using the given requirements files.

+ +

Overrides files are requirements.txt-like files that force a specific version of a requirement to be installed, regardless of the requirements declared by any constituent package, and regardless of whether this would be considered an invalid resolution.

+ +

While constraints are additive, in that they’re combined with the requirements of the constituent packages, overrides are absolute, in that they completely replace the requirements of the constituent packages.

+ +
--extra

Include optional dependencies from the extra group name; may be provided more than once.

+ +

Only applies to pyproject.toml, setup.py, and setup.cfg sources.

+ +
--index-url, -i

The URL of the Python package index (by default: <https://pypi.org/simple>).

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

The index given by this flag is given lower priority than all other indexes specified via the --extra-index-url flag.

+ +
--extra-index-url

Extra URLs of package indexes to use, in addition to --index-url.

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

+ +
--find-links, -f

Locations to search for candidate distributions, in addition to those found in the registry indexes.

+ +

If a path, the target must be a directory that contains packages as wheel files (.whl) or source distributions (.tar.gz or .zip) at the top level.

+ +

If a URL, the page must contain a flat list of links to package files adhering to the formats described above.

+ +
--upgrade-package, -P

Allow upgrades for a specific package, ignoring pinned versions in any existing output file

+ +
--index-strategy

The strategy to use when resolving against multiple index URLs.

+ +

By default, uv will stop at the first index on which a given package is available, and limit resolutions to those present on that first index (first-match). This prevents "dependency confusion" attacks, whereby an attack can upload a malicious package under the same name to a secondary.

+ +
--keyring-provider

Attempt to use keyring for authentication for index URLs.

+ +

At present, only --keyring-provider subprocess is supported, which configures uv to use the keyring CLI to handle authentication.

+ +

Defaults to disabled.

+ +
--resolution

The strategy to use when selecting between the different compatible versions for a given package requirement.

+ +

By default, uv will use the latest compatible version of each package (highest).

+ +
--prerelease

The strategy to use when considering pre-release versions.

+ +

By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers (if-necessary-or-explicit).

+ +
--config-setting, -C

Settings to pass to the PEP 517 build backend, specified as KEY=VALUE pairs

+ +
--exclude-newer

Limit candidate packages to those that were uploaded prior to the given date.

+ +

Accepts both RFC 3339 timestamps (e.g., 2006-12-02T02:07:43Z) and UTC dates in the same format (e.g., 2006-12-02).

+ +
--link-mode

The method to use when installing packages from the global cache.

+ +

This option is only used when building source distributions.

+ +

Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.

+ +
--refresh-package

Refresh cached data for a specific package

+ +
--output-file, -o

Write the compiled requirements to the given requirements.txt file.

+ +

If the file already exists, the existing versions will be preferred when resolving dependencies, unless --upgrade is also specified.

+ +
--annotation-style

The style of the annotation comments included in the output file, used to indicate the source of each package.

+ +

Defaults to split.

+ +
--custom-compile-command

The header comment to include at the top of the output file generated by uv pip compile.

+ +

Used to reflect custom build scripts and commands that wrap uv pip compile.

+ +
--python

The Python interpreter against which to compile the requirements.

+ +

By default, uv uses the virtual environment in the current working directory or any parent directory, falling back to searching for a Python executable in PATH. The --python option allows you to specify a different interpreter.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +
--no-binary

Don’t install pre-built wheels.

+ +

The given packages will be built and installed from source. The resolver will still use pre-built wheels to extract package metadata, if available.

+ +

Multiple packages may be provided. Disable binaries for all packages with :all:. Clear previously specified packages with :none:.

+ +
--only-binary

Only use pre-built wheels; don’t build source distributions.

+ +

When enabled, resolving will not run code from the given packages. The cached wheels of already-built source distributions will be reused, but operations that require building distributions will exit with an error.

+ +

Multiple packages may be provided. Disable binaries for all packages with :all:. Clear previously specified packages with :none:.

+ +
--python-version, -p

The minimum Python version that should be supported by the resolved requirements (e.g., 3.8 or 3.8.17).

+ +

If a patch version is omitted, the minimum patch version is assumed. For example, 3.8 is mapped to 3.8.0.

+ +
--python-platform

The platform for which requirements should be resolved.

+ +

Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aaarch64-apple-darwin.

+ +
--no-emit-package

Specify a package to omit from the output resolution. Its dependencies will still be included in the resolution. Equivalent to pip-compile’s --unsafe-package option

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv pip sync + +Sync an environment with a `requirements.txt` file + +

Usage

+ +``` +uv pip sync [OPTIONS] ... +``` + +

Arguments

+ +
SRC_FILE

Include all packages listed in the given requirements.txt files.

+ +

If a pyproject.toml, setup.py, or setup.cfg file is provided, uv will extract the requirements for the relevant project.

+ +

If - is provided, then requirements will be read from stdin.

+ +
+ +

Options

+ +
--constraint, -c

Constrain versions using the given requirements files.

+ +

Constraints files are requirements.txt-like files that only control the version of a requirement that’s installed. However, including a package in a constraints file will not trigger the installation of that package.

+ +

This is equivalent to pip’s --constraint option.

+ +
--index-url, -i

The URL of the Python package index (by default: <https://pypi.org/simple>).

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

The index given by this flag is given lower priority than all other indexes specified via the --extra-index-url flag.

+ +
--extra-index-url

Extra URLs of package indexes to use, in addition to --index-url.

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

+ +
--find-links, -f

Locations to search for candidate distributions, in addition to those found in the registry indexes.

+ +

If a path, the target must be a directory that contains packages as wheel files (.whl) or source distributions (.tar.gz or .zip) at the top level.

+ +

If a URL, the page must contain a flat list of links to package files adhering to the formats described above.

+ +
--reinstall-package

Reinstall a specific package, regardless of whether it’s already installed. Implies --refresh-package

+ +
--index-strategy

The strategy to use when resolving against multiple index URLs.

+ +

By default, uv will stop at the first index on which a given package is available, and limit resolutions to those present on that first index (first-match). This prevents "dependency confusion" attacks, whereby an attack can upload a malicious package under the same name to a secondary.

+ +
--keyring-provider

Attempt to use keyring for authentication for index URLs.

+ +

At present, only --keyring-provider subprocess is supported, which configures uv to use the keyring CLI to handle authentication.

+ +

Defaults to disabled.

+ +
--config-setting, -C

Settings to pass to the PEP 517 build backend, specified as KEY=VALUE pairs

+ +
--exclude-newer

Limit candidate packages to those that were uploaded prior to the given date.

+ +

Accepts both RFC 3339 timestamps (e.g., 2006-12-02T02:07:43Z) and UTC dates in the same format (e.g., 2006-12-02).

+ +
--link-mode

The method to use when installing packages from the global cache.

+ +

Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.

+ +
--refresh-package

Refresh cached data for a specific package

+ +
--python, -p

The Python interpreter into which packages should be installed.

+ +

By default, uv installs into the virtual environment in the current working directory or any parent directory. The --python option allows you to specify a different interpreter, which is intended for use in continuous integration (CI) environments or other automated workflows.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +
--target

Install packages into the specified directory, rather than into the virtual or system Python environment. The packages will be installed at the top-level of the directory

+ +
--prefix

Install packages into lib, bin, and other top-level folders under the specified directory, as if a virtual environment were present at that location.

+ +

In general, prefer the use of --python to install into an alternate environment, as scripts and other artifacts installed via --prefix will reference the installing interpreter, rather than any interpreter added to the --prefix directory, rendering them non-portable.

+ +
--no-binary

Don’t install pre-built wheels.

+ +

The given packages will be built and installed from source. The resolver will still use pre-built wheels to extract package metadata, if available.

+ +

Multiple packages may be provided. Disable binaries for all packages with :all:. Clear previously specified packages with :none:.

+ +
--only-binary

Only use pre-built wheels; don’t build source distributions.

+ +

When enabled, resolving will not run code from the given packages. The cached wheels of already-built source distributions will be reused, but operations that require building distributions will exit with an error.

+ +

Multiple packages may be provided. Disable binaries for all packages with :all:. Clear previously specified packages with :none:.

+ +
--python-version

The minimum Python version that should be supported by the requirements (e.g., 3.7 or 3.7.9).

+ +

If a patch version is omitted, the minimum patch version is assumed. For example, 3.7 is mapped to 3.7.0.

+ +
--python-platform

The platform for which requirements should be installed.

+ +

Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aaarch64-apple-darwin.

+ +

WARNING: When specified, uv will select wheels that are compatible with the target platform; as a result, the installed distributions may not be compatible with the current platform. Conversely, any distributions that are built from source may be incompatible with the target platform, as they will be built for the current platform. The --python-platform option is intended for advanced use cases.

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv pip install + +Install packages into an environment + +

Usage

+ +``` +uv pip install [OPTIONS] |--editable > +``` + +

Arguments

+ +
PACKAGE

Install all listed packages

+ +
+ +

Options

+ +
--requirement, -r

Install all packages listed in the given requirements.txt files.

+ +

If a pyproject.toml, setup.py, or setup.cfg file is provided, uv will extract the requirements for the relevant project.

+ +

If - is provided, then requirements will be read from stdin.

+ +
--editable, -e

Install the editable package based on the provided local file path

+ +
--constraint, -c

Constrain versions using the given requirements files.

+ +

Constraints files are requirements.txt-like files that only control the version of a requirement that’s installed. However, including a package in a constraints file will not trigger the installation of that package.

+ +

This is equivalent to pip’s --constraint option.

+ +
--override

Override versions using the given requirements files.

+ +

Overrides files are requirements.txt-like files that force a specific version of a requirement to be installed, regardless of the requirements declared by any constituent package, and regardless of whether this would be considered an invalid resolution.

+ +

While constraints are additive, in that they’re combined with the requirements of the constituent packages, overrides are absolute, in that they completely replace the requirements of the constituent packages.

+ +
--extra

Include optional dependencies from the extra group name; may be provided more than once.

+ +

Only applies to pyproject.toml, setup.py, and setup.cfg sources.

+ +
--index-url, -i

The URL of the Python package index (by default: <https://pypi.org/simple>).

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

The index given by this flag is given lower priority than all other indexes specified via the --extra-index-url flag.

+ +
--extra-index-url

Extra URLs of package indexes to use, in addition to --index-url.

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

+ +
--find-links, -f

Locations to search for candidate distributions, in addition to those found in the registry indexes.

+ +

If a path, the target must be a directory that contains packages as wheel files (.whl) or source distributions (.tar.gz or .zip) at the top level.

+ +

If a URL, the page must contain a flat list of links to package files adhering to the formats described above.

+ +
--upgrade-package, -P

Allow upgrades for a specific package, ignoring pinned versions in any existing output file

+ +
--reinstall-package

Reinstall a specific package, regardless of whether it’s already installed. Implies --refresh-package

+ +
--index-strategy

The strategy to use when resolving against multiple index URLs.

+ +

By default, uv will stop at the first index on which a given package is available, and limit resolutions to those present on that first index (first-match). This prevents "dependency confusion" attacks, whereby an attack can upload a malicious package under the same name to a secondary.

+ +
--keyring-provider

Attempt to use keyring for authentication for index URLs.

+ +

At present, only --keyring-provider subprocess is supported, which configures uv to use the keyring CLI to handle authentication.

+ +

Defaults to disabled.

+ +
--resolution

The strategy to use when selecting between the different compatible versions for a given package requirement.

+ +

By default, uv will use the latest compatible version of each package (highest).

+ +
--prerelease

The strategy to use when considering pre-release versions.

+ +

By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers (if-necessary-or-explicit).

+ +
--config-setting, -C

Settings to pass to the PEP 517 build backend, specified as KEY=VALUE pairs

+ +
--exclude-newer

Limit candidate packages to those that were uploaded prior to the given date.

+ +

Accepts both RFC 3339 timestamps (e.g., 2006-12-02T02:07:43Z) and UTC dates in the same format (e.g., 2006-12-02).

+ +
--link-mode

The method to use when installing packages from the global cache.

+ +

Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.

+ +
--refresh-package

Refresh cached data for a specific package

+ +
--python, -p

The Python interpreter into which packages should be installed.

+ +

By default, uv installs into the virtual environment in the current working directory or any parent directory. The --python option allows you to specify a different interpreter, which is intended for use in continuous integration (CI) environments or other automated workflows.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +
--target

Install packages into the specified directory, rather than into the virtual or system Python environment. The packages will be installed at the top-level of the directory

+ +
--prefix

Install packages into lib, bin, and other top-level folders under the specified directory, as if a virtual environment were present at that location.

+ +

In general, prefer the use of --python to install into an alternate environment, as scripts and other artifacts installed via --prefix will reference the installing interpreter, rather than any interpreter added to the --prefix directory, rendering them non-portable.

+ +
--no-binary

Don’t install pre-built wheels.

+ +

The given packages will be built and installed from source. The resolver will still use pre-built wheels to extract package metadata, if available.

+ +

Multiple packages may be provided. Disable binaries for all packages with :all:. Clear previously specified packages with :none:.

+ +
--only-binary

Only use pre-built wheels; don’t build source distributions.

+ +

When enabled, resolving will not run code from the given packages. The cached wheels of already-built source distributions will be reused, but operations that require building distributions will exit with an error.

+ +

Multiple packages may be provided. Disable binaries for all packages with :all:. Clear previously specified packages with :none:.

+ +
--python-version

The minimum Python version that should be supported by the requirements (e.g., 3.7 or 3.7.9).

+ +

If a patch version is omitted, the minimum patch version is assumed. For example, 3.7 is mapped to 3.7.0.

+ +
--python-platform

The platform for which requirements should be installed.

+ +

Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aaarch64-apple-darwin.

+ +

WARNING: When specified, uv will select wheels that are compatible with the target platform; as a result, the installed distributions may not be compatible with the current platform. Conversely, any distributions that are built from source may be incompatible with the target platform, as they will be built for the current platform. The --python-platform option is intended for advanced use cases.

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv pip uninstall + +Uninstall packages from an environment + +

Usage

+ +``` +uv pip uninstall [OPTIONS] > +``` + +

Arguments

+ +
PACKAGE

Uninstall all listed packages

+ +
+ +

Options

+ +
--requirement, -r

Uninstall all packages listed in the given requirements files

+ +
--python, -p

The Python interpreter from which packages should be uninstalled.

+ +

By default, uv uninstalls from the virtual environment in the current working directory or any parent directory. The --python option allows you to specify a different interpreter, which is intended for use in continuous integration (CI) environments or other automated workflows.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +
--keyring-provider

Attempt to use keyring for authentication for remote requirements files.

+ +

At present, only --keyring-provider subprocess is supported, which configures uv to use the keyring CLI to handle authentication.

+ +

Defaults to disabled.

+ +
--target

Uninstall packages from the specified --target directory

+ +
--prefix

Uninstall packages from the specified --prefix directory

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv pip freeze + +List, in requirements format, packages installed in an environment + +

Usage

+ +``` +uv pip freeze [OPTIONS] +``` + +

Options

+ +
--python, -p

The Python interpreter for which packages should be listed.

+ +

By default, uv lists packages in the currently activated virtual environment, or a virtual environment (.venv) located in the current working directory or any parent directory, falling back to the system Python if no virtual environment is found.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv pip list + +List, in tabular format, packages installed in an environment + +

Usage

+ +``` +uv pip list [OPTIONS] +``` + +

Options

+ +
--exclude

Exclude the specified package(s) from the output

+ +
--format

Select the output format between: columns (default), freeze, or json

+ +
--python, -p

The Python interpreter for which packages should be listed.

+ +

By default, uv lists packages in the currently activated virtual environment, or a virtual environment (.venv) located in the current working directory or any parent directory, falling back to the system Python if no virtual environment is found.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv pip show + +Show information about one or more installed packages + +

Usage

+ +``` +uv pip show [OPTIONS] [PACKAGE]... +``` + +

Arguments

+ +
PACKAGE

The package(s) to display

+ +
+ +

Options

+ +
--python, -p

The Python interpreter for which packages should be listed.

+ +

By default, uv lists packages in the currently activated virtual environment, or a virtual environment (.venv) located in the current working directory or any parent directory, falling back to the system Python if no virtual environment is found.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv pip tree + +Display the dependency tree for an environment + +

Usage

+ +``` +uv pip tree [OPTIONS] +``` + +

Options

+ +
--depth, -d

Maximum display depth of the dependency tree

+ +
--prune

Prune the given package from the display of the dependency tree

+ +
--package

Display only the specified packages

+ +
--python, -p

The Python interpreter for which packages should be listed.

+ +

By default, uv lists packages in the currently activated virtual environment, or a virtual environment (.venv) located in the current working directory or any parent directory, falling back to the system Python if no virtual environment is found.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv pip check + +Verify installed packages have compatible dependencies + +

Usage

+ +``` +uv pip check [OPTIONS] +``` + +

Options

+ +
--python, -p

The Python interpreter for which packages should be listed.

+ +

By default, uv lists packages in the currently activated virtual environment, or a virtual environment (.venv) located in the current working directory or any parent directory, falling back to the system Python if no virtual environment is found.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +## uv tool + +Run and manage executable Python packages + +

Usage

+ +``` +uv tool [OPTIONS] +``` + +

Commands

+ +
uv tool run

Run a tool

+
+
uv tool install

Install a tool

+
+
uv tool list

List installed tools

+
+
uv tool uninstall

Uninstall a tool

+
+
uv tool update-shell

Ensure that the tool executable directory is on PATH

+
+
uv tool dir

Show the tools directory

+
+
+ +### uv tool run + +Run a tool + +

Usage

+ +``` +uv tool run [OPTIONS] [COMMAND] +``` + +

Options

+ +
--from

Use the given package to provide the command.

+ +

By default, the package name is assumed to match the command name.

+ +
--with

Run with the given packages installed

+ +
--with-requirements

Run with all packages listed in the given requirements.txt files

+ +
--index-url, -i

The URL of the Python package index (by default: <https://pypi.org/simple>).

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

The index given by this flag is given lower priority than all other indexes specified via the --extra-index-url flag.

+ +
--extra-index-url

Extra URLs of package indexes to use, in addition to --index-url.

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

+ +
--find-links, -f

Locations to search for candidate distributions, in addition to those found in the registry indexes.

+ +

If a path, the target must be a directory that contains packages as wheel files (.whl) or source distributions (.tar.gz or .zip) at the top level.

+ +

If a URL, the page must contain a flat list of links to package files adhering to the formats described above.

+ +
--upgrade-package, -P

Allow upgrades for a specific package, ignoring pinned versions in any existing output file

+ +
--reinstall-package

Reinstall a specific package, regardless of whether it’s already installed. Implies --refresh-package

+ +
--index-strategy

The strategy to use when resolving against multiple index URLs.

+ +

By default, uv will stop at the first index on which a given package is available, and limit resolutions to those present on that first index (first-match). This prevents "dependency confusion" attacks, whereby an attack can upload a malicious package under the same name to a secondary.

+ +
--keyring-provider

Attempt to use keyring for authentication for index URLs.

+ +

At present, only --keyring-provider subprocess is supported, which configures uv to use the keyring CLI to handle authentication.

+ +

Defaults to disabled.

+ +
--resolution

The strategy to use when selecting between the different compatible versions for a given package requirement.

+ +

By default, uv will use the latest compatible version of each package (highest).

+ +
--prerelease

The strategy to use when considering pre-release versions.

+ +

By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers (if-necessary-or-explicit).

+ +
--config-setting, -C

Settings to pass to the PEP 517 build backend, specified as KEY=VALUE pairs

+ +
--exclude-newer

Limit candidate packages to those that were uploaded prior to the given date.

+ +

Accepts both RFC 3339 timestamps (e.g., 2006-12-02T02:07:43Z) and UTC dates in the same format (e.g., 2006-12-02).

+ +
--link-mode

The method to use when installing packages from the global cache.

+ +

Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.

+ +
--no-build-package

Don’t build source distributions for a specific package

+ +
--no-binary-package

Don’t install pre-built wheels for a specific package

+ +
--refresh-package

Refresh cached data for a specific package

+ +
--python, -p

The Python interpreter to use to build the run environment.

+ +

By default, uv uses the virtual environment in the current working directory or any parent directory, falling back to searching for a Python executable in PATH. The --python option allows you to specify a different interpreter.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv tool install + +Install a tool + +

Usage

+ +``` +uv tool install [OPTIONS] +``` + +

Arguments

+ +
PACKAGE

The package to install commands from

+ +
+ +

Options

+ +
--with

Include the following extra requirements

+ +
--with-requirements

Run all requirements listed in the given requirements.txt files

+ +
--index-url, -i

The URL of the Python package index (by default: <https://pypi.org/simple>).

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

The index given by this flag is given lower priority than all other indexes specified via the --extra-index-url flag.

+ +
--extra-index-url

Extra URLs of package indexes to use, in addition to --index-url.

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

+ +
--find-links, -f

Locations to search for candidate distributions, in addition to those found in the registry indexes.

+ +

If a path, the target must be a directory that contains packages as wheel files (.whl) or source distributions (.tar.gz or .zip) at the top level.

+ +

If a URL, the page must contain a flat list of links to package files adhering to the formats described above.

+ +
--upgrade-package, -P

Allow upgrades for a specific package, ignoring pinned versions in any existing output file

+ +
--reinstall-package

Reinstall a specific package, regardless of whether it’s already installed. Implies --refresh-package

+ +
--index-strategy

The strategy to use when resolving against multiple index URLs.

+ +

By default, uv will stop at the first index on which a given package is available, and limit resolutions to those present on that first index (first-match). This prevents "dependency confusion" attacks, whereby an attack can upload a malicious package under the same name to a secondary.

+ +
--keyring-provider

Attempt to use keyring for authentication for index URLs.

+ +

At present, only --keyring-provider subprocess is supported, which configures uv to use the keyring CLI to handle authentication.

+ +

Defaults to disabled.

+ +
--resolution

The strategy to use when selecting between the different compatible versions for a given package requirement.

+ +

By default, uv will use the latest compatible version of each package (highest).

+ +
--prerelease

The strategy to use when considering pre-release versions.

+ +

By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers (if-necessary-or-explicit).

+ +
--config-setting, -C

Settings to pass to the PEP 517 build backend, specified as KEY=VALUE pairs

+ +
--exclude-newer

Limit candidate packages to those that were uploaded prior to the given date.

+ +

Accepts both RFC 3339 timestamps (e.g., 2006-12-02T02:07:43Z) and UTC dates in the same format (e.g., 2006-12-02).

+ +
--link-mode

The method to use when installing packages from the global cache.

+ +

Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.

+ +
--no-build-package

Don’t build source distributions for a specific package

+ +
--no-binary-package

Don’t install pre-built wheels for a specific package

+ +
--refresh-package

Refresh cached data for a specific package

+ +
--python, -p

The Python interpreter to use to build the tool environment.

+ +

By default, uv will search for a Python executable in the PATH. uv ignores virtual environments while looking for interpreter for tools. The --python option allows you to specify a different interpreter.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv tool list + +List installed tools + +

Usage

+ +``` +uv tool list [OPTIONS] +``` + +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv tool uninstall + +Uninstall a tool + +

Usage

+ +``` +uv tool uninstall [OPTIONS] +``` + +

Arguments

+ +
NAME

The name of the tool to uninstall

+ +
+ +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv tool update-shell + +Ensure that the tool executable directory is on `PATH` + +

Usage

+ +``` +uv tool update-shell [OPTIONS] +``` + +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv tool dir + +Show the tools directory + +

Usage

+ +``` +uv tool dir [OPTIONS] +``` + +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +## uv python + +Manage Python installations + +

Usage

+ +``` +uv python [OPTIONS] +``` + +

Commands

+ +
uv python list

List the available Python installations

+
+
uv python install

Download and install Python versions

+
+
uv python find

Search for a Python installation

+
+
uv python pin

Pin to a specific Python version

+
+
uv python dir

Show the uv Python installation directory

+
+
uv python uninstall

Uninstall Python versions

+
+
+ +### uv python list + +List the available Python installations + +

Usage

+ +``` +uv python list [OPTIONS] +``` + +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv python install + +Download and install Python versions + +

Usage

+ +``` +uv python install [OPTIONS] [TARGETS]... +``` + +

Arguments

+ +
TARGETS

The Python version(s) to install.

+ +

If not provided, the requested Python version(s) will be read from the .python-versions or .python-version files. If neither file is present, uv will check if it has installed any Python versions. If not, it will install the latest stable version of Python.

+ +
+ +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv python find + +Search for a Python installation + +

Usage

+ +``` +uv python find [OPTIONS] [REQUEST] +``` + +

Arguments

+ +
REQUEST

The Python request

+ +
+ +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv python pin + +Pin to a specific Python version + +

Usage

+ +``` +uv python pin [OPTIONS] [REQUEST] +``` + +

Arguments

+ +
REQUEST

The Python version

+ +
+ +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv python dir + +Show the uv Python installation directory + +

Usage

+ +``` +uv python dir [OPTIONS] +``` + +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv python uninstall + +Uninstall Python versions + +

Usage

+ +``` +uv python uninstall [OPTIONS] ... +``` + +

Arguments

+ +
TARGETS

The Python version(s) to uninstall

+ +
+ +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +## uv venv + +Create a virtual environment + +

Usage

+ +``` +uv venv [OPTIONS] [NAME] +``` + +

Arguments

+ +
NAME

The path to the virtual environment to create

+ +
+ +

Options

+ +
--python, -p

The Python interpreter to use for the virtual environment.

+ +

Supported formats:

+ +
    +
  • 3.10 looks for an installed Python 3.10 using py --list-paths on Windows, or python3.10 on Linux and macOS.
  • + +
  • python3.10 or python.exe looks for a binary with the given name in PATH.
  • + +
  • /home/ferris/.local/bin/python3.10 uses the exact Python at the given path.
  • +
+ +

Note that this is different from --python-version in pip compile, which takes 3.10 or 3.10.13 and doesn’t look for a Python interpreter on disk.

+ +
--prompt

Provide an alternative prompt prefix for the virtual environment.

+ +

The default behavior depends on whether the virtual environment path is provided:

+ +
    +
  • If provided (uv venv project), the prompt is set to the virtual environment’s directory name.
  • + +
  • If not provided (uv venv), the prompt is set to the current directory’s name.
  • +
+ +

Possible values:

+ +
    +
  • .: Use the current directory name.
  • + +
  • Any string: Use the given string.
  • +
+ +
--index-url, -i

The URL of the Python package index (by default: <https://pypi.org/simple>).

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

The index given by this flag is given lower priority than all other indexes specified via the --extra-index-url flag.

+ +
--extra-index-url

Extra URLs of package indexes to use, in addition to --index-url.

+ +

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

+ +

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

+ +
--find-links, -f

Locations to search for candidate distributions, in addition to those found in the registry indexes.

+ +

If a path, the target must be a directory that contains packages as wheel files (.whl) or source distributions (.tar.gz or .zip) at the top level.

+ +

If a URL, the page must contain a flat list of links to package files adhering to the formats described above.

+ +
--index-strategy

The strategy to use when resolving against multiple index URLs.

+ +

By default, uv will stop at the first index on which a given package is available, and limit resolutions to those present on that first index (first-match). This prevents "dependency confusion" attacks, whereby an attack can upload a malicious package under the same name to a secondary.

+ +
--keyring-provider

Attempt to use keyring for authentication for index URLs.

+ +

At present, only --keyring-provider subprocess is supported, which configures uv to use the keyring CLI to handle authentication.

+ +

Defaults to disabled.

+ +
--exclude-newer

Limit candidate packages to those that were uploaded prior to the given date.

+ +

Accepts both RFC 3339 timestamps (e.g., 2006-12-02T02:07:43Z) and UTC dates in the same format (e.g., 2006-12-02).

+ +
--link-mode

The method to use when installing packages from the global cache.

+ +

This option is only used for installing seed packages.

+ +

Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +## uv cache + +Manage the cache + +

Usage

+ +``` +uv cache [OPTIONS] +``` + +

Commands

+ +
uv cache clean

Clear the cache, removing all entries or those linked to specific packages

+
+
uv cache prune

Prune all unreachable objects from the cache

+
+
uv cache dir

Show the cache directory

+
+
+ +### uv cache clean + +Clear the cache, removing all entries or those linked to specific packages + +

Usage

+ +``` +uv cache clean [OPTIONS] [PACKAGE]... +``` + +

Arguments

+ +
PACKAGE

The packages to remove from the cache

+ +
+ +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv cache prune + +Prune all unreachable objects from the cache + +

Usage

+ +``` +uv cache prune [OPTIONS] +``` + +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +### uv cache dir + +Show the cache directory + +

Usage

+ +``` +uv cache dir [OPTIONS] +``` + +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +## uv version + +Display uv's version + +

Usage

+ +``` +uv version [OPTIONS] +``` + +

Options

+ +
--output-format
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ +## uv help + +Display documentation for a command + +

Usage

+ +``` +uv help [OPTIONS] [COMMAND]... +``` + +

Arguments

+ +
COMMAND
+ +

Options

+ +
--color

Control colors in output

+ +
--python-preference

Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

+ +
--python-fetch

Whether to automatically download Python when required

+ +
--cache-dir

Path to the cache directory.

+ +

Defaults to $HOME/Library/Caches/uv on macOS, $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Linux, and {FOLDERID_LocalAppData}\uv\cache on Windows.

+ +
--config-file

The path to a uv.toml file to use for configuration

+ +
+ diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index 511c36264ecaf..a356052b6ae38 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -147,3 +147,20 @@ See https://github.com/astral-sh/uv/issues/5130 */ .md-nav__link--active { font-weight: bold; } + +/* Styling for the generated CLI reference page */ +.cli-reference dd { + margin-top: 0.1em; + margin-bottom: 0.5em; +} +.cli-reference dd p { + margin-block-start: 0.2em; + margin-block-end: 0.3em; +} +.cli-reference ul { + margin-bottom: 0.1em; +} +h3.cli-reference { + font-size: 1.1em; + margin: 0 0 0 0; +} diff --git a/mkdocs.template.yml b/mkdocs.template.yml index e1cda60140e5a..bc86c47eecbc2 100644 --- a/mkdocs.template.yml +++ b/mkdocs.template.yml @@ -120,6 +120,8 @@ nav: - Declaring dependencies: pip/dependencies.md - Locking environments: pip/compile.md - Compatibility with pip: pip/compatibility.md + - Reference: + - Commands: reference/cli.md - Policies: - Versioning: versioning.md - Platform support: platforms.md