Developer’s corner#

pytest and flake#

To launch the test suite, run:

poetry install --with test
poetry run pytest

Coverage#

To evaluate the test coverage, run:

poetry install --with dev
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 programming style, run:

poetry install --with dev

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

… or directly: .. code-block:: bash

poetry run flake8 src/ tests/

Documentation#

To build the documentation, run:

  • If make is installed:

poetry install --with docs
poetry run make docs
  • Otherwise:

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

Publish a release#

Initialization#

  • Create a token in Pypi.

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

    • PYPI_USERNAME: __token__

    • PYPI_TOKEN: pypi-xxxxxxxxxxxx

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

poetry config pypi-token.pypi pypi-xxxxxxxxxxxx
  • Install bumpversion:

apt install bumpversion

New release#

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

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

bumpversion patch  # Possible values: major / minor / patch
git push
git push --tags
  • Publish the release

    • Method 1: In GitHub, create a release for the tag you have created. It publishes the package to PyPI (see .github/workflows/publish_on_pypi.yml).

    • Method 2: Alternatively, you could run:

poetry publish

Modifying the project dependencies#

Update the pyproject.toml file. Then, run:

poetry lock
poetry install

You could check the dependencies of your wheels thanks to pkginfo:

pkginfo -f requires_dist dist/*whl