62. uv for Package Management
Date: 2025-11-29Status
AcceptedCategory
Development & ToolingContext
Python package management has historically been fragmented across multiple tools:- pip: Standard but slow, no lockfile by default
- poetry: Popular but slow dependency resolution, complex pyproject.toml
- pipenv: Deprecated in favor of poetry, slow
- conda: Heavy, primarily for data science
- Fast installation: CI/CD pipelines run frequently
- Reproducible builds: Lockfile for exact dependency versions
- Virtual environment management: Isolated environments per project
- pyproject.toml support: Modern Python packaging standard
- Cross-platform: Works on Linux, macOS, Windows
Performance Comparison (cold cache, ~150 dependencies)
| Tool | Install Time | Resolution Time |
|---|---|---|
| pip | ~45s | N/A |
| poetry | ~120s | ~60s |
| uv | ~3s | ~1s |
Decision
Use uv (by Astral) as the primary package manager for dependency installation and virtual environment management.Key Reasons
- Speed: 10-100x faster than pip/poetry (written in Rust)
- Drop-in Replacement: Compatible with pip commands and requirements.txt
- Lockfile Support:
uv.lockfor reproducible builds - pyproject.toml: Native support for modern Python packaging
- Virtual Environments: Built-in venv creation and management
- Active Development: Maintained by Astral (creators of ruff)
Usage Patterns
CI/CD Integration
Consequences
Positive
- CI Speed: Dependency installation reduced from ~2min to ~10s
- Developer Experience: Fast feedback loops during development
- Reproducibility:
uv.lockensures identical environments - Compatibility: Works with existing pip/requirements.txt workflows
- Memory Efficient: Low memory footprint during resolution
Negative
- New Tool: Team must learn uv-specific commands
- Early Stage: Less mature than poetry (but rapidly improving)
- Rust Dependency: Requires Rust toolchain for some edge cases
Alternatives Considered
pip + pip-tools
- Rejected: Slow installation, no built-in venv management
- Requires manual lockfile generation with pip-compile
poetry
- Rejected: Slow dependency resolution (minutes vs seconds)
- Complex pyproject.toml format with poetry-specific sections
- Memory-intensive for large dependency trees
pipenv
- Rejected: Deprecated in favor of poetry
- Slow, inconsistent behavior across platforms
pdm
- Considered: Fast, PEP 582 support
- Rejected: Smaller community, less CI/CD integration
Migration from Poetry
References
- Configuration:
pyproject.toml,uv.lock - CI Integration:
.github/workflows/ci.yaml - External: uv Documentation
- Related: Astral (creators of uv and ruff)