Skip to content

Cookiecutter for rapidly creating modern & high-quality Python packages

License

Notifications You must be signed in to change notification settings

collijk/python-package-cookiecutter

 
 

Repository files navigation

Python Package Cookiecutter

A cookiecutter (project template) for rapidly developing new open source Python packages. Best practices with all the modern bells and whistles included.

Features

Automatic updates to the projects generated from this cookiecutter

  • Powered by cruft
  • Keep your project up-to-date with best practices

Continuous integration

  • Powered by Github Actions
  • Testing against multiple different versions

Documentation

Automated releases

  • Publishing to PyPI when a release is made in GitHub

Changelog management

  • Gently enforced: Keep a Changelog
  • GitHub releases get their description automatically populated based on the changelog content
  • The Unreleased section is automatically updated when a release is done
  • Changelog is embedded in the documentation

Bells and whistles

  • Poetry for managing dependencies and packaging
  • pre-commit for running all the goodies listed below
  • mypy for static type checking
  • ruff for automatic formatting, linting and automatically fixing some linting errors

Automation

  • Updates to the best practices (via GHA workflow which runs cruft update and creates a PR)
  • Dependency updates (via GHA workflow which creates a PR)

Usage

Make sure you have cruft installed. Alternatively, you can use cookiecutter if you are not interested in getting updates to the project "boilerplate" in the future.

Create a new project:

cruft create https://github.com/collijk/python-package-cookiecutter

The CLI interface will ask some basic questions, such the name of the project, and then generate all the goodies automatically.

After that you can make it a proper git repo:

cd <your-project-slug>
git init
git add .
git commit -m "Initial project structure from Python Package cookiecutter"

We update this cookiecutter template regularly to keep it up-to-date with the best practices of the Python world. You can get the updates into your project with:

cruft update

Configure secrets

PYPI_TOKEN

Required for publishing the package to PyPI. You can generate a token by logging into PyPI and navigating to Add API token in your account settings.

GH_TOKEN

This cookiecutter template needs repository access for the following operations:

  • Automatically updating the infrastructure files when the template is updated (via cruft)
  • Automatically updating the dependencies.
  • Automatically updating the changelog and version for draft releases.

To enable these features, you need to create a personal access token and use it as the value for GH_TOKEN secret. When creating the access token, the following permissions have to be granted:

  • repo
  • workflow

After the first release

The first release will create gh-pages branch which will contain the static files for the documentation. Enable GitHub Pages in the Pages section of the repository settings.

About

Cookiecutter for rapidly creating modern & high-quality Python packages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 60.5%
  • JavaScript 39.5%