An open API service indexing awesome lists of open source software.

https://github.com/mgaitan/python-package-copier-template

Copier template for Python projects managed by uv.
https://github.com/mgaitan/python-package-copier-template

boilerplate-template cookiecutter-template copier copier-template python template-project

Last synced: 4 months ago
JSON representation

Copier template for Python projects managed by uv.

Awesome Lists containing this project

README

          

# Modern Python package template

[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-purple.json)](https://github.com/copier-org/copier)
[![CI](https://github.com/mgaitan/python-package-copier-template/actions/workflows/ci.yml/badge.svg)](https://github.com/mgaitan/python-package-copier-template/actions/workflows/ci.yml)
[![Changelog](https://img.shields.io/github/v/release/mgaitan/python-package-copier-template)](https://github.com/mgaitan/python-package-copier-template/releases)

A [Copier](https://github.com/copier-org/copier) template
for modern Python projects.

Demo repo generated from this template: [mgaitan/yet-another-demo](https://github.com/mgaitan/yet-another-demo)

## Features

- ๐Ÿ Modern Python package (3.12+)
- ๐Ÿ“ฆ Build and dependency management with [uv](https://docs.astral.sh/uv/), split by groups (dev/qa/docs)
- ๐ŸงŠ Dependency cooldowns enabled by default in `uv` (`[tool.uv].exclude-newer = "1 week"`), with targeted overrides when needed (for example `ty`) to reduce supply-chain risk without blocking QA tools
- ๐Ÿงน Linting and formatting via [Ruff](https://docs.astral.sh/ruff/) with a broad set of rules enabled
- โœ… Type checking via [ty](https://github.com/astral-sh/ty)
- ๐Ÿงช Tests with [pytest](https://docs.pytest.org/en/stable/), [coverage.py](https://coverage.readthedocs.io/en/latest/) and extensions
- ๐Ÿ“š Docs with [Sphinx](https://www.sphinx-doc.org/en/master/), [MyST](https://myst-parser.readthedocs.io/en/stable/) and a few extensions, deployed to [GitHub Pages](https://pages.github.com/)
- ๐Ÿ—๏ธ Use of [GitHub CLI](https://cli.github.com/) for autotic project creation
- โš™๏ธ CI workflow on [GitHub Actions](https://github.com/features/actions)
- ๐Ÿš€ Automated releases to PyPI via [Trusted Publishing](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/)
- ๐Ÿง  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](https://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`](https://copier.readthedocs.io/en/stable/updating/)

Please read [my blog post](https://mgaitan.github.io/en/posts/opinionated-python-project-scaffolding/) 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):

```bash
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:

```bash
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:

```bash
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:

```bash
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](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/). Read more about how this workflow works [here](https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/)

Then

```
$ make bump # optional
$ make release
```

### Acknowledgement

This project template started as a fork of [pawamoy/copier-uv](https://github.com/pawamoy/copier-uv). Then I simplified and changed it to fit my needs.