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

--version
    Displays the installed Hatch version and exits.

--help
    Shows the general help message for Hatch, or for a specific command (e.g., hatch new --help).

COMMAND
    The specific subcommand to execute, dictating the action Hatch will perform (e.g., new, env, run, build, publish). Each command has its own set of options and arguments.

[ARGS]...
    Additional arguments specific to the chosen COMMAND, which can include paths, names, or other options.

DESCRIPTION

Hatch is a comprehensive, modern, and extensible command-line interface (CLI) tool designed for managing Python projects. Unlike traditional system commands, it's primarily a Python application installed via `pip`. It provides a unified workflow for various aspects of the Python development lifecycle, including project creation, dependency management, virtual environment handling, executing custom scripts, building distributions, and publishing packages. Hatch emphasizes configuration through `pyproject.toml`, aligning with modern Python packaging standards, and offers a robust plugin system for custom workflows and integrations. It aims to streamline the development and deployment of Python applications and libraries.

CAVEATS

Hatch is a Python-based tool and requires a Python installation (typically 3.8+) along with `pip` to be available on the system. It manages Python project-specific concerns, so it's not a general-purpose Linux system utility like file or process management commands. Its functionality is entirely tied to the Python ecosystem and project structure conventions.

PROJECT CONFIGURATION

Hatch centralizes project configuration within the standard `pyproject.toml` file. This single source of truth defines project metadata, dependencies, custom scripts, and environment settings, simplifying project setup and ensuring consistency across development teams.

ENVIRONMENT MANAGEMENT

Hatch provides powerful and flexible virtual environment management. It allows developers to define and activate isolated environments (e.g., test, lint, docs) within a project, ensuring dependency isolation and reproducible builds across different development contexts.

PLUGIN SYSTEM

A core feature of Hatch is its extensible plugin system. This allows users to create custom project templates, environment types, builders, and hooks, enabling deep customization and integration with various tools and workflows specific to a project's needs.

HISTORY

Hatch was created by Ofek Lev and first publicly released in 2021. It emerged as a modern, consolidated alternative to fragmented Python packaging and project management solutions. Its development prioritizes extensibility, adherence to contemporary Python Enhancement Proposals (PEPs) like `pyproject.toml` (PEP 517/660), and providing a streamlined, opinionated, yet highly configurable developer experience for managing Python projects end-to-end.

SEE ALSO

pip(1), poetry(1), pipenv(1), setuptools(1), venv(1)

Copied to clipboard