Welcome to cookiecutter-py’s documentation!¶
cookiecutter-py¶
🐍 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.
Features¶
poetry
to manage dependenciesstructlog
for loggingmypy
for static typingpytest
,hypothesis
,mutmut
for testingpytest-cov
for coverage reportspytest-mock
for mockspytest-xdist
for distributed testingpytest-randomly
to randomly order tests
tox
for testing automationsphinx
for docsmyst-parser
for markdown docsfuro
theme
pdb++
for debuggingpre-commit
hooks with various hooks (mypy / black /ruff
)dockerfile
for development, testing, and productiondunamai
for versioningcustom
Justfile
(runjust
)stay up-to-date w/ configured
dependabot
github-actions
with ci (leveragingtox
), publish to pypi workflows w/release-drafter
integration-
optional
codecov
integration for code coverage
publish
workflow (to test.pypi.org / pypi.org) w/release-drafter
integrationauto approve / merge
workflowwith these additional workflows:
-
optional
direnv
.envrc (with pyenv layout)
Installation¶
Cookiecutter¶
Install Cookiecutter
pip install cookiecutter
# poetry add cookiecutter
# pipenv install cookiecutter
After installing Cookiecutter, create the project:
cookiecutter gh:ryankanno/cookiecutter-py
Note: 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¶
Install Cruft
pip install cruft
# poetry add cruft
# pipenv install cruft
After installing Cruft, create the project:
cruft create https://github.com/ryankanno/cookiecutter-py/
Details¶
Coming soon to a README near you!
Docker¶
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.surf
Versioning¶
If 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.
TODO¶
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 docs.yml github workflows
deploy to gh-pages / readthedocs
investigate uv
plan for 1.0
License¶
MIT. See LICENSE for deets.
The MIT License (MIT)
Copyright (c) 2015 Ryan Kanno
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.