The intro predated the audit and never mentioned poetry-core, which the README now lists. Co-Authored-By: Claude <noreply@anthropic.com>
4.6 KiB
uv manages your project with a lockfile, and doubles as a Python package manager. Its uv-build backend packages pure-Python code with reasonable defaults.
How to choose:
- A new project, from installing Python to locking dependencies: uv
- Packaging pure-Python code in a uv project: uv-build
- Installing packages with only what ships with Python: pip
- A project already on Poetry, or one that relies on its plugins: Poetry
- Tests across a matrix of Python versions: Hatch
- Command-line apps, each in its own environment: pipx, or
uv toolon uv - Scientific stacks with non-Python libraries: conda
- C or C++ extension modules: setuptools
- Build hooks, or a layout uv-build doesn't expect: Hatchling
- Building a Poetry project without Poetry installed: poetry-core
uv is a single tool for Python versions, virtual environments, dependencies, and command-line tools. Start a project with uv init, add packages with uv add, and run code with uv run, which checks that the lockfile and environment are up to date before every run. The uv pip commands are for projects not ready to move away from pip, not the main interface.
uv-build is uv's own build backend, and uv init sets it up with your code in src/<project_name>/. When you need build scripts or a more flexible layout, uv's docs suggest Hatchling instead.
pip installs packages from PyPI and other indexes. It comes with Python, but managing environments, the interpreter, and the project as a whole is outside its scope. Run it as python -m pip, so you know which Python gets the package.
Poetry manages your dependencies and builds your package, with a lockfile for repeatable installs. For a project you won't publish, turn off package mode and use Poetry for dependencies only. Its build backend, poetry-core, lets pip build and install your project without Poetry.
Hatch manages environments, builds, and Python installs for your project. hatch run test:pytest runs pytest in a test environment without activating it, and creates that environment on first use. A matrix repeats an environment across Python versions.
Hatchling is Hatch's build backend, developed with Hatch but separate from it. It takes the files to ship from your .gitignore and builds reproducible wheels and sdists by default.
pipx installs command-line apps each in its own virtual environment, so their dependencies never collide, and puts their commands on your PATH. To try an app once, pipx run runs it in a temporary environment. uv tool does the same job on uv, and pipx's docs say running both is fine.
conda manages packages and environments for any language, and its packages can hold system libraries and programs, not only Python modules. Keep your requirements in a file, and use pip only after conda has installed everything it can.
setuptools builds C and C++ extension modules, and Hatch's docs recommend it for them. Keep its configuration in pyproject.toml and setup.py minimal, if you need one at all, and don't run setup.py as a script.
Whichever tool writes your lockfile, commit it to version control, as uv and Poetry both recommend, so every machine installs the same versions.