diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml deleted file mode 100644 index ee9f72b..0000000 --- a/.github/workflows/manual.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: ci - -on: - push: - branches: - - "master" - -env: - TEST_TAG: ${{ secrets.DOCKERHUB_USERNAME }}/intervaltree:test - LATEST_TAG: ${{ secrets.DOCKERHUB_USERNAME }}/intervaltree:latest - -jobs: - build: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Build and export to Docker - uses: docker/build-push-action@v4 - with: - context: . - file: ./Dockerfile - load: true - tags: ${{ env.TEST_TAG }} - - - name: Test - run: docker run --rm ${{ env.TEST_TAG }} - - - name: Build and push - uses: docker/build-push-action@v4 - with: - context: . - file: ./Dockerfile - push: true - tags: ${{ env.LATEST_TAG }} - diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..fc7da39 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,98 @@ +# This workflow will install Python dependencies, lint, and run tests in supported versions of Python. +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: tests + +on: + push: + branches: [ "master", "gha" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + + pytest: + strategy: + matrix: + python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14.0-alpha.5"] + include: + - python-version: "3.5" + os: ubuntu-20.04 + - python-version: "3.6" + os: ubuntu-20.04 + - python-version: "3.7" + os: ubuntu-22.04 + - python-version: "3.8" + os: ubuntu-24.04 + - python-version: "3.9" + os: ubuntu-24.04 + - python-version: "3.10" + os: ubuntu-24.04 + - python-version: "3.11" + os: ubuntu-24.04 + - python-version: "3.12" + os: ubuntu-24.04 + - python-version: "3.13" + os: ubuntu-24.04 + - python-version: "3.14.0-alpha.5" + os: ubuntu-24.04 + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + env: + PIP_TRUSTED_HOST: "pypi.python.org pypi.org files.pythonhosted.org" + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements/pytest.txt + - name: Test with pytest + run: | + coverage run -m pytest + coverage report -m + + pytest-python27: + runs-on: ubuntu-latest + container: coatldev/six:latest + steps: + - uses: actions/checkout@v4 + - name: Display Python version + run: python2 -c "import sys; print(sys.version)" + - name: Install dependencies + run: | + python2 -m pip install --upgrade pip + pip2 install -r requirements/pytest.txt + - name: Test with pytest + run: | + coverage2 run -m pytest + coverage2 report -m + + flake8: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.13 + uses: actions/setup-python@v5 + with: + python-version: 3.13 + - name: Display Python verison + run: python -c "import sys; print(sys.version)" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements/flake8.txt + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # 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 + diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 1b7e32a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,137 +0,0 @@ -# Modified by chaimleib March 2023 from -# https://github.com/vicamo/docker-pyenv/blob/main/alpine/Dockerfile -# -# Changes: -# * customize the versions of python installed -# * remove the dependency on github.com/momo-lab/xxenv-latest -# * forbid failures when building python -# * add other tools like parallel -# * run intervaltree tests - -FROM alpine:latest AS base - -ENV PYENV_ROOT="/opt/pyenv" -ENV PYENV_SHELL="bash" -ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:$PATH" - -# http://bugs.python.org/issue19846 -# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. -ENV LANG C.UTF-8 - -# runtime dependencies -RUN set -eux; \ - apk update; \ - apk add --no-cache \ - bash \ - build-base \ - bzip2 \ - ca-certificates \ - curl \ - expat \ - git \ - libffi \ - mpdecimal \ - ncurses-libs \ - openssl \ - parallel \ - readline \ - sqlite-libs \ - tk \ - xz \ - zlib \ - ; - -RUN set -eux; \ - curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash; \ - pyenv update - -FROM base AS builder - -# runtime dependencies -RUN set -eux; \ - apk update; \ - apk add --no-cache \ - bzip2-dev \ - libffi-dev \ - ncurses-dev \ - openssl-dev \ - readline-dev \ - sqlite-dev \ - tk-dev \ - xz-dev \ - zlib-dev \ - ; - -FROM builder AS build-2.7.18 -RUN set -eux; pyenv install 2.7.18; \ - find ${PYENV_ROOT}/versions -depth \ - \( \ - \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ - -o \( -type f -a -name 'wininst-*.exe' \) \ - \) -exec rm -rf '{}' + - -FROM builder AS build-3.6.15 -RUN set -eux; pyenv install 3.6.15; \ - find ${PYENV_ROOT}/versions -depth \ - \( \ - \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ - -o \( -type f -a -name 'wininst-*.exe' \) \ - \) -exec rm -rf '{}' + - -FROM builder AS build-3.7.16 -RUN set -eux; pyenv install 3.7.16; \ - find ${PYENV_ROOT}/versions -depth \ - \( \ - \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ - -o \( -type f -a -name 'wininst-*.exe' \) \ - \) -exec rm -rf '{}' + - -FROM builder AS build-3.8.16 -RUN set -eux; pyenv install 3.8.16; \ - find ${PYENV_ROOT}/versions -depth \ - \( \ - \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ - -o \( -type f -a -name 'wininst-*.exe' \) \ - \) -exec rm -rf '{}' + - -FROM builder AS build-3.9.16 -RUN set -eux; pyenv install 3.9.16; \ - find ${PYENV_ROOT}/versions -depth \ - \( \ - \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ - -o \( -type f -a -name 'wininst-*.exe' \) \ - \) -exec rm -rf '{}' + - -FROM builder AS build-3.10.10 -RUN set -eux; pyenv install 3.10.10; \ - find ${PYENV_ROOT}/versions -depth \ - \( \ - \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ - -o \( -type f -a -name 'wininst-*.exe' \) \ - \) -exec rm -rf '{}' + - -FROM builder AS build-3.11.2 -RUN set -eux; pyenv install 3.11.2; \ - find ${PYENV_ROOT}/versions -depth \ - \( \ - \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ - -o \( -type f -a -name 'wininst-*.exe' \) \ - \) -exec rm -rf '{}' + - -FROM base AS tester -COPY --from=build-2.7.18 /opt/pyenv/versions/2.7.18 /opt/pyenv/versions/2.7.18 -COPY --from=build-3.6.15 /opt/pyenv/versions/3.6.15 /opt/pyenv/versions/3.6.15 -COPY --from=build-3.7.16 /opt/pyenv/versions/3.7.16 /opt/pyenv/versions/3.7.16 -COPY --from=build-3.8.16 /opt/pyenv/versions/3.8.16 /opt/pyenv/versions/3.8.16 -COPY --from=build-3.9.16 /opt/pyenv/versions/3.9.16 /opt/pyenv/versions/3.9.16 -COPY --from=build-3.10.10 /opt/pyenv/versions/3.10.10 /opt/pyenv/versions/3.10.10 -COPY --from=build-3.11.2 /opt/pyenv/versions/3.11.2 /opt/pyenv/versions/3.11.2 - -RUN set -eux; \ - pyenv rehash; \ - pyenv versions - -WORKDIR /intervaltree -COPY . . -CMD [ "scripts/testall.sh" ] - diff --git a/MANIFEST.in b/MANIFEST.in index 260c74a..40d2b19 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ include README.md CHANGELOG.md LICENSE.txt -recursive-include test * +recursive-include test requirements diff --git a/README.md b/README.md index b7e24ae..985f9dc 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ pip install intervaltree Features -------- -* Supports Python 2.7 and Python 3.6+ (Tested under 2.7, and 3.6 thru 3.11) +* Supports Python 2.7 and Python 3.5+ (Tested under 2.7, and 3.5 thru 3.14) * Initializing * blank `tree = IntervalTree()` * from an iterable of `Interval` objects (`tree = IntervalTree(intervals)`) @@ -356,7 +356,7 @@ Based on Copyright --------- -* [Chaim Leib Halbert][GH], 2013-2023 +* [Chaim Leib Halbert][GH], 2013-2025 * Modifications, [Konstantin Tretyakov][Konstantin intervaltree], 2014 Licensed under the [Apache License, version 2.0][Apache]. @@ -364,7 +364,7 @@ Licensed under the [Apache License, version 2.0][Apache]. The source code for this project is at https://github.com/chaimleib/intervaltree -[build status badge]: https://github.com/chaimleib/intervaltree/workflows/ci/badge.svg +[build status badge]: https://github.com/chaimleib/intervaltree/workflows/tests/badge.svg [build status]: https://github.com/chaimleib/intervaltree/actions [GH]: https://github.com/chaimleib/intervaltree [issue tracker]: https://github.com/chaimleib/intervaltree/issues diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..db128d8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,49 @@ +[project] +name = "intervaltree" +description='Editable interval tree data structure for Python 2 and 3' +version = "3.2.0" +authors = [ + { name="Chaim Leib Halbert", email="chaim.leib.halbert@gmail.com" }, + { name="Konstantin Tretyakov" }, +] +readme = "README.md" +requires-python = ">= 2.7.18, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +license = "Apache-2.0" +keywords = ['interval-tree', 'data-structure', 'intervals', 'tree'] +classifiers = [ + 'Development Status :: 5 - Production/Stable', + 'Programming Language :: Python :: Implementation :: PyPy', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'Intended Audience :: Science/Research', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', + 'Programming Language :: Python :: 3.14', + 'License :: OSI Approved :: Apache Software License', + 'Topic :: Scientific/Engineering :: Artificial Intelligence', + 'Topic :: Scientific/Engineering :: Bio-Informatics', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Software Development :: Libraries', + 'Topic :: Text Processing :: General', + 'Topic :: Text Processing :: Linguistic', + 'Topic :: Text Processing :: Markup', +] + +[project.urls] +Homepage = "https://github.com/chaimleib/intervaltree" +Issues = "https://github.com/chaimleib/intervaltree/issues" + +[build-system] +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c58f7cb --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +-r requirements/common.txt diff --git a/requirements/common.txt b/requirements/common.txt new file mode 100644 index 0000000..1e73a3a --- /dev/null +++ b/requirements/common.txt @@ -0,0 +1 @@ +sortedcontainers==2.4.0 diff --git a/requirements/flake8.txt b/requirements/flake8.txt new file mode 100644 index 0000000..3930480 --- /dev/null +++ b/requirements/flake8.txt @@ -0,0 +1 @@ +flake8 diff --git a/requirements/pytest.txt b/requirements/pytest.txt new file mode 100644 index 0000000..5c843eb --- /dev/null +++ b/requirements/pytest.txt @@ -0,0 +1,3 @@ +-r common.txt +pytest +pytest-cov diff --git a/scripts/testall.sh b/scripts/testall.sh deleted file mode 100755 index 1364729..0000000 --- a/scripts/testall.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# Tests using `python setup.py test` using different versions of python. - -this_dir="$(dirname "$0")" -export base_dir="$(dirname "$this_dir")" - -set -x -code=0 -for ver in $(pyenv versions --bare | sort -V); do - pyenv global "$ver" - python --version - python "$base_dir/setup.py" test || code=1 -done -set +x -exit "$code" diff --git a/test/intervals.py b/test/intervals.py index 7c2612e..1be24cb 100644 --- a/test/intervals.py +++ b/test/intervals.py @@ -126,10 +126,10 @@ def trepr(s): pprint(data, f) -if __name__ == '__main__': +# if __name__ == '__main__': # ivs = gaps_rand() # write_ivs_data('ivs3', ivs, docstring=""" # Random integer ranges, with gaps. # """ # ) - pprint(ivs) + # pprint(ivs) diff --git a/test/optimality/optimality_test.py b/test/optimality/optimality_test.py index eb2223d..a9faacf 100644 --- a/test/optimality/optimality_test.py +++ b/test/optimality/optimality_test.py @@ -25,8 +25,10 @@ from test.optimality.optimality_test_matrix import OptimalityTestMatrix from test import data +from intervaltree import IntervalTree -matrix = OptimalityTestMatrix(verbose=1) + +matrix = OptimalityTestMatrix(verbose=True) matrix.run()