Details | |
Features |
The Hatchlor is a cookiecutter template featuring the modern and extensible Python project manager hatch 🐣.
With hatch, you no longer need to deal with files like requirements.txt
, Pipfile
or environment.yml
,
just configure everything in pyproject.toml
. Thus, hatch is a sophisticated alternative to pipenv, poetry, conda, or
direct virtualenv usage. Just think of hatch as a tool that allows you to easily define many isolated development environments,
e.g. virtual but also docker environments, and helps you to manage them. A bit like what tox does for testing environments but
for all kinds of environments, e.g. testing, linting your code, buildings your docs, and whatever you want.
Check out a vanilla Python project created by the Hatchlor.
The Hatchlor integrates the following features:
- hatch: Python packaging, environment management and test runner,
- hatch-vcs: determine the package version automatically from git tags, e.g.
v0.9
, - hatch-pip-compile: support for lock-files,
- pyproject.toml: all package, build and tool configuration in one file,
- pytest: full-featured Python testing tool that helps you write better programs,
- coverage: tool for measuring code coverage of Python programs with pytest integration,
- GitHub Actions: workflows with dependabot, release-drafter, labeler, build docs, test & publish to PyPI,
- ruff: extremely fast Python linter/formatter, which replaces isort, flake8, black, etc.,
- mypy: optional static type checker for Python,
- mkdocs: a fast, simple and downright gorgeous static site generator,
- pre-commit: pre-commit git hooks that make your life easier,
- Markdown: instead of reStructuredText, Markdown is used consistently for all text files,
- EditorConfig: maintain consistent coding styles for multiple developers,
- src-layout: the actual Python package is kept under a
src
folder avoiding many common errors.
Please note additional integrations and following amendments:
- [semantic-release]: local prepare of a commit: create changelog and commit with a version tag
- [bump-my-version] and [generate-changelog]: alternative to [semantic-release]
- [gitlint]: include linting of commit messages
- GitHub Actions: reworked workflows - dump context, add test publishing on TestPy, switch to new PyPi mechanism
The amendments support a local development and commit process while "outsourcing" testing for different OS and with different Python versions to GitHub. The local committing includes preparation of a changelog. It is based on semantic-versioning. Commit-messages are linted to enforce commit messages according to conventional commits format as basis for a proper and automatically generated changelog.
The template includes a skeleton.py
with a simple function fib
that calculates the Fibonacci numbers
as demonstration. This is tested with tests/test_skeleton.py
to demonstrate the corresponding features
from above. As an additional tidbit, skeleton.py
also features Typer to show how fib
can be
exposed as a CLI command. These files are only for demonstration and can be safely deleted.
Install the latest cookiecutter, i.e. >= 1.4, if not installed:
pip install -U cookiecutter
Then generate your Python project with:
cookiecutter https://github.com/florianwilhelm/the-hatchlor.git
🎉 That's it! Now change into the created directory and check out README.md
for more information.
The Hatchlor is distributed under the terms of the MIT license.
To start this project off a lot of inspiration was taken from hatch, cookiecutter-pypackage and Pyscaffold.