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 command [options]

PARAMETERS

new
    Create a new project.

env
    Manage project environments (create, activate, remove, etc.).

build
    Build distributions (wheel, sdist) of the project.

publish
    Publish distributions to a package index.

run
    Execute a command within a project environment.

config
    Manage hatch configuration settings.

version
    Show the version of hatch.

help
    Display help information.

DESCRIPTION

hatch is a modern, extensible Python project manager designed for creating reproducible, isolated development environments. It streamlines project creation, dependency management, virtual environment handling, publishing, and more.

It distinguishes itself by offering a flexible plugin system, allowing for customization of build systems, version management, and publishing workflows. Hatch simplifies tasks like initializing new projects, adding dependencies, managing virtual environments, and building distributions.

The primary goal of hatch is to provide a consistent and straightforward workflow for Python projects, reducing the complexity often associated with managing dependencies and environments.

CAVEATS

Hatch is a relatively new tool, and it is rapidly evolving. Be aware of potential breaking changes in future releases. Requires Python 3.8 or higher.

VIRTUAL ENVIRONMENT MANAGEMENT

Hatch simplifies virtual environment creation and activation. You can easily create multiple environments for different purposes, such as development, testing, or deployment. Hatch manages the environment locations and makes activation a simple command. Environments are defined using TOML configuration.

PROJECT INITIALIZATION

The `hatch new` command quickly scaffolds a new project with a predefined structure, including the pyproject.toml file. This file defines all project configurations and dependencies.

HISTORY

Hatch was created to address the complexities of managing Python projects and environments. Its development focused on providing a more intuitive and flexible alternative to traditional tools like venv and virtualenv combined with pip. Hatch is relatively recent and has gained traction quickly in Python communities for its ease of use and rich feature set.

SEE ALSO

venv(1), pip(1)

Copied to clipboard