.
├── cmake
├── mylib
│ ├── include # header files of C++ library
│ │ └── mylib
│ ├── src # source files of C++ library
│ └── tests # tests for C++ library
│ └── unit
└── python
├── mylib # python module
├── mylib11 # python bindings for C++ library
└── tests # tests suites, results and coverage reports
├── mylib # tests for python module
└── mylib11 # tests for C++/pybind11 moduleYou can then install the mylib and mylib11 package with pip:
pip install .# build using cmake
cmake -S . -B build -G Ninja
cmake --build buildblack .cmake -S . -B build -G Ninja
cmake --build build --target check-format # check formatting only
cmake --build build --target format # show differences between current and reformatted code
cmake --build build --target fix-format # apply reformattingPure python module:
pip install -e .[test]
pytest -vv python/tests/mylibBindings module:
pip install -e .[test]
pytest -vv python/tests/mylib11C++ code:
cmake -S . -B build -G Ninja
cmake --build build
cmake --build build --target testOnce the python tests are running properly you can get a code coverage report with:
coverage run --source=python -m pytest python/tests/mylib && coverage report -mFor a detailed analysis of which code sections are covered you can generate an
HTML report. Then open the file python/tests/coverage/index.html.
coverage html -d python/tests/coverage