Skip to content

Commit 8a347b9

Browse files
committed
Copier project scaffolding
1 parent 2ae96e7 commit 8a347b9

14 files changed

Lines changed: 441 additions & 89 deletions

CHANGELOG.md renamed to CHANGELOG.md.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
This file holds the changelog of `template`. Ideally, entries in the `.changelog`
3+
This file holds the changelog of `{{ module_name }}`. Ideally, entries in the `.changelog`
44
directory should be linked to GitHub issues, which in turn (should) reference Pull
55
Requests.
66

README.md

Lines changed: 77 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
1-
<!-- <div align="center">
2-
<img src="https://github.com/peinser/template/actions/workflows/docs.yml/badge.svg" alt="Docs">
3-
<img src="https://github.com/peinser/template/actions/workflows/image.yml/badge.svg" alt="Docker Image">
4-
<img src="https://github.com/peinser/template/actions/workflows/pypi.yml/badge.svg" alt="PyPI">
5-
<img src="https://badgen.net/badge/license/Apache-2.0/blue" alt="License">
6-
<img src="https://img.shields.io/pypi/v/template" alt="PyPI version">
7-
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
8-
<img src="https://img.shields.io/docker/v/peinser/template" alt="Docker version">
9-
</div>
10-
11-
<p align="center">
12-
<img src="docs/assets/logo.png" height=100%>
13-
</p> -->
14-
151
---
162

173
A modern Python package template with batteries included: strict type checking, automated linting, multi-stage Docker builds, MkDocs documentation, and a full CI/CD pipeline via GitHub Actions.
184

5+
Powered by [Copier](https://copier.readthedocs.io) — scaffold a new project in seconds, and keep it up to date as the template evolves.
6+
197
---
208

219
## Table of Contents
2210

2311
- [Features](#features)
24-
- [Prerequisites](#prerequisites)
25-
- [Getting Started](#getting-started)
12+
- [Using this Template](#using-this-template)
13+
- [Generating a New Project](#generating-a-new-project)
14+
- [Updating an Existing Project](#updating-an-existing-project)
15+
- [Template Variables](#template-variables)
16+
- [Working on the Template Itself](#working-on-the-template-itself)
17+
- [Prerequisites](#prerequisites)
2618
- [Option A — Dev Container (recommended)](#option-a--dev-container-recommended)
2719
- [Option B — Local Setup](#option-b--local-setup)
2820
- [Project Structure](#project-structure)
@@ -33,12 +25,74 @@ A modern Python package template with batteries included: strict type checking,
3325
- [Docker](#docker)
3426
- [CI/CD](#cicd)
3527
- [Publishing to PyPI](#publishing-to-pypi)
36-
- [Customizing the Template](#customizing-the-template)
3728
- [Contributing](#contributing)
3829
- [License](#license)
3930

4031
---
4132

33+
## Using this Template
34+
35+
### Generating a New Project
36+
37+
> **Requirement:** Copier 9.0 or newer. Install it once with:
38+
> ```bash
39+
> pipx install copier
40+
> # or
41+
> uv tool install copier
42+
> ```
43+
44+
Run the following command and answer the prompts:
45+
46+
```bash
47+
copier copy gh:peinser/template <destination-directory>
48+
```
49+
50+
Copier will ask for:
51+
52+
| Variable | Description |
53+
|---|---|
54+
| `project_name` | Human-readable name (e.g. `My Awesome Library`) |
55+
| `project_description` | One-line description of the project |
56+
| `author_name` | Your full name |
57+
| `author_email` | Your e-mail address |
58+
| `repo_url` | Full HTTPS GitHub URL (e.g. `https://github.com/owner/repo`) |
59+
| `module_name` | Python module name — lowercase, underscores only (e.g. `my_library`) |
60+
61+
After generation, `git init` and `git add .` are run automatically. Then:
62+
63+
```bash
64+
cd <destination-directory>
65+
uv sync --locked # install all dependencies
66+
make help # see available tasks
67+
```
68+
69+
> **Tip:** The answers are stored in `.copier-answers.yml` inside the generated project. Do not delete this file — it is required for future updates.
70+
71+
### Updating an Existing Project
72+
73+
When this template is updated, regenerate your project to pull in the latest changes:
74+
75+
```bash
76+
cd <your-project>
77+
copier update
78+
```
79+
80+
Copier replays your original answers, applies the diff, and lets you resolve any conflicts. Review the changes with `git diff` before committing.
81+
82+
### Template Variables
83+
84+
All variables are validated at prompt time:
85+
86+
- `author_email` must match a basic `user@host.tld` pattern.
87+
- `repo_url` must start with `https://github.com/`.
88+
- `module_name` must be a valid Python identifier: starts with a lowercase letter, followed by lowercase letters, digits, or underscores.
89+
90+
---
91+
92+
## Working on the Template Itself
93+
94+
The sections below describe the reference project bundled with this template. They also serve as living documentation for the generated project's `README.md`.
95+
4296
## Features
4397

4498
| Area | Tooling |
@@ -69,8 +123,6 @@ A modern Python package template with batteries included: strict type checking,
69123

70124
---
71125

72-
## Getting Started
73-
74126
### Option A — Dev Container (recommended)
75127

76128
The dev container provides a fully configured, reproducible environment with all tools pre-installed (including `act` for local CI testing).
@@ -109,6 +161,7 @@ That's it. Skip to [Development Workflow](#development-workflow).
109161
cd template
110162
```
111163

164+
112165
2. **Install uv** (if not already installed):
113166

114167
```bash
@@ -337,8 +390,6 @@ The dev container ships with [`act`](https://github.com/nektos/act), which lets
337390
338391
---
339392

340-
Here's a clean, professional documentation section you can add to your project's **README.md** (or a dedicated `CONTRIBUTING.md` / `RELEASE.md` file).
341-
342393
## Publishing to PyPI
343394

344395
This project uses [`uv`](https://docs.astral.sh/uv/) for building and publishing. Releases are published automatically via GitHub Actions using **Trusted Publishing** (OIDC), which is the most secure method in 2026 — no long-lived API tokens are required.
@@ -401,25 +452,13 @@ The workflow will:
401452

402453
## Customizing the Template
403454

404-
After forking or using this template, rename the project to match your package:
405-
406-
1. **`pyproject.toml`** — update `name`, `version`, `description`, `authors`, and `requires-python`.
407-
2. **`src/template/`** — rename the directory to your package name.
408-
3. **`pyproject.toml`** — update `[tool.hatch.build.targets.wheel] packages` and all `[tool.mypy] files` / `[tool.towncrier] package` references.
409-
4. **`mkdocs.yml`** — update `site_name` and any repository URLs.
410-
5. **`.github/workflows/`** — update the Docker registry path and image name in `image.yml`. Also, follow the `PyPi` section in this `README.md` if you would like to publish to `PyPi`.
411-
6. **`README.md`** — replace badge URLs, logo, and project description.
412-
7. **`CODEOWNERS`** — replace `@peinser` and `@JoeriHermans` with your GitHub handle(s).
413-
8. **`docker/Dockerfile`** - replace `template`.
455+
All renaming and substitution is handled automatically by Copier — see [Using this Template](#using-this-template).
414456

415-
Other files containing references to `template`. Adjust accordingly.
457+
After generation you may still want to manually adjust:
416458

417-
```
418-
./uv.lock
419-
./CHANGELOG.md
420-
./src/template/__init__.py
421-
./src/template/__version__.py
422-
```
459+
- **`.github/workflows/image.yml`** — update the Docker registry path and image name.
460+
- **`CODEOWNERS`** — replace the placeholder GitHub handle(s) with your own.
461+
- **`docker/entrypoint.sh`** — add your application's startup logic.
423462

424463
---
425464

0 commit comments

Comments
 (0)