hatch Documentation

Modern, extensible Python project management

7,216 stars Python Python 1 file ยท ~1,906 tokens #build#cli#packaging#plugin#python#versioning#virtualenv
RAW Doc

Docker & Self-Hosted Deployment Verified OCI

Deploy hatch on any server, homelab, or cloud container platform.

1-Click Terminal Command
bash (docker run)
docker run -d --name hatch -p 3141:3141 --restart always nginx:alpine
Configured Services & Ports
โš™๏ธ devpi
image: build locally
๐Ÿ”Œ Ports: 3141:3141
โš™๏ธ nginx
image: nginx:alpine
๐Ÿ”Œ Ports: 8080:80, 8443:443
docker-compose.yml
yaml (docker-compose.yml)
services:
  devpi:
    container_name: hatch-devpi
    build:
      context: devpi
    ports:
    - "3141:3141"
    environment:
    - DEVPI_INDEX_NAME
    - DEVPI_USERNAME
    - DEVPI_PASSWORD
    healthcheck:
      test: [ "CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:3141')" ]
      interval: 2s
      timeout: 5s
      retries: 30
      start_period: 10s

  nginx:
    container_name: hatch-nginx
    image: nginx:alpine
    ports:
    - "8080:80"
    - "8443:443"
    volumes:
    - ./nginx:/etc/nginx
    depends_on:
      devpi:
        condition: service_healthy

File: README.md

Hatch


Hatch is a modern, extensible Python project manager.

Features

See the Why Hatch? page for more information.

Documentation

The documentation is made with Material for MkDocs and is hosted by GitHub Pages.

License

Hatch is distributed under the terms of the MIT license.


File: docs/index.md

Hatch

{ role="img" }

CI/CD { loading=lazy .off-glb } { loading=lazy .off-glb } { loading=lazy .off-glb }
Docs { loading=lazy .off-glb } { loading=lazy .off-glb }
Package { loading=lazy .off-glb } { loading=lazy .off-glb } { loading=lazy .off-glb } { loading=lazy .off-glb }
Meta { loading=lazy .off-glb } { loading=lazy .off-glb } { loading=lazy .off-glb } { loading=lazy .off-glb } { loading=lazy .off-glb }

Hatch is a modern, extensible Python project manager. See the Why Hatch? page for more information.

License

Hatch is distributed under the terms of the MIT license.

Documentation for specific MAJOR.MINOR versions can be chosen by using the dropdown on the top of every page. The dev version reflects changes that have not yet been released.

Also, desktop readers can use special keyboard shortcuts:

Keys Action
  • , (comma)
  • p
  • Navigate to the "previous" page
  • . (period)
  • n
  • Navigate to the "next" page
  • /
  • s
  • Display the search modal

    File: docs/intro.md

    Introduction


    Setup

    Projects can be set up for use by Hatch using the new command.

    New project

    Let's say you want to create a project named Hatch Demo. You would run:

    text
    hatch new "Hatch Demo"

    This would create the following structure in your current working directory:

    text
    hatch-demo
    โ”œโ”€โ”€ src
    โ”‚   โ””โ”€โ”€ hatch_demo
    โ”‚       โ”œโ”€โ”€ __about__.py
    โ”‚       โ””โ”€โ”€ __init__.py
    โ”œโ”€โ”€ tests
    โ”‚   โ””โ”€โ”€ __init__.py
    โ”œโ”€โ”€ LICENSE.txt
    โ”œโ”€โ”€ README.md
    โ””โ”€โ”€ pyproject.toml

    !!! tip
    There are many ways to customize project generation.

    Existing project

    To initialize an existing project, enter the directory containing the project and run the following:

    text
    hatch new --init

    If your project has a setup.py file the command will automatically migrate setuptools configuration for you. Otherwise, this will interactively guide you through the setup process.

    Project metadata

    Next you'll want to define more of your project's metadata located in the pyproject.toml file. You can specify things like its license, the supported versions of Python, and URLs referring to various parts of your project, like documentation.

    Dependencies

    The last step of the setup process is to define any dependencies that you'd like your project to begin with.

    Configuration

    All project-specific configuration recognized by Hatch can be defined in either the pyproject.toml file, or a file named hatch.toml where options are not contained within the tool.hatch table:

    toml config-example
    [tool.hatch]
    option = "..."
    
    [tool.hatch.table1]
    option = "..."
    
    [tool.hatch.table2]
    option = "..."

    Top level keys in the latter file take precedence when defined in both.

    !!! tip
    If you want to make your file more compact, you can use dotted keys, turning the above example into:

    text
    ```toml config-example
    [tool.hatch]
    option = "..."
    table1.option = "..."
    table2.option = "..."
    ```