๐ Modern Python project Cookiecutter template
Each time you start a new Python project, you shouldn't start from scratch. Ideally, you'd start with a standard project structure and set of tools and integrations to help facilitate writing quality Python code.
This modern Python Cookiecutter template is the tool that will help you do just that.
-
poetryto manage dependencies -
structlogfor logging -
mypyfor static typing -
pytest,hypothesis,mutmutfor testingpytest-covfor coverage reportspytest-mockfor mockspytest-xdistfor distributed testingpytest-randomlyto randomly order tests
-
toxfor testing automation -
sphinxfor docsmyst-parserfor markdown docs- selectable theme
-
pdb++for debugging -
pre-commithooks with various hooks (mypy / black /ruff/deptry) -
dockerfilefor development, testing, and production -
dunamaifor versioning -
custom
Justfile(runjust) -
stay up-to-date w/ configured
dependabot -
github-actionswith ci (leveragingtox), publish to pypi workflows w/release-drafterintegration-
- optional
codecovintegration for code coverage
- optional
-
publishworkflow (to test.pypi.org / pypi.org) w/release-drafterintegration -
auto approve / mergeworkflow -
with these additional workflows:
-
-
optional
direnv.envrc (with pyenv layout)
Install Cookiecutter
poetry add cookiecutter
# pip install cookiecutter
# pipenv install cookiecutterOptional: Install Cruft
poetry add cruft
# pip install cruft
# pipenv install cruftcookiecutter gh:ryankanno/cookiecutter-pyNote: If you want to use the auto approve / merge Dependabot workflow, make
sure to create tags major, minor, patch so that Dependabot can tag its
PRs. The workflow won't merge anything with a major tag.
cruft create https://github.com/ryankanno/cookiecutter-py/Coming soon to a README near you!
To build the container:
DOCKER_BUILDKIT=1 docker build .To run the container (if you've installed the defaults):
docker run <image_id or tag> python -m surf.surfIf you enable the PyPi workflow, versioning will happen via dunamai within the Github pipeline.
If instead, you prefer to version your package, please do it via poetry version $(dunamai from any) as recommended in their documentation.
See the open issues for a list of proposed features (and known issues).
- add mutmut example to template
- add hypothesis example to template
- add licenses
- add typeguard
- version releases
- update docs
- include cookiecutter var descriptions
- update default/initial template doc structure
- add publish docs workflow
- investigate uv
- migrate to uv
- plan for 1.0
Contributions are very much appreciated.
- Fork the project
- Create your feature branch (
git checkout -b feature/new-cookiecutter-feature) - Commit your changes (
git commit -m 'Added a new feature') - Push to the feature branch (
git push origin feature/new-cookiecutter-feature) - Open a PR! ๐
Distributed under the MIT License. See LICENSE for more information.
Ryan Kanno - @ryankanno
Project Link: https://github.com/ryankanno/cookiecutter-py