Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .ackrc

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,18 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

pip-install-local:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.14
uses: actions/setup-python@v6
with:
python-version: 3.14
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Test pip install
run: |
pip install .
python -c 'from intervaltree import IntervalTree; t = IntervalTree(); print(t)'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pyandoc/
pandoc
docutils/
bin/
venv/

# Developer eggs
*.egg-info
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
# Change log

## Version 3.2.1
- Fixed:
- Build system includes sortedcontainers dependency in the wheel again
- Maintainers:
- Local testing happens inside virtual environments,
instead of in the system-installed Python environment.
- Add uv-dynamic-versioning.
This generates automatic version numbers for test.pypi.org,
based on the distance from the last tag version.
- CI tests "pip install ."
- Updated Makefile
- Updated HACKING.md

## Version 3.2.0
BROKEN: missing sortedcontainers dependency from wheel
- Added:
- Add support for Python 3.9 - 3.14
- `pyproject.toml`, which modernizes the build and dependency system.
- `requirements/*.txt`: If you are not using `pyproject.toml`,
use `pip install -r` on `requirements/common.txt`
Expand Down
202 changes: 115 additions & 87 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,152 +5,180 @@ This is a developer's guide to modifying and maintaining `intervaltree`.

## Dependencies

* On a Mac, you will need [`brew`][brew].
Before running most `make` commands,
you will need to [install pyenv] and run `make install-devtools`.
This section describes those steps in detail.

* On Linux, you will need `apt-get`.
### Pyenv

On all systems, Python 2.6, 2.7, 3.2, 3.3, 3.4 and 3.5 are needed to run the complete test suite.
To install pyenv, follow your preferred instructions at
https://github.com/pyenv/pyenv/blob/master/README.md#installation
including

### Single version of Python

If you don't have all the above versions of Python, these `make` features will be unavailable to you:
1. running the installer,
2. the modifications to your shell's rc file, and
3. restarting your shell.

* `make` and `make test`
* `make pytest`
* `make upload` and `make release upload`

### Set up the virtual environments (venv directory)

## Project structure
This section creates the virtual environments necessary for testing `intervaltree`
in all the supported versions of Python, locally.

### `intervaltree`
#### Optional: Compiling Python with third-party libraries

The `intervaltree` directory has three main files:
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.

* `intervaltree.py`
* `interval.py`
* `node.py`
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.

`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:
```bash
apt-get install libreadline-dev libncurses5-dev
# OR
dnf install readline-devel
```

* Wikipedia's [Interval tree][Wiki intervaltree] article
* Eternally Confuzzled's tutorial on [AVL balancing][Confuzzled AVL tree]
* Tyler Kahn's simpler, immutable [interval tree implementation][Kahn intervaltree] in Python

### `test`
More information about suggested packages is listed at
https://github.com/pyenv/pyenv/wiki#suggested-build-environment

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.
#### Install Python versions and dev tools

#### `test/data`
Some tests depend on having certain lists of `Interval`s. 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 `Interval`s by `test/intervals.py`. You can access them by importing the dict of lists of `Interval`s `test.intervals.ivs`.
To install the Python versions and dev tools:

Other tests (like `test/issue25_test.py`) depend on having pre-constructed `IntervalTree`s. These are constructed by `test/intervaltrees.py` and can be accessed by importing `test.intervaltrees.trees`. This is a dict of callables that return `IntervalTree`s.
```bash
make install-devtools
```

### `scripts`
This does the following:

Contains `testall.sh`, which runs all tests on all supported versions of Python.
1. Uses pyenv to download (and if no binary is hosted, compile)
all the Python interpreters which we test under.
2. Creates Python virtual environments under the venv directory.
3. Installs the needed packages in each venv for testing and deployment.

### Dependency folders

* `pyandoc` and `pandoc` give the ability to convert README.md into rst format for PyPI.
* `docutils` and `bin` are created if `pip` could not install them system-wide without permissions. These are used to check the syntax of the converted rst README.
* `*.egg` are created by `PyTest` to fulfill testing dependencies
* `intervaltree.egg-info` is package metadata generated by `setup.py`.

### Other documentation files

* `HACKING.md` is this file.
* `README.md` contains public API documentation and credits.
* `README.rst` is generated from `README.md`.
* `CHANGELOG.md`
* `LICENSE.txt`
## Testing

### Other code files
To run the tests in the `test` directory, run

* `Makefile` contains convenience routines for managing and testing the project. It installs certain dependencies that are too inconvenient to install on [travis-ci.org][], and gives an easy way to call `test/testall.sh`.
* `setup.py` runs the tests in a single version of Python. Also, packages the project for PyPI.
* `setup.cfg` configures `setup.py`. If you want to permanently skip a folder in testing, do it here.
```bash
make test
```

or simply

## Testing
```bash
make
```

### Code
The two commands above run all the available tests on all versions of Python supported.

To run the tests in the `test` directory, run
Running all tests requires that all the supported versions of Python installed.
These can be viewed with `make env`.

make test
### Single version of Python

or simply
Run

make
```bash
make quicktest
```

The two commands above run all the available tests on all versions of Python supported. You should run `make` first, because it will also detect missing dependencies and install them.
## Cleaning

The first time you run `make`, you may be asked for your password. This is in order to install `pandoc`, a tool used for processing the README file.
To clean up the project directory, run

Running all tests requires that you have all the supported versions of Python installed. These are 2.6, 2.7, 3.2, 3.3, 3.4 and 3.5. Try to use your package manager to install them if possible. Otherwise, go to [python.org/downloads][] and install them manually.
```bash
make distclean
```

#### Single version of Python
That 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`.

Run
To keep the virtual envs, but clean everything else, run

make quicktest
```bash
make clean
```

### README
## Maintainers: Working with PyPI

To test changes to the README and make sure that they are compatible with PyPI's very restrictive rules, run
To publish a new version to Test PyPI, run

make rst
```bash
make upload
```

`make rst` is also run by `make test`, but `make test` takes longer.
This 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:

## Cleaning
```bash
python -m venv venv/testpypi
source venv/testpypi/bin/activate
make install-testpypi
python -c 'from intervaltree import IntervalTree; IntervalTree()'
```

To clean up the project directory, run

make distclean

That should remove all the locally-installed dependencies and clear out all the temporary files.
If this looks like it went well, run

To keep the dependencies, but clean everything else, run
```bash
make prod upload
```

make clean
to push the distribution to the production PyPI server.

You can delete your virtual env when you are done with it:

## Maintainers: Working with PyPI
```bash
rm -rf venv/testpypi
```

### README
## Project structure

To update the README on PyPI, run
### `intervaltree`

make register
The `intervaltree` directory has three main files:

This will test the README's syntax strictly and push it up to the PyPI test server.
If you are satisfied with the results, run
* `intervaltree.py`
* `interval.py`
* `node.py`

make release register
`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:

to do it for real on the production PyPI server.
* Wikipedia's [Interval tree][Wiki intervaltree] article
* Eternally Confuzzled's tutorial on [AVL balancing][Confuzzled AVL tree]
* Tyler Kahn's simpler, immutable [interval tree implementation][Kahn intervaltree] in Python

### Publishing
### `test`

To publish a new version to PyPI, run
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.

make upload
#### `test/data`
Some tests depend on having certain lists of `Interval`s. 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 `Interval`s by `test/intervals.py`. You can access them by importing the dict of lists of `Interval`s `test.intervals.ivs`.

This will run `make test`, zip up the source distribution and push it to the PyPI test server.
Other tests (like `test/issue25_test.py`) depend on having pre-constructed `IntervalTree`s. These are constructed by `test/intervaltrees.py` and can be accessed by importing `test.intervaltrees.trees`. This is a dict of callables that return `IntervalTree`s.

If this looks like it went well, run
### Documentation files

make release upload
* `HACKING.md` is this file.
* `README.md` contains public API documentation and credits.
* `CHANGELOG.md`
* `LICENSE.txt`

to push the distribution to the production PyPI server.
### Other code files

* `Makefile` contains convenience routines for managing and testing the project.
* `pyproject.toml` configures how `intervaltree` gets built and deployed.

[brew]: http://brew.sh/
[install pyenv]: https://github.com/pyenv/pyenv/blob/master/README.md#installation
[python.org/downloads]: http://www.python.org/downloads
[travis-ci.org]: https://travis-ci.org/
[Confuzzled AVL tree]: http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_avl.aspx
[Wiki intervaltree]: http://en.wikipedia.org/wiki/Interval_tree
[Kahn intervaltree]: http://zurb.com/forrst/posts/Interval_Tree_implementation_in_python-e0K
Loading