templatepy¶
Copier template for modern Python packages.
Stack¶
| Tool | Role |
|---|---|
| uv | Dependency management, virtual environments, running tools |
| hatchling + hatch-vcs | Build backend; version derived from git tags |
| commitizen | Conventional Commits enforcement; auto version bump on merge |
| ruff | Linting and formatting |
| mypy | Static type checking |
| pytest + pytest-cov | Testing with coverage |
| MkDocs Material | Documentation (this site) |
Requirements¶
Create a new project¶
copier copy gh:larsrollik/templatepy my-new-project
cd my-new-project
git init && git add -A && git commit -m "chore: initial commit from templatepy"
uv sync --extra dev
uv run pre-commit install --hook-type pre-commit --hook-type commit-msg
Apply template updates to an existing project¶
Copier reads .copier-answers.yml (committed in the generated repo) to know what answers were given and which template version was used.
Day-to-day commands¶
cz commit # structured commit (enforces Conventional Commits)
uv run pytest # run tests
uv run pre-commit run --all-files # run all lint checks manually
Version bumping and releasing are handled automatically by bump.yml and release.yml on every merge to main. Manual override:
Project structure (generated)¶
my-project/
├── src/
│ └── my_project/
│ ├── __init__.py # version via importlib.metadata
│ └── py.typed # PEP 561 typed marker
├── tests/
│ ├── conftest.py
│ ├── unit/
│ └── integration/
├── .github/
│ └── workflows/
│ ├── ci.yml # lint on push; tests on PR to main
│ ├── bump.yml # auto cz bump on merge to main
│ ├── release.yml # on v* tag: GitHub release + PyPI (OIDC)
│ └── docs.yml # deploy MkDocs to GitHub Pages on push to main
├── pyproject.toml
├── CITATION.cff # citation metadata for Zenodo + GitHub
├── .pre-commit-config.yaml
└── LICENSE