Skip to content

A cookiecutter template to create a python project with hatch as the build system and dependency manager. It also uses black for formatting, pre-commit and commitzen for commit checks and versioning, and ruff for linting. Fast and straightforward to manage!

License

Notifications You must be signed in to change notification settings

KingMichaelPark/hatch-python-cookiecutter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Hatch Managed Cookiecutter template

Hatch project linting - Ruff code style - Black


Table of Contents

Installation

pip install cookiecutter
cookiecutter gh:KingMichaelPark/hatch-python-cookiecutter

Preview of Generated Project

Development

To work with your project you can drop into a shell that keeps your dependencies synced with the entries in your pyproject.toml file. You can have dependency groups there that allow for custom shells.

You can enter a shell simply with:

hatch shell
# You can still run other shell commands such as git helpers from within the shell
hatch run git:commit

Project dependencies for the build can be listed with:

❯ hatch dep show table
 Env: default
┏━━━━━━━━━━━━┓
┃ Name       ┃
┡━━━━━━━━━━━━┩
│ black      │
│ pytest     │
│ pytest-cov │
│ ruff       │
└────────────┘

You can update these and include sub shells in your pyproject.toml. Environments

Working on the project source code with code-completion can be done by simply calling: hatch shell.

Versioning

Commitzen is used to handle the version bumping (Hatch can do this as well but doesn't get git tags by default)^1

hatch run git:version

(It is really a wrapper for cz bump {args})

hatch run git:version --help

Committing

Helper functions for nice commit messages are also built-in using commitizen.

hatch run git:commit

Building

Hatch complies with modern Python packaging specs and therefore your projects can be used by other tools with Hatch serving as just the build backend.

Invoking the build command without any arguments will build the sdist and wheel targets:

Build

hatch build

Publishing

After your project is built, you can distribute it using the publish command.

The -p/--publisher option controls which publisher to use, with the default being index.

Publish

hatch publish

License

{{ cookiecutter.project_slug }} is distributed under the terms of the MIT license.

About

A cookiecutter template to create a python project with hatch as the build system and dependency manager. It also uses black for formatting, pre-commit and commitzen for commit checks and versioning, and ruff for linting. Fast and straightforward to manage!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages