UV as Python Package Manager
Python projects are highly dependent on external packages from registries like PyPI.
Context
Python projects are highly dependent on external packages from registries like PyPI. The traditional Python ecosystem for managing dependencies and virtual environments is fragmented, with many competing tools and workflows (e.g., pip + venv, poetry, pipenv). This lack of a single standard leads to inconsistent project structures and setup procedures, different incompatible lockfile formats (poetry.lock, Pipfile.lock, requirements.txt), and slow dependency resolution and installation times.
To ensure consistency, high performance, and reproducible builds for Python projects, a single modern tool must be standardized.
Decision
UV (from Astral, the creators of Ruff) is the mandatory package and environment manager for all Python projects. It replaces pip, pipenv, poetry, and conda.
- Use
uv venvto create virtual environments. - Use
uv add [package]oruv remove [package]to manage dependencies. These commands automatically updatepyproject.tomland regenerateuv.lock. - Use
uv syncto install all dependencies from the lockfile. - The
uv.lockfile must be committed to version control. - All Python packages use
pyproject.tomlwith UV-compatible configuration. - The
uv pipcommands are explicitly forbidden in favor of theadd/remove/syncworkflow.
Do's and Don'ts
Do
- Use
uv venvto create virtual environments. - Use
uv addanduv removefor dependency management. - Use
uv syncto install dependencies from the lockfile. - Commit
uv.lockandpyproject.tomlto version control. - Use
pyproject.tomlfor all project configuration.
Don't
- Use
pip,python -m venv,poetry,pipenv,pip-tools, orconda. - Use
uv pip installoruv pip uninstall. - Use
requirements.txtfiles for locking dependencies. - Manually edit the
uv.lockfile. - Commit the virtual environment directory (e.g.,
.venv). - Use
setup.pyorsetup.cfgfor project configuration.
Consequences
Positive
- Extreme performance with drastically reduced time for dependency resolution and installation.
- Unified tool replacing a combination of
pip,venv,pip-tools, andpoetry. - Familiar
add/remove/syncworkflow for developers coming from npm, yarn, or bun. - Clean, reproducible dependency management with
pyproject.toml+uv.lock.
Negative
- UV is a relatively new tool; commands and lockfile format may still evolve.
- Adoption friction for developers accustomed to pip, poetry, or conda workflows.
- IDE integration is still maturing for automatic dependency detection.