LinuxCommandLibrary

hatch

Manage isolated Python projects

TLDR

Create a new Hatch project

$ hatch new [project_name]
copy

Initialize Hatch for an existing project
$ hatch new --init
copy

Build a Hatch project
$ hatch build
copy

Remove build artifacts
$ hatch clean
copy

Create a default environment with dependencies defined in the pyproject.toml file
$ hatch env create
copy

Show environment dependencies as a table
$ hatch dep show table
copy

SYNOPSIS

hatch [OPTIONS] COMMAND [ARGS]...

PARAMETERS

--help, -h
    Show help message and exit

--verbosity TEXT, -v TEXT
    Increase verbosity (0=error,1=warning,2=info,3=debug)

--color / --no-color
    Force colorful/silent output

--docs
    Open documentation in browser

--storage DIR
    Override data storage directory

--project PATH
    Select project at given path

--project-root PATH
    Select project root directory

--config FILE
    Load configuration from file

--version
    Show Hatch version

DESCRIPTION

Hatch is a modern, plugin-extensible command-line tool for Python project management. It simplifies building, testing, publishing, and environment management using standards like pyproject.toml. Unlike legacy tools, Hatch automates virtual environments per matrix (e.g., Python versions, OS), handles dependencies seamlessly, and supports reproducible builds. Developers use it for creating new projects with hatch new, building wheels/sdists via hatch build, running scripts in isolated envs with hatch run, and more. Its plugin system allows customization for tasks like linting or deployment. Ideal for packaging, it integrates with PyPI and Git, reducing boilerplate and errors in workflows.

CAVEATS

Not a core Linux utility; requires Python 3.8+ and installation via pip install hatch. Subcommands have additional options; use hatch <command> --help for details. Environments stored in ~/.local/share/hatch by default.

MAIN SUBCOMMANDS

new: Create new project.
build: Build distributions.
env: Manage environments.
run: Execute in environment.
publish: Upload to PyPI.

INSTALLATION

Recommended: pipx install hatch or pip install hatch. Supports Windows/macOS/Linux.

HISTORY

Developed by Ofek Lev starting in 2020 under Python Packaging Authority influence. Reached 1.0 in 2023, emphasizing PEP 517/518/621 compliance. Evolved from frustration with fragmented tools like pipenv and flit.

SEE ALSO

poetry(1), pip(1), virtualenv(1), setuptools(1)

Copied to clipboard