Creating the development environment
pyenv is used to manage the different versions of Python that are used for the experiments and for testing. If you have pyenv installed and activated, pyenv will make the necessary python versions available as they are listed in .python_version. The version listed first is the one that has been used during development.
If you simply want to create a virtual environment for the Python version installed on your sytem (supported are python 3.7, 3.8, 3.9 and 3.10), run the following command:
python -m venv .venv
Note
If you don’t have pip installed on your sytem, the command above might fail. In this case try:
python -m venv --without-pip .venv
curl https://bootstrap.pypa.io/get-pip.py | python
To activate the virtual environment run source .venv/bin/activate, to deactive it again run deactivate.
All the dependencies that are used for the experiments and during development are contained in requirements-dev.txt which is managed with the help of pip-tools).
It has been created from the dependencies of the package cxnminer given in setup.py and the additional dependencies given in requirements-dev.in and requirements-test.in using
pip-compile setup.py requirements-dev.in requirements-test.in --output-file requirements-dev.txt
Note
If pip-compile fails (No module named 'versioneer'), the
package cxnminer has to be installed into the environment first.
In order to do this make sure that a recent version of pip is installed
(> 20) and run pip install -e ..
The dependencies and the package cxnminer can be installed in your environment with the following commands:
pip install -r requirements-dev.txt
pip install -e .
Alternatively pip-sync (from pip-tools) can be used to assure that exactly (and only) the packages mentioned in requirements.txt are installed:
pip-sync requirements-dev.txt && pip install -e .
Makefile
The development environment can be managed using make. The contained Makefile uses Makefile.venv to create and update a virtual environment. The file contains the following targets:
- upgrade
Upgrade the dependencies (running the pip-compile commands with –upgrade).
- test
Run the tests.
- docs
Build the documentation.
- coverage
Create coverage reports for the tests. A HTML report is created in the folder .coverage_html.
- badges
Create/ Update the badges for the documentation (prerequisite of the target docs).
Tests
Tests are run using pytest with tox handling tests for multiple python versions (3.7, 3.8, 3.9 and 3.10). The requirements that are used when running the tests, are given in requirements-test.txt which is managed with the help of pip-tools as well.
pip-compile setup.py requirements-test.in --output-file requirements-test.txt
Additionaly the environment dev uses the python version mainly used during development with the dependencies installed from requirements-dev.txt instead of requirements-test.txt.
Coverage reports are created using pytest-cov.:
pytest --cov=cxnminer
Documentation
The documentation is built using sphinx. The virtual environment containing sphinx and the other packages that are needed is handled by tox. The packages are defined in requirements-docs.txt which is managed with the help of pip-tools as well.
pip-compile requirements-docs.in --output-file requirements-docs.txt
To create the documentation run:
tox -e docs
The README file contains badges that are created using pybadges and coverage-badge.