explaingit

pypa/hatch

7,153PythonAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Hatch is the official Python Packaging Authority tool that handles everything from creating a new project to publishing it on PyPI, replacing separate tools for environments, testing, versioning, and building.

Mindmap

mindmap
  root((hatch))
    What it does
      Project scaffolding
      Virtual environments
      Build and publish
    Features
      Version management
      Custom scripts
      UV support
    Audience
      Python developers
      Open source maintainers
    License
      MIT permissive
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Bootstrap a new Python library with correct project structure and a virtual environment in one command.

USE CASE 2

Run the test suite in an isolated environment without manually creating or activating a venv.

USE CASE 3

Build a distributable wheel and publish it to PyPI without installing separate build or upload tools.

USE CASE 4

Automate version bumping across all project files with a single Hatch command.

Tech stack

PythonHatchlingUV

Getting it running

Difficulty · easy Time to first run · 30min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

Hatch is a command-line tool for managing Python projects from start to finish. It is part of the Python Packaging Authority (PyPA), the group responsible for maintaining the official Python packaging ecosystem. Rather than juggling separate tools for creating projects, running tests, building packages, and publishing to PyPI, Hatch covers all of those steps in one place. When starting a new project, Hatch can generate it from a template with standard structure already in place. It manages virtual environments for you, so each project can have its own isolated set of installed packages, and it supports UV for faster package resolution. You can define custom scripts to run common tasks, and Hatch handles test execution with recommended defaults built in. Static analysis is also included, with sensible default settings so you do not need to configure tools from scratch. When a project is ready to distribute, Hatch handles building it into a package and publishing to PyPI or other package indices. Version management is built in as well, so you can update version numbers without editing files manually. Hatch is built around the Hatchling build backend, which is the component that constructs distributable packages. Builds are reproducible by default, meaning two builds from the same source produce identical output. The CLI is reported to be roughly two to three times faster than equivalent tooling in this space. Documentation lives at hatch.pypa.io and covers all features in detail. The project is released under the MIT license.

Copy-paste prompts

Prompt 1
I just started a new Python library project. Walk me through using Hatch to create the project, add a dependency, run the tests, and publish to PyPI.
Prompt 2
My Python project uses Hatch. Show me how to define a custom script in pyproject.toml that runs linting and tests together with one command.
Prompt 3
I want to use Hatch to test my library against both Python 3.10 and 3.12 in separate environments. How do I configure that in pyproject.toml?
Prompt 4
How do I configure Hatch to automatically bump my package version and tag the release when I run a release command?
Open on GitHub → Explain another repo

← pypa on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.