Development setup#
Create a virtual environment, activate it and install required packages:
python -m venv .venv
source .venv/bin/activate
pip install -e ".[test]"
# enable basic style checks once
pre-commit install
Important
Make sure to activate the virtual environment in every new shell session:
source .venv/bin/activate
If you want to automate this checkout direnv.
Windows-specifics
On Windows the syntax for virtual environment activation is a bit different:
# The following may need to be run once. Please check the docs for its consequences:
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policiess
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
# Activate via:
.venv\Scripts\Activate.ps1
CLI scripts can now be simply run:
msh2vtu --help
Testing with tox
and pytest
#
Test environment are created and run with tox
.
Tests are executed via pytest
To run the tests:
tox
Note
You can parallelize the tox tests with tox -p
.
You can view a test coverage report by opening htmlcov/index.html
in a browser.
You can also run a single test environment with e.g.:
tox -e py39
The following environments are available:
$ tox list
default environments:
py39 -> Run tests with py39
py310 -> Run tests with py310
py311 -> Run tests with py311
report -> Combines coverage reports into html and xml reports.
typecheck -> Type checks with mypy
pre-commit -> Run pre-commit on all files
additional environments:
docs -> Create documentation
publish -> Run tests with publish
pragma -> Run tests with pragma
Create a package#
pyproject-build
Packages can then be found in dist/
.
Build documentation#
tox -e docs
make html
This will create the documentation files in docs/_build/html
.
For development use the auto-generating and -reloading web server:
docs/toxin -e docs python docs/server.py
# open http://127.0.0.1:5500 in a web browser