From 67abe6ba47f9d104adc1bebbdddc384e0a02df81 Mon Sep 17 00:00:00 2001 From: Ben Jeffery Date: Mon, 24 Jun 2024 10:16:56 +0100 Subject: [PATCH] Upgrade actions infrastructure, numpy2 support, osx ARM wheels. --- .circleci/config.yml | 3 +- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 22 ++-- .github/workflows/wheels.yml | 108 ++++++++++++------ .mergify.yml | 24 ++-- python/CHANGELOG.rst | 7 +- python/pyproject.toml | 53 ++++++++- python/requirements/CI/tests/requirements.txt | 2 + python/setup.cfg | 50 -------- python/setup.py | 14 --- 10 files changed, 154 insertions(+), 131 deletions(-) delete mode 100644 python/setup.cfg diff --git a/.circleci/config.yml b/.circleci/config.yml index 1c409fc..2e56817 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ orbs: jobs: build: docker: - - image: cimg/python:3.8 + - image: cimg/python:3.9 steps: - checkout - run: @@ -16,7 +16,6 @@ jobs: sudo apt-get install -y ninja-build libcunit1-dev valgrind clang doxygen python3-pip # Install meson as root so we can install to the system below. sudo pip install meson - pip install numpy==1.18.5 pip install --user -r python/requirements/development.txt echo 'export PATH=/home/circleci/.local/bin:$PATH' >> $BASH_ENV - run: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 163c373..2fbb79a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install dependencies and set path run: | sudo apt-get update diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2a860d2..d11006b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.6.0 + uses: styfle/cancel-workflow-action@0.12.1 with: access_token: ${{ github.token }} - uses: actions/checkout@v3 @@ -27,21 +27,21 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python: [ 3.8, 3.11 ] + python: [ 3.9, 3.12 ] os: [ macos-latest, ubuntu-latest, windows-latest ] defaults: run: shell: bash steps: - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.6.0 + uses: styfle/cancel-workflow-action@0.12.1 with: access_token: ${{ github.token }} - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: ${{matrix.python}} @@ -51,9 +51,15 @@ jobs: - name: Build module working-directory: python run: | - python setup.py build_ext --inplace + python -m build + python -m pip install dist/*.whl - name: Run tests - working-directory: python run: | - python -m pytest tests + python -m pytest python/tests + + - name: Run tests (numpy < 2) + run: | + pip install setuptools + pip install "numpy<2" + python -m pytest python/tests diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index c088055..6fff38b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -15,11 +15,11 @@ jobs: runs-on: windows-latest strategy: matrix: - python: [3.8, 3.9, "3.10", 3.11] + python: [3.9, "3.10", 3.11, 3.12] wordsize: [64] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Build wheel env: PYTHON: "py -${{ matrix.python }}-${{ matrix.wordsize }}" @@ -49,21 +49,21 @@ jobs: rm -rf python/kastore python/*.pyd ${PYTHON} -m pytest -v python - name: Upload Wheels - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: win-wheel-${{ matrix.python }}-${{ matrix.wordsize }} path: python/dist OSX: - runs-on: macos-latest + runs-on: macos-13 strategy: matrix: - python: [3.8, 3.9, "3.10", 3.11] + python: [3.9, "3.10", 3.11, 3.12] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - name: Build Wheel @@ -82,21 +82,55 @@ jobs: rm -rf python/kastore python/*.so python -m pytest -v python - name: Upload Wheels - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: osx-wheel-${{ matrix.python }} path: python/dist + OSX-ARM: + runs-on: macos-14 + strategy: + matrix: + python: [3.9, "3.10", 3.11, 3.12] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: Build Wheel + run: | + cd python + python -m pip install build + python -m build --wheel + - name: Install wheel and run tests + run: | + # We install in this odd way to make sure we get both deps and a local kastore + pip install kastore --only-binary kastore -f python/dist/ + pip uninstall -y kastore + pip install -v kastore --only-binary kastore -f python/dist/ --no-index + python -c "import kastore" + pip install -r python/requirements/CI/tests/requirements.txt + rm -rf python/kastore python/*.so + python -m pytest -v python + - name: Upload Wheels + uses: actions/upload-artifact@v4 + with: + name: osxarm-wheel-${{ matrix.python }} + path: python/dist + + manylinux: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: 3.9 - name: Build sdist shell: bash @@ -106,7 +140,7 @@ jobs: python setup.py sdist - name: Upload sdist - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: sdist path: python/dist @@ -116,12 +150,12 @@ jobs: run: | docker run --rm -v `pwd`:/project -w /project quay.io/pypa/manylinux2014_x86_64 bash docker/buildwheel.sh - - name: Set up Python 3.11 - uses: actions/setup-python@v2 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 with: - python-version: 3.11 + python-version: 3.12 - - name: Run tests (3.11) + - name: Run tests (3.12) run: | python -VV # We install in this odd way to make sure we get both deps and a local kastore @@ -132,12 +166,12 @@ jobs: pip install -r python/requirements/CI/tests/requirements.txt python -m pytest -v python - - name: Set up Python 3.10 - uses: actions/setup-python@v2 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: 3.12 - - name: Run tests (3.10) + - name: Run tests (3.11) run: | python -VV # We install in this odd way to make sure we get both deps and a local kastore @@ -148,12 +182,12 @@ jobs: pip install -r python/requirements/CI/tests/requirements.txt python -m pytest -v python - - name: Set up Python 3.9 - uses: actions/setup-python@v2 + - name: Set up Python 3.10 + uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: "3.10" - - name: Run tests (3.9) + - name: Run tests (3.10) run: | python -VV # We install in this odd way to make sure we get both deps and a local kastore @@ -164,12 +198,12 @@ jobs: pip install -r python/requirements/CI/tests/requirements.txt python -m pytest -v python - - name: Set up Python 3.8 - uses: actions/setup-python@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.9 - - name: Run tests (3.8) + - name: Run tests (3.9) run: | python -VV # We install in this odd way to make sure we get both deps and a local kastore @@ -181,7 +215,7 @@ jobs: python -m pytest -v python - name: Upload Wheels - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: linux-wheels path: python/dist/wheelhouse @@ -189,22 +223,22 @@ jobs: PyPI_Upload: runs-on: ubuntu-latest - needs: ['windows', 'OSX', 'manylinux'] + environment: release + needs: ['windows', 'OSX-ARM', 'manylinux'] + permissions: + id-token: write steps: - name: Download all - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 - name: Move to dist run: | mkdir dist cp */*.{whl,gz} dist/. - name: Publish distribution to Test PyPI if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && !contains(github.event.ref, 'C_') - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ secrets.test_pypi_password }} repository_url: https://test.pypi.org/legacy/ - name: Publish distribution to PRODUCTION PyPI if: github.event_name == 'release' && !startsWith(github.event.release.tag_name, 'C_') - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.pypi_password }} + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.mergify.yml b/.mergify.yml index a31212e..bae7a5b 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -4,12 +4,12 @@ queue_rules: - "#approved-reviews-by>=1" - "#changes-requested-reviews-by=0" - status-success=Lint - - status-success=Python (3.8, macos-latest) - - status-success=Python (3.11, macos-latest) - - status-success=Python (3.8, ubuntu-latest) - - status-success=Python (3.11, ubuntu-latest) - - status-success=Python (3.8, windows-latest) - - status-success=Python (3.11, windows-latest) + - status-success=Python (3.9, macos-latest) + - status-success=Python (3.12, macos-latest) + - status-success=Python (3.9, ubuntu-latest) + - status-success=Python (3.12, ubuntu-latest) + - status-success=Python (3.9, windows-latest) + - status-success=Python (3.12, windows-latest) - "status-success=ci/circleci: build" pull_request_rules: @@ -21,12 +21,12 @@ pull_request_rules: - base=main - label=AUTOMERGE-REQUESTED - status-success=Lint - - status-success=Python (3.8, macos-latest) - - status-success=Python (3.11, macos-latest) - - status-success=Python (3.8, ubuntu-latest) - - status-success=Python (3.11, ubuntu-latest) - - status-success=Python (3.8, windows-latest) - - status-success=Python (3.11, windows-latest) + - status-success=Python (3.9, macos-latest) + - status-success=Python (3.12, macos-latest) + - status-success=Python (3.9, ubuntu-latest) + - status-success=Python (3.12, ubuntu-latest) + - status-success=Python (3.9, windows-latest) + - status-success=Python (3.12, windows-latest) - "status-success=ci/circleci: build" actions: queue: diff --git a/python/CHANGELOG.rst b/python/CHANGELOG.rst index 0c9fa48..9155afb 100644 --- a/python/CHANGELOG.rst +++ b/python/CHANGELOG.rst @@ -1,8 +1,11 @@ -------------------- -[0.3.X] - 202X-XX-XX +[0.3.3] - 202X-XX-XX -------------------- -kastore now requires Python 3.8 or later. +Maintenance release: + +- Support for numpy 1.x and 2.x +- Require Python >= 3.9 -------------------- diff --git a/python/pyproject.toml b/python/pyproject.toml index 0d78818..4be328c 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,7 +1,50 @@ [build-system] -requires = [ - "setuptools>=42", - "wheel", - "oldest-supported-numpy" +requires = ["setuptools>=45", "wheel", "numpy>=2"] +build-backend = "setuptools.build_meta" + +[project] +name = "kastore" +dynamic = ["version"] +authors = [ + {name = "Tskit Developers", email = "admin@tskit.dev"}, ] -build-backend = "setuptools.build_meta" \ No newline at end of file +description = "A write-once-read-many store for simple numerical data" +readme = "README.md" +license = {text = "MIT"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Scientific/Engineering :: Bio-Informatics", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3 :: Only", +] +keywords = ["binary store", "numerical", "arrays"] +dependencies = [ + "numpy>=1.23.5", + "humanize", +] +requires-python = ">=3.9" + +[project.urls] +Homepage = "https://github.com/tskit-dev/kastore" +Documentation = "https://kastore.readthedocs.io/en/latest/" +Changelog = "https://kastore.readthedocs.io/en/latest/changelogs.html" +"Bug Tracker" = "https://github.com/tskit-dev/kastore/issues" +GitHub = "https://github.com/tskit-dev/kastore" + +[project.scripts] +kastore = "kastore.__main__:main" + +[tool.setuptools] +packages = ["kastore"] + +[tool.setuptools.dynamic] +version = {attr = "kastore._version.kastore_version"} + +[tool.pytest.ini_options] +testpaths = ["tests"] \ No newline at end of file diff --git a/python/requirements/CI/tests/requirements.txt b/python/requirements/CI/tests/requirements.txt index b56fd81..12d0c96 100644 --- a/python/requirements/CI/tests/requirements.txt +++ b/python/requirements/CI/tests/requirements.txt @@ -1,7 +1,9 @@ attrs +build hypothesis humanize pytest pytest-cov numpy mock +setuptools \ No newline at end of file diff --git a/python/setup.cfg b/python/setup.cfg deleted file mode 100644 index 73e2279..0000000 --- a/python/setup.cfg +++ /dev/null @@ -1,50 +0,0 @@ -[metadata] -name = kastore -author = Tskit Developers -author_email = admin@tskit.dev -license = MIT -# NOTE: description *must* be on one line. -description = A write-once-read-many store for simple numerical data -long_description_content_type = text/markdown -long_description = file: README.md -url = https://github.com/tskit-dev/kastore -project_urls = - Documentation = https://kastore.readthedocs.io/en/latest/ - Changelog = https://kastore.readthedocs.io/en/latest/changelogs.html - Bug Tracker = https://github.com/tskit-dev/kastore/issues - GitHub = https://github.com/tskit-dev/kastore -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Topic :: Scientific/Engineering :: Bio-Informatics - License :: OSI Approved :: MIT License - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3 :: Only -keywords = - binary store - numerical - arrays -platforms = - POSIX - Windows - MacOS X - -[options] -packages = kastore -python_requires = >=3.8 -include_package_data = True -install_requires = - numpy>=1.7 - humanize - -[options.entry_points] -console_scripts = - kastore=kastore.__main__:main - -[tool:pytest] -testpaths = - tests diff --git a/python/setup.py b/python/setup.py index e75299d..ec55df7 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,10 +1,7 @@ -import os.path - import numpy from setuptools import Extension from setuptools import setup - _kastore_module = Extension( "_kastore", sources=["_kastoremodule.c", "lib/kastore.c"], @@ -12,17 +9,6 @@ include_dirs=["lib", numpy.get_include()], ) - -# After exec'ing this file we have kastore_version defined. -kastore_version = None # Keep PEP8 happy. -version_file = os.path.join("kastore", "_version.py") -with open(version_file) as f: - exec(f.read()) - setup( - # The package name along with all the other metadata is specified in setup.cfg - # However, GitHub's dependency graph can't see the package unless we put this here. - name="kastore", - version=kastore_version, ext_modules=[_kastore_module], )