A modern opinionated Cookiecutter template for Python packages and applications using Poetry.
-
Poetry: Dependency management and packaging
-
Tox: Easily run tests for different python versions
-
Github Actions: Ready for Continous Integration testing
-
Tests using Pytest including support for
- pytest-mock for mocking
- code coverage using coverage.py
-
pre-commit hook to automatically run
- autoflake - automatically removes unused imports and variables,
- isort - automatically sorts imports alphabetically, and automatically separated into sections and by type,
- black - automatically formats your code,
- flake8 - checks code against code style (PEP8), programming errors and complexity,
- flake8-bugbear - finds likely bugs and design problems in your program,
- flake8-builtins - Checks for python builtins being used as variables or parameters,
- flake8-debugger - Checks for
pdb
statements, - pep8-naming - Checks code against PEP 8 naming conventions,
- flake8-comprehensions - helps you write better list/set/dict comprehensions,
- mypy - static type checker,
-
Debugging tools
- pdbpp - better debugger,
- [better_exceptions] - Pretty and more helpful exceptions in Python, automatically
-
(optional) Preconfigured for Django applications
- Support for Twelve-factor-Methodology using django-environ
-
Simple pull request template with checklist
Get the latest version of Cruft (or Cookiecutter) I recommend pipx to install it into a global isolated environment.
pipx install cruft
Generate a new python package
cruft create https://github.com/escaped/cookiecutter-pypackage.git
cd <chosen project slug>
git init
git add .
git commit -m "feat: initial project structure"
In order get automatic releases to pypi you need to add your pypi access token to the github secrets (named PYPI_TOKEN
).
Instructions can be found here: python.org.
This cookiecutter template comes with an auto update feature if the project was created using cruft. A GitHub action automatically checks for updates and creates a pull request.
It is required to add a personal access token
as github secret to the repository (named AUTO_UPDATE_GITHUB_TOKEN
).
While creating the access token, the following permissions have to be granted
- repo
- workflow