Fundamentals 12 min read

Introducing uv: A High‑Performance Unified Python Packaging Tool

uv is a Rust‑based, ultra‑fast Python package manager and dependency resolver that expands beyond pip to provide end‑to‑end project management, tool installation, workspace support, Python version bootstrapping, single‑file script execution, and a unified interface comparable to Cargo, dramatically simplifying Python development workflows.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Introducing uv: A High‑Performance Unified Python Packaging Tool

uv is a high‑performance Python package manager written in Rust, designed as a drop‑in replacement for pip and as a comprehensive solution for managing Python projects, command‑line tools, single‑file scripts, and even the Python interpreter itself.

Key new capabilities include:

End‑to‑end project management: uv run , uv lock and uv sync create cross‑platform lock files and replace tools like Poetry, PDM, and Rye.

Tool management: uv tool install (alias uvx ) installs CLI tools in isolated environments and can execute them without prior installation, offering a fast alternative to pipx.

Python installation: uv python install can fetch and install specific Python versions, removing the need for external managers such as pyenv.

Workspace support: Inspired by Cargo, uv can manage a collection of packages in a single workspace, sharing a common lock file while each package retains its own pyproject.toml .

Dependency sources: uv extends PEP 621 with tool.uv.sources to declare editable or path‑based dependencies, enabling local development without changing project metadata.

Single‑file script execution: Scripts can embed dependency metadata (PEP‑723) and be run directly with uv run or uvx , automatically creating a temporary virtual environment.

Installation is straightforward via the official installer:

<code>curl -LsSf https://astral.sh/uv/install.sh | sh</code>

On Windows, use PowerShell:

<code>powershell -c "irm https://astral.sh/uv/install.ps1 | iex"</code>

uv can also be installed from PyPI:

<code>pip install uv</code>

Example project initialization:

<code>uv init && uv add "fastapi>=0.112"</code>

This generates a pyproject.toml with the specified dependencies and allows uv lock to produce a lock file that works across macOS, Linux, and Windows.

For workspace configuration, a root pyproject.toml may contain:

<code>[project]
name = "fastapi"
version = "0.1.0"
dependencies = ["uvicorn"]

[tool.uv.sources]
uvicorn = { workspace = true }

[tool.uv.workspace]
members = ["libraries/*"]
</code>

Running a package within the workspace is as simple as:

<code>uv run --package fastapi</code>

uv’s tool API also provides commands to list and upgrade installed tools:

<code>uv tool list
uv tool upgrade --all</code>

Single‑file script example (main.py) with embedded dependencies:

<code># /// script
# requires-python = ">=3.12"
# dependencies = ["requests<3", "rich"]
# ///
import requests
from rich.pretty import pprint
resp = requests.get("https://peps.python.org/api/peps.json")
data = resp.json()
for k, v in list(data.items())[:10]:
    pprint((k, v["title"]))
</code>

Running the script with uv run main.py automatically resolves and installs the declared dependencies in an isolated environment.

Overall, uv offers a fast, reliable, and unified workflow for Python development, from simple scripts to large multi‑package workspaces, while remaining cross‑platform and self‑contained.

RusttoolingPackage ManagementuvDependency Resolution
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.