Installation

Stable release

To install ErnosCube, run this command in your terminal:

pip install ErnosCube

This is the preferred method to install ErnosCube, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for ErnosCube can be downloaded from the Github repo.

You can either clone the public repository:

git clone git://github.com/andfranklin/ErnosCube

Or download the tarball:

curl  -OL https://github.com/andfranklin/ErnosCube/tarball/master

You can install ErnosCube once you have a copy of the source by:

pip install .

For Developers

First, create a virtual environment to isolate the packages that ErnosCube depends on from your globally installed packages. By doing this you can make changes without mucking up the installed version of the package.

python -m venv env

Then activate it. If you’re on Windows, run:

env\Scripts\activate.bat

If you’re on Unix or MacOS, run:

env/bin/activate

Finally, install the package in editable mode. When the virtual environemnt is activated any changes you make to the code will automatically be reflected in the installation.

pip install -e .

If desired you can install the dev, test, and doc requirements, respectivelly, by:

pip install -r requirements_dev.txt
pip install -r requirements_test.txt
pip install -r docs/requirements.txt

Finally, install the pre-commit hooks before commiting anything to ensure a smooth development process:

pre-commit install

Testing

To run tests:

pytest

To run a subset of tests

pytest <path/to/tests>

It’s possible to rerun test that failed first or only the tests that failed. These commands correspond to --failed-first (--ff) and --last-failed (--lf), respectively. If you are developing tests you can choose to run the new tests first with --new-first (--nf). To stop the test runner after the first failure use -x. To run tests in parallel use -n <number of jobs>.

By default, pytest captures anything that is printed during tests. This is nice because it keeps the screen clean when you’re running tests. If you want to output anything that is printed during the test use -s. Another useful command is --pdb. This opens a debugger right before the error in the test that failed. These pytest commands and many others can be specified at the command line by:

pytest <command>

See pytest for more information.

Coverage

To get a coverage report first make sure that pytestcov is installed. Then, use the command:

pytest --cov

To get a more detailed html coverage report:

pytest --cov --cov-report=html

While debugging tests it might be useful to use the flag --no-cov-on-fail to suppress coverage when a test is failing. To see more info about CL options:

pytest --help