Cookiecutter template for a Python package, built with popular develop tools and conform to best practice.
- Documentation: https://mishamsk.github.io/cookiecutter-pypackage
This tool will create Python project with the following features:
- Poetry: Manage dependency, build and release
- Makefile template for typical operations
- Mkdocs: Writing your docs in markdown style
- Testing with Pytest (unittest is still supported out of the box)
- Tox: Test your code against environment matrix, lint and artifact check
- Format with Black and Isort
- Lint code with Flake8
- Check static type with Mypy (optional)
- Pre-commit hooks: Formatting/linting anytime when commit your code
- Mkdocstrings: Auto API doc generation
- Command line interface using Click (optional)
- bump2version: Pre-configured version bumping with a single command
- Continuous Integration/Deployment by GitHub actions, includes:
- publish dev build/official release to TestPyPI/PyPI automatically when CI success
- publish documents automatically when CI success
- extract changelog from CHANGELOG and integrate with release notes automatically
- Host your documentation from GitHub Pages with zero-config
Install the latest Cookiecutter if you haven't installed it yet (see instruction here). I suggest using pipx to make it a global tool in an isolated Python environment
pipx install cookiecutter
Generate a Python package project:
cookiecutter https://github.com/mishamsk/cookiecutter-pypackage
And code away!
project_name
The name of your new Python package project. This is used in
documentation, so spaces and any characters are fine here.
project_slug
The name of your Python package for PyPI, also as the repository name of GitHub.
Typically, it is the slugified version of project_name.
pkg_name
The namespace of your Python package. This should be Python import-friendly.
project_short_description
A 1-sentence description of what your Python package does.
full_name
Your full name.
email
Your email address.
github_username
Your GitHub username.
version
The starting version number of the package.
use_mypy
If use mypy for static type check in pre-commit hooks and tox.
install_precommit_hooks
If you choose yes, then cookiecutter will install pre-commit hooks for you.
docstrings_style
one of google, numpy, pep257
. It's required by flake8-docstrings.
command_line_interface
Whether to create a console script using Python Click. Console script
entry point will match the project_slug. Options: ['click', "No
command-line interface"]
Except the settings above, you'll also need configure gitub repsitory secrets at page repo > settings > secrtes, and add the following secrets:
- TEST_PYPI_API_TOKEN (required for publishing dev release to testpypi)
- PYPI_API_TOKEN (required for publish )
This repo is forked from waynerv/cookiecutter-pypackage, whose origin traces all the way to audreyfeldroy/cookiecutter-pypackage