Skip to content

mgaitan/python-package-copier-template

Modern Python package template

Copier CI Changelog

A Copier template for modern Python projects.

Demo repo generated from this template: mgaitan/yet-another-demo

Features

  • 🐍 Modern Python package (3.12+)
  • πŸ“¦ Build and dependency management with uv, split by groups (dev/qa/docs)
  • 🧹 Linting and formatting via Ruff with a broad set of rules enabled
  • βœ… Type checking via ty
  • πŸ§ͺ Tests with pytest, coverage.py and extensions
  • πŸ“š Docs with Sphinx, MyST and a few extensions, deployed to GitHub Pages
  • πŸ—οΈ Use of GitHub CLI for autotic project creation
  • βš™οΈ CI workflow on GitHub Actions
  • πŸš€ Automated releases to PyPI via Trusted Publishing
  • 🧠 Sensible defaults via introspection to minimize answers during the initial setup
  • πŸ› οΈ Makefile with shortcuts for common tasks
  • πŸ“„ Generation of generic docs such as LICENSE, CODE_OF_CONDUCT, etc.
  • πŸ€– Heavily curated AGENTS.md
  • πŸŒ€ Initial setup of the development environment and git repo
  • πŸ” Scheduled template refresh workflow that opens a PR every 20 days when updates are available
  • ♻️ Projects updatable with copier update

Please read my blog post to learn about the details of the decisions I made and the alternatives I considered.

Quick setup and usage

Quick shortcut (auto-detects copy vs update):

uvx git+https://github.com/mgaitan/python-package-copier-template [DESTINATION]

This runs copier copy --defaults --unsafe to DESTINATION (or . if omitted) when no .copier-answers.yml is present, or copier update --defaults --unsafe when it is. Check the installed version with uvx git+https://github.com/mgaitan/python-package-copier-template -- --version.

Start a new project explicitly with Copier:

uvx --with=copier-template-extensions copier copy --trust "gh:mgaitan/python-package-copier-template" /path/to/your/new/project

To upgrade an existing project created from this template to the latest version, run:

uvx --with=copier-template-extensions copier update . --trust 

This will fetch the latest template version and guide you through updating your project, preserving your customizations whenever possible.

The generated project also ships a Template Update GitHub Actions workflow that runs every 20 days (or on manual dispatch) to execute uvx copier update --trust --defaults . and open a pull request with the changes and template version bump.

To test a development version of the template, clone the repository and run:

uv sync
uv run copier copy --trust  --vcs-ref=HEAD . /path/to/your/test/project

If you create the GitHub repository via the gh CLI prompt, the template will attempt to enable GitHub Pages (using the Actions build type) so documentation deployments succeed. If Pages is unavailable (for example, with some private repositories or account policies), the docs workflow will keep failing until Pages is allowed.

To publish a release of your project to PyPI, you need to register the project with trusted published. Read more about how this workflow works here

Then

$ make bump    # optional
$ make release

Acknowledgement

This project template started as a fork of pawamoy/copier-uv. Then I simplified and changed it to fit my needs.