Developer’s corner

Tests

To launch the test suite, run:

  • If the package is installed system-wide:

pytest
  • Else, with poetry:

poetry install --with test
poetry run coverage run -m pytest
poetry run coverage xml
  • Else, with tox:

    • The versions of python that are tested are listed in tox.ini.

    • To run the tests, run:

tox -e py

Programming style

To check the quality of the code, use flake8:

# Stops the build if there are Python syntax errors or undefined names
poetry run flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
poetry run flake8 src/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

Documentation

To build the documentation, run:

  • If the package is installed system-wide and if make is installed:

make docs
  • Otherwise:

poetry run sphinx-apidoc -f -o docs/ src/
poetry run sphinx-build -b html docs/ docs/_build

Publish a release

Initialization

  1. Create a token in Pypi.

  2. Configure this token in your GitHub repository (in the settings tab)

  • PYPI_USERNAME: __token__

  • PYPI_TOKEN: pypi-xxxxxxxxxxxx

  1. Configure this token in poetry so that you can use poetry publish in the future

poetry config pypi-token.pypi pypi-xxxxxxxxxxxx

New release

  1. Update the changelog HISTORY.md, then add and commit this change:

git add README.md
git commit -m "Updated README.md"
  1. Increase the version number using bumpversion:

bumpversion patch # Possible values major / minor / patch
git push
git push --tags
  1. Optionnally, in GitHub, create a release for the tag you have created.

It publishes the package to PyPI (see .github/workflows/publish_on_pypi.yml). Alternatively, you could run:

poetry publish