Poetry Template

build status

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:

  1. Download and install Poetry following the instructions for your OS.

  2. Click the green "Use this template" button above

  3. Name and create your repository

  4. Clone your new repository and make it your working directory

  5. Replace instances of poetry_template with your own application name. Edit:

    • pyproject.toml
    • tests/test_poetry_template.py
    • The poetry_template directory name and poetry_template/__main__.py
    • docs/source/conf.py
    • setup.cfg
  6. Set up the virtual environment:

    poetry install
  7. Activate the virtual environment (alternatively, ensure any python-related command is preceded by poetry run):

    poetry shell
  8. Install the git hooks:

    pre-commit install
  9. Run the main app:

    python 
  10. Run the tests:

    pytest
  11. Build the documentation:

    sphinx-build -b html docs/source/ docs/build/
  12. Edit/replace .py files, setup.cfg and .github/workflows/python-package.yml as required.

  13. Add new requirements with poetry add or by manually adding them to pyproject.toml

For a more traditional pip-based project template, try Pytest Application Template.