Hatch
Hatch is a project manager for Python that centralizes environment management, packaging with Hatchling, testing, static analysis, versioning, and publishing behind a single command-line interface.
Installation and Setup
Install it from the Python Package Index (PyPI):
$ pipx install hatch
Check the documentation for other installation options.
Key Features
- Manages isolated environments and runs commands inside them with
hatch runandhatch shell. - Builds wheels and sdists via Hatchling, a PEP 517 compliant backend that reads PEP 621 metadata from
[project]. - Supports environment matrices and per-environment dependencies for testing across multiple Python versions.
- Locks dependencies into a PEP 751
pylock.tomlwithhatch dep lock. - Manages multiple interdependent packages in one environment through workspaces.
- Provides version management via
hatch version, including segment bumps like minor, and supports configurable version sources. - Publishes built artifacts to package indexes using
hatch publish. - Runs tests across the
hatch-testenvironment matrix withhatch test, and checks linting, formatting, and types withhatch check. - Installs and manages Python distributions with
hatch python, and downloads a missing version automatically when an environment requests it.
Usage
A minimal pyproject.toml that builds with Hatchling looks like this:
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
# ...
Create a new project:
$ hatch new project_name
Create an environment and install declared dependencies:
$ cd project_name/
$ hatch env create
Build the project:
$ hatch build
Publish the project to an index:
$ hatch publish
Run commands inside a managed environment:
$ hatch run python -V
$ hatch run pytest -q
$ hatch shell
Related Resources
Course
Everyday Project Packaging With pyproject.toml
In this Code Conversation video course, you'll learn how to package your everyday projects with pyproject.toml. Playing on the same team as the import system means you can call your project from anywhere, ensure consistent imports, and have one file that'll work for many build systems.
For additional information on related topics, take a look at the following resources:
- How to Publish an Open-Source Python Package to PyPI (Tutorial)
- How to Manage Python Projects With pyproject.toml (Tutorial)
- How to Publish Your Own Python Package to PyPI (Course)
- Publishing Python Packages to PyPI (Course)
- How to Publish an Open-Source Python Package to PyPI (Quiz)
- How to Manage Python Projects With pyproject.toml (Quiz)
By Leodanis Pozo Ramos • Updated Sept. 13, 2026