Template for BonvinLab Python projects. src-layout, pytest, GitHub Actions for CI, Docker, and PyPI publishing.
src/<package>/is the package, withmain.py(argparse CLI stub),utils.py(example functions),log.py(logging setup)tests/— matching pytest tests.github/workflows/test.ymlautomated actions that run pytest on push/PR tomain, matrix ofubuntu-latest/macos-latestx Python 3.10/3.14.github/workflows/docker-publish.ymlautomated action that builds and pushes a Docker image to GHCR on tag push.github/workflows/publish.ymlis an action publishes to PyPI on GitHub release
-
Use this template on GitHub when creating a new repository.
-
Rename the package:
src/python_project_template/→src/your_package_name/, updatenameinpyproject.toml. -
Install:
pip install -e ".[dev]" -
Run tests:
pytest
-
Fill in the stubs in
main.py,utils.py,log.py, and update the tests to match. -
Start programming (:
The Dockerfile installs the package with pip install . and runs python -m your_package_name.main as the entrypoint, update that module path after renaming.
docker-publish.yml action builds the image and pushes it to GHCR (ghcr.io/<owner>/<repo>) on every tag push, tagged to match.
Build and run locally:
docker build -t your-image-name .
docker run --rm your-image-namepublish.yml uses trusted publishing, to configure it:
- Go to pypi.org: Publishing -> add a trusted publisher with your repo name, workflow
publish.yml. - Update the
urlinpublish.ymlto your project's PyPI page. - Make a GitHub release, the workflow will run and publish your code to PyPi