LinuxCommandLibrary

uv

Upgrade Python dependencies using the uv resolver

TLDR

Create a new Python project in the current directory

$ uv init
copy

Create a new Python project at the specified path
$ uv init [path/to/directory]
copy

Add a new dependency to the project
$ uv add [package]
copy

Remove a dependency from the project
$ uv remove [package]
copy

Run a script in the project's environment
$ uv run [path/to/script.py]
copy

Run a command in the project's environment
$ uv run [command]
copy

Update a project's environment from pyproject.toml
$ uv sync
copy

Create a lock file for the project's dependencies
$ uv lock
copy

SYNOPSIS

uv [OPTIONS] <COMMAND> [ARGS]...

Common commands:
  uv pip install <PACKAGE>...
  uv venv [PATH]
  uv pip compile [REQUIREMENTS_IN]...
  uv pip sync [REQUIREMENTS_TXT]...

PARAMETERS

--help
    Prints help information for the command or subcommand.

--version
    Prints version information for uv.

--color
    Controls when to use colors in output. Options include 'auto', 'always', 'never'.

--python
    Specify the Python interpreter to use. Can be a version (e.g., '3.10'), an executable path, or a name.

--quiet
    Suppresses informational messages, only showing errors or warnings.

--verbose
    Enables verbose output for more detailed information during execution.

DESCRIPTION

uv is a modern, high-performance Python package installer and resolver, designed as a direct replacement for pip and pip-tools. Written in Rust, it aims to provide significantly faster and more reliable dependency resolution and package installation, addressing long-standing performance issues in the Python ecosystem.

It functions as a single, compiled binary and offers familiar commands for installing packages, managing virtual environments, and synchronizing project dependencies. uv supports a wide range of features including installing from PyPI, local paths, and Git repositories, handling editable installs, and managing a pyproject.toml based dependency graph. Its core strength lies in its ability to quickly resolve complex dependency trees and perform operations like pip install, pip compile, and pip sync with exceptional speed and correctness.

CAVEATS

uv is not a standard Linux command-line utility distributed with most base systems. It is a third-party tool primarily used for Python package management. While highly compatible with pip, it is a relatively new project and is under active development, meaning features and behaviors might evolve rapidly. It requires a Python installation to function effectively, as its purpose is to manage Python environments and packages. Some very niche pip functionalities might not be fully replicated yet.

INSTALLATION

uv can be installed using various methods, often via a simple shell script provided by Astral, or through package managers like Homebrew on macOS. Example installation:
curl -LsSf https://astral.sh/uv/install.sh | sh
It can also be installed into an existing Python environment: pip install uv.

KEY FEATURES

Speed: Dramatically faster package installation and dependency resolution compared to pip and pip-tools.
Reliability: Robust dependency resolution engine built from the ground up.
Single Binary: All functionalities are bundled into a single executable.
pip Compatibility: Designed to be a drop-in replacement for many pip and pip-tools commands, understanding common requirements formats.
Virtual Environment Management: Integrated support for creating and managing Python virtual environments.

HISTORY

uv was developed by Astral, the company behind the popular Rust-based linter and formatter Ruff. It was publicly launched in late 2023/early 2024, quickly gaining significant attention within the Python community due to its unprecedented speed and reliability in handling package installations and dependency resolution. It leverages Rust's performance capabilities to deliver a dramatically faster alternative to existing Python packaging tools, aiming to solve long-standing 'dependency hell' and slow installation issues.

SEE ALSO

pip(1), venv(1), pip-tools, rye, pdm, conda(1)

Copied to clipboard