This is a minimal Python 3.12 application that uses poetry for packaging and dependency management. It also provides pre-commit hooks (for ruff and mypy) and automated tests using pytest and GitHub Actions. Pre-commit hooks are automatically kept updated with a dedicated GitHub Action, this can be removed and replace with pre-commit.ci if using an public repo. It was developed by the Imperial College Research Computing Service.
To use this repository as a template for your own application:
-
Download and install Poetry following the instructions for your OS.
-
Click the green "Use this template" button above
-
Name and create your repository
-
Clone your new repository and make it your working directory
-
Replace instances of
myprojectwith your own application name. Edit:pyproject.tomltests/test_myproject.py- Rename
myprojectdirectory
-
Set up the virtual environment:
poetry install
-
Activate the virtual environment (alternatively, ensure any python-related command is preceded by
poetry run):poetry shell
-
Install the git hooks:
pre-commit install
-
Run the main app:
python -m myproject
-
Run the tests:
pytest
The GitHub workflow includes an action to publish on release.
To run this action, uncomment the commented portion of publish.yml, and modify the steps for the desired behaviour (ie. publishing a Docker image, publishing to PyPI, deploying documentation etc.)