Metadata-Version: 2.3
Name: python-package-copier-template
Version: 0.4.3
Summary: A Copier template for modern Python projects.
Author: Martín Gaitán
Author-email: Martín Gaitán <gaitan@gmail.com>
Requires-Dist: copier>=9.11.0
Requires-Dist: copier-templates-extensions>=0.3.2
Requires-Dist: ruff>=0.14.9
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# 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)
- 🪝 Optional pre-commit style QA orchestration via [prek](https://github.com/j178/prek) as an external tool (`uv tool install prek`; hooks include `check-ast`, `check-yaml`, `check-toml`, Ruff, 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/)
- 👀 Automatic docs preview deployment for PRs that modify documentation (`/_preview/pr-<PR_NUMBER>/` on GitHub Pages)
- 🧭 Generated docs follow [Diataxis](https://diataxis.fr/) and document rationale in [`about_the_docs`](project/docs/about_the_docs.md.jinja)
- 🏗️ 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.

## Package Documentation

The package now includes a Diataxis-based docs set under `docs/` that expands this README:

- [Tutorial: Getting started](docs/getting_started.md)
- [How-to: Maintain the template](docs/maintain_template.md)
- [Reference: Configuration](docs/configuration.md)
- [Explanation: About these docs](docs/about_the_docs.md)
- [Explanation: Design decisions](docs/design_decisions.md)

## Quick setup and usage

Quick shortcut (auto-detects copy vs update):

```bash
uvx python-package-copier-template [PATH_TO_PROJECT]
```

This runs `copier copy --defaults --unsafe` to `PATH_TO_PROJECT` (or `.` if omitted) when no `.copier-answers.yml` is present, or `copier update --defaults --unsafe` when it is.
Check the installed version with `uvx python-package-copier-template --version`.
When installed from PyPI, the wrapper copies from the matching template release instead of always using `main`.

If you want the latest development version straight from this repository instead of the latest published release, use:

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

You can check that wrapper version with `uvx git+https://github.com/mgaitan/python-package-copier-template -- --version`.

Start a new project explicitly with Copier if you want to bypass the wrapper:

```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 local 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 publishing](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/).

This repository's own release workflow also refreshes the demo repository after a successful publish. That step requires the `DEMO_REPO_TOKEN` GitHub Actions secret, documented in [Configuration](docs/configuration.md).

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.
