How astral-sh/uv works
uv is a Rust-based Python package and project manager. The principal workflow starts at its CLI, resolves project or requirements inputs, obtains package metadata and distributions, then installs them into a managed environment; projects can also persist resolutions in a universal lockfile. Separate command branches support pip compatibility, scripts and tools, Python-version management, building/publishing, and auditing. The graph follows documented capabilities and crate responsibilities; sampled implementation excerpts are limited, so uncertain internal call wiring is omitted.
Main entry points: uv.rs uv CLI · mod.rs Project commands · lib.rs Dependency resolver · registry_client.rs Registry client
Components 20
CLI and projects
- uv CLI
crates/uv/src/bin/uv.rs - Project commands
crates/uv/src/commands/project/mod.rs - Project sync
crates/uv/src/commands/project/sync.rs - pip commands
crates/uv/src/commands/pip/mod.rs - Lockfile
crates/uv-lock/src/lib.rs - Workspace
crates/uv-workspace/src/lib.rs
Resolution and artifacts
- Dependency resolver
crates/uv-resolver/src/lib.rs - Distribution database
crates/uv-distribution/src/distribution_database.rs - Package installer
crates/uv-installer/src/lib.rs
Environments and tools
- Virtual environments
crates/uv-virtualenv/src/lib.rs - Script execution
crates/uv/src/commands/project/run.rs - Tool management
crates/uv/src/commands/tool/mod.rs - Python management
crates/uv/src/commands/python/mod.rs - Build backend
crates/uv-build-backend/src/lib.rs - Publish command
crates/uv/src/commands/publish.rs - Dependency audit
crates/uv/src/commands/project/audit.rs
Package services
- Registry client
crates/uv-client/src/registry_client.rs - Global cache
crates/uv-cache/src/lib.rs
Other components
- User
- Python package index
Connections 25
- User → uv CLI: invokes
- uv CLI → Project commands: dispatches
- uv CLI → pip commands: dispatches
- uv CLI → Tool management: dispatches
- uv CLI → Python management: dispatches
- Project commands → Workspace: reads project
- Project commands → Project sync: syncs project
- Project sync → Dependency resolver: resolves dependencies
- Project sync → Package installer: installs packages
- Project commands → Lockfile: writes lockfile
- pip commands → Dependency resolver: resolves requirements
- pip commands → Package installer: installs packages
- Dependency resolver → Registry client: requests metadata
- Registry client → Python package index: fetches index data
- Distribution database → Registry client: fetches metadata
- Distribution database → Python package index: downloads distributions
- Distribution database → Global cache: caches artifacts
- Package installer → Virtual environments: installs into
- Script execution → Virtual environments: runs in
- Tool management → Dependency resolver: resolves tool
- Tool management → Virtual environments: manages tool environment
- Python management → Virtual environments: selects interpreter
- Publish command → Build backend: builds artifacts
- Publish command → Python package index: publishes packages
- Dependency audit → Registry client: checks package status