This is a minimal Python 3.8 application that uses poetry for packaging and dependency management. It also provides pre-commit hooks (for Black and Flake8) and automated tests using pytest, Coverage.py and GitHub Actions. Documentation can be generated with Sphinx, and version numbers updated with bump2version. It was developed by the Imperial College Research Computing Service while developing the control software for the SPARTA system.
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
poetry_template
with your own application name. Edit:pyproject.toml
tests/test_poetry_template.py
- The
poetry_template
directory name andpoetry_template/__main__.py
docs/source/conf.py
setup.cfg
-
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
-
Run the tests:
pytest
-
Build the documentation:
sphinx-build -b html docs/source/ docs/build/
-
Edit/replace
.py
files,setup.cfg
and.github/workflows/python-package.yml
as required. -
Add new requirements with
poetry add
or by manually adding them topyproject.toml
For a more traditional pip
-based project template, try Pytest Application Template.