Template repository for Python projects: a src/ package with a console
entry point, pytest tests, GitHub Actions for tests, static analysis,
tutorials, documentation and PyPI publishing, and an
Astro +
Starlight documentation site.
Documentation: https://max-models.github.io/template-python/
Create a repository from this template, then rename the package:
bash setup_project.sh my-app
rm setup_project.shThis replaces template-python with my-app everywhere, moves
src/app to src/my_app, and points the entry point, tests and docs at
it.
With uv:
make install # uv sync --extra dev, plus the pre-commit hooks
uv run template-pythonOr create and activate a Python environment (3.10 or newer):
python -m venv env
source env/bin/activate
pip install --upgrade pipInstall the code and requirements with pip:
pip install -e .Run the code with:
template-pythonThe test, docs and dev extras install the test runner, the
documentation tooling and the linters:
pip install -e ".[dev]"Formatting and linting use ruff, type checking pyright, run by pre-commit and in CI:
make lint # ruff check, ruff format --check, pyright
make test # pytest with coverageCommit messages follow Conventional Commits; see CONTRIBUTING.md.
The documentation in docs/ is an Astro + Starlight site: hand-written
pages, the notebooks in tutorials/ executed and published as pages,
and the API reference generated from the docstrings with
starlight-pydocs. It needs
Node 22 or newer.
make docs-install # npm packages and the Python docs extra
make docs-notebooks # execute tutorials/*.ipynb and convert them to pages
make docs-dev # live preview at http://localhost:4321/template-python/
make docs-build # the static site in docs/distREADME.md is rendered from README.qmd with
Quarto:
make readmerelease-please keeps a
release PR open on main from the commit messages. Merging it tags the
release, updates CHANGELOG.md and publishes the package to PyPI with
trusted publishing (OIDC). The one-time PyPI and GitHub configuration is
described in the publishing
guide.

