This is a developer's guide to modifying and maintaining intervaltree.
Before running most make commands,
you will need to install pyenv and run make install-devtools.
This section describes those steps in detail.
To install pyenv, follow your preferred instructions at https://github.com/pyenv/pyenv/blob/master/README.md#installation including
- running the installer,
- the modifications to your shell's rc file, and
- restarting your shell.
This section creates the virtual environments necessary for testing intervaltree
in all the supported versions of Python, locally.
If certain libraries and headers are present, pyenv will compile the Python interpreters with the associated support. Note that as we go back in Python version history, support for the latest libraries declines. Incompatible libraries will be ignored, rather than break compilation.
If readline is provided, this provides autocomplete and advanced history support
when the interpreters are run interactively.
On systems using dnf, readline-devel also includes ncurses-devel.
apt-get install libreadline-dev libncurses5-dev
# OR
dnf install readline-develMore information about suggested packages is listed at https://github.com/pyenv/pyenv/wiki#suggested-build-environment
To install the Python versions and dev tools:
make install-devtoolsThis does the following:
- Uses pyenv to download (and if no binary is hosted, compile) all the Python interpreters which we test under.
- Creates Python virtual environments under the venv directory.
- Installs the needed packages in each venv for testing and deployment.
To run the tests in the test directory, run
make testor simply
makeThe two commands above run all the available tests on all versions of Python supported.
Running all tests requires that all the supported versions of Python installed.
These can be viewed with make env.
Run
make quicktestTo clean up the project directory, run
make distcleanThat should remove all the locally-installed dependencies and clear out all the temporary files.
You will need to restore the virtual envs with make install-devtools.
To keep the virtual envs, but clean everything else, run
make cleanTo publish a new version to Test PyPI, run
make uploadThis will run make test,
build the source and wheel distributions,
and push them to the PyPI test server.
You can test your deploy in a fresh virtual env:
python -m venv venv/testpypi
source venv/testpypi/bin/activate
make install-testpypi
python -c 'from intervaltree import IntervalTree; IntervalTree()'If this looks like it went well, run
make prod uploadto push the distribution to the production PyPI server.
You can delete your virtual env when you are done with it:
rm -rf venv/testpypiThe intervaltree directory has three main files:
intervaltree.pyinterval.pynode.py
intervaltree.py and interval.py contain the public API to IntervalTree and Interval. node.py contains the internal logic of the tree. For the theory of how this type of tree works, read the following:
- Wikipedia's Interval tree article
- Eternally Confuzzled's tutorial on AVL balancing
- Tyler Kahn's simpler, immutable interval tree implementation in Python
All files ending with _test.py are detected and run whenever you run make or make quicktest. In those files, only functions beginning with test_ are executed.
Some tests depend on having certain lists of Intervals. These are stored in the modules of test/data. Most of these modules only contain a data attribute, which is a list of tuples that is converted to a list of Intervals by test/intervals.py. You can access them by importing the dict of lists of Intervals test.intervals.ivs.
Other tests (like test/issue25_test.py) depend on having pre-constructed IntervalTrees. These are constructed by test/intervaltrees.py and can be accessed by importing test.intervaltrees.trees. This is a dict of callables that return IntervalTrees.
HACKING.mdis this file.README.mdcontains public API documentation and credits.CHANGELOG.mdLICENSE.txt
Makefilecontains convenience routines for managing and testing the project.pyproject.tomlconfigures howintervaltreegets built and deployed.