Skip to content

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):

Language: Shell
$ pipx install hatch

Check the documentation for other installation options.

Key Features

  • Manages isolated environments and runs commands inside them with hatch run and hatch 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.toml with hatch 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-test environment matrix with hatch test, and checks linting, formatting, and types with hatch 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:

Language: TOML
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

# ...

Create a new project:

Language: Shell
$ hatch new project_name

Create an environment and install declared dependencies:

Language: Shell
$ cd project_name/
$ hatch env create

Build the project:

Language: Shell
$ hatch build

Publish the project to an index:

Language: Shell
$ hatch publish

Run commands inside a managed environment:

Language: Shell
$ hatch run python -V
$ hatch run pytest -q
$ hatch shell
Everyday Project Packaging With pyproject.toml

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.

intermediate best-practices tools

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated Sept. 13, 2026