From 7f5869d5aadd7099fcc93c578ccf22eb3b20ad0b Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 20 Nov 2026 01:08:02 -0600 Subject: [PATCH 1/4] Require python-graphblas 2026.11.0 and scipy The floor said >=2023.1.0. It is now 2026.11.0, the release this package is developed against, which lifts the suitesparse-graphblas <10 cap of 2025.2.0, whose 9.x builds stop at Python 3.13. graphblas.io.from_networkx builds a scipy sparse array first, so every call dispatched on a NetworkX graph needs scipy, which this package did not declare. scipy is now a dependency, at 1.11.2: the floor NetworkX 3.6.1 declares, which is above python-graphblas's own (1.9). The test extra's scipy floor rises to match. The README says why scipy is needed. --- README.md | 4 ++++ pyproject.toml | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b2972a..618a61c 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,10 @@ conda install -c conda-forge graphblas-algorithms pip install graphblas-algorithms ``` +graphblas-algorithms depends on scipy: python-graphblas converts a NetworkX graph through a scipy +sparse array, and `adjacency_matrix`, `laplacian_matrix`, `normalized_laplacian_matrix`, +`bethe_hessian_matrix` and `tournament_matrix` return scipy sparse arrays. + ## Basic Usage First, create a GraphBLAS Matrix. diff --git a/pyproject.toml b/pyproject.toml index 011eb5f..188cd20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,9 @@ classifiers = [ "Topic :: Scientific/Engineering :: Physics", "Topic :: Software Development :: Libraries :: Python Modules", ] -dependencies = ["python-graphblas >=2023.1.0"] +# python-graphblas converts a NetworkX graph through a scipy sparse array. 1.11.2 is the scipy +# floor NetworkX 3.6.1 declares, above python-graphblas's own. +dependencies = ["python-graphblas >=2026.11.0", "scipy >=1.11.2"] [project.entry-points."networkx.backends"] graphblas = "graphblas_algorithms.interface:Dispatcher" @@ -75,7 +77,7 @@ test = [ "pytest-xdist", "networkx >=3.6", "rich", # scripts/maketree.py, which the generated-code freshness test runs - "scipy >=1.9", + "scipy >=1.11.2", "setuptools", ] all = ["graphblas-algorithms[test]"] From a6e321b3e9bb24e057cba362e0ffe11e5f9b5bea Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 20 Nov 2026 01:08:03 -0600 Subject: [PATCH 2/4] Test Python 3.14 and 3.15 against NetworkX 3.6.1 and the latest release The pytest matrix gains Python 3.14 and 3.15 and a NetworkX axis: 3.6.1, the last patch of the oldest NetworkX this backend supports, and the newest on conda-forge, which warns when a NetworkX release changes what the backend meets. Python 3.11 runs 3.6.1 only, since NetworkX 3.7 requires Python 3.12 and "latest" would install 3.6.1 again. The two extra architectures take Python 3.13 and NetworkX 3.6.1. The comment about installing other NetworkX versions by hand goes. The NetworkX suite job runs on both NetworkX versions, still advisory, and its summary and annotation name the version. The cells are renamed "pytest (os, pyX, nxY)". The package declares Python 3.14 and 3.15. black targets 3.14 but not yet 3.15, as in python-graphblas: a black that does not know py315 refuses to run on the project, and conda-forge's black for Python 3.15 is still one. --- .github/workflows/test.yml | 40 ++++++++++++++++++++++++++++---------- pyproject.toml | 7 ++++++- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a0bcbc..19b4616 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ permissions: jobs: test: - name: pytest (${{ matrix.os }}, ${{ matrix.python-version }}) + name: pytest (${{ matrix.os }}, py${{ matrix.python-version }}, nx${{ matrix.networkx-version }}) runs-on: ${{ matrix.os }} defaults: run: @@ -20,13 +20,21 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest", "macos-latest", "windows-latest"] - python-version: ["3.11", "3.12", "3.13"] + python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"] + # The NetworkX floor (3.6, at its last patch) and the newest release. + networkx-version: ["3.6.1", "latest"] + exclude: + # NetworkX 3.7 requires Python 3.12, so "latest" would be 3.6.1 again. + - python-version: "3.11" + networkx-version: "latest" include: # Additional architectures, at one Python version to limit the cost. - os: macos-15-intel python-version: "3.13" + networkx-version: "3.6.1" - os: ubuntu-24.04-arm python-version: "3.13" + networkx-version: "3.6.1" steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -58,13 +66,16 @@ jobs: activate-environment: graphblas - name: Install dependencies run: | + if [ "${{ matrix.networkx-version }}" = "latest" ]; then + nx=networkx + else + nx=networkx=${{ matrix.networkx-version }} + fi # conda, not mamba: on Windows the action's bash wrapper for mamba runs `cmd.exe /C`, # which Git Bash rewrites to `cmd.exe C:/`, so the install silently does nothing. conda install python-suitesparse-graphblas scipy pandas donfig pyyaml numpy python-graphblas \ - pytest-cov pytest-randomly pytest-xdist networkx rich setuptools + pytest-cov pytest-randomly pytest-xdist "$nx" rich setuptools # matplotlib lxml pygraphviz pydot sympy # Extra networkx deps we don't need yet - # Sometimes we prefer to use the latest release of NetworkX or the latest development from github - # pip install git+https://github.com/networkx/networkx.git@main --no-deps pip install -e . --no-deps - name: pytest run: | @@ -76,12 +87,16 @@ jobs: uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 networkx: - # One cell, since the suite is slow and tests the dispatch layer, not the platform. - name: NetworkX suite through the backend + # Linux and Python 3.13 only: the suite is slow and tests the dispatch layer, not the platform. + name: NetworkX suite through the backend (nx${{ matrix.networkx-version }}) runs-on: ubuntu-latest defaults: run: shell: bash -l {0} + strategy: + fail-fast: false + matrix: + networkx-version: ["3.6.1", "latest"] steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -112,9 +127,14 @@ jobs: activate-environment: graphblas - name: Install dependencies run: | + if [ "${{ matrix.networkx-version }}" = "latest" ]; then + nx=networkx + else + nx=networkx=${{ matrix.networkx-version }} + fi # pytest-mpl brings matplotlib, which NetworkX's drawing tests need. conda install python-suitesparse-graphblas scipy pandas donfig pyyaml numpy python-graphblas \ - pytest-cov pytest-randomly pytest-mpl pytest-xdist networkx + pytest-cov pytest-randomly pytest-mpl pytest-xdist "$nx" pip install -e . --no-deps - name: NetworkX test suite id: nx_suite @@ -133,14 +153,14 @@ jobs: summary=$(tail -n 1 nx-suite.log 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g') summary=${summary:-"the suite produced no output"} { - echo "### NetworkX suite through this backend" + echo "### NetworkX suite through this backend, on networkx ${{ matrix.networkx-version }}" echo echo '```' echo "$summary" echo '```' } >> "$GITHUB_STEP_SUMMARY" if [ "$SUITE_OUTCOME" != "success" ]; then - echo "::warning::NetworkX suite did not pass: $summary" + echo "::warning::NetworkX suite did not pass on networkx ${{ matrix.networkx-version }}: $summary" fi - name: Coverage uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 diff --git a/pyproject.toml b/pyproject.toml index 188cd20..a54cfe5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,8 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.15", "Programming Language :: Python :: 3 :: Only", "Intended Audience :: Developers", "Intended Audience :: Other Audience", @@ -127,7 +129,10 @@ dirty_template = "{tag}+{ccount}.g{sha}.dirty" [tool.black] line-length = 100 -target-version = ["py311", "py312", "py313"] +# No "py315" yet, as in python-graphblas: a black that does not know a listed version refuses +# to run on this project, and conda-forge's black for Python 3.15 is still 26.1 (black 26.5, the +# first to know py315, needs a pytokens with no 3.15 build there as of 2026-11). +target-version = ["py311", "py312", "py313", "py314"] [tool.isort] sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"] From 117a5998974743d251a4121a1ab53ed24689c21a Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 20 Nov 2026 01:08:03 -0600 Subject: [PATCH 3/4] Publish to PyPI with a trusted publisher The publish job uploaded with an API token stored as a repository secret. With trusted publishing a job mints a short-lived OIDC token (id-token: write) that PyPI exchanges for upload rights, so there is no long-lived credential to leak or rotate. The upload moves to a job of its own, which downloads the built files and is the only one allowed to mint the token; the build job, which installs and runs build and twine, is not. The upload job declares the environment pypi for the registration to name. The registration is made on PyPI, not here; a tag pushed before it exists fails at the upload. --- .github/workflows/publish_pypi.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 8fbb4e7..749c9fa 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -9,7 +9,7 @@ permissions: contents: read jobs: - build_and_deploy: + build: runs-on: ubuntu-latest if: github.repository == 'python-graphblas/graphblas-algorithms' defaults: @@ -38,8 +38,19 @@ jobs: if-no-files-found: error - name: Check with twine run: python -m twine check --strict dist/* + + publish: + needs: build + runs-on: ubuntu-latest + # The trusted-publisher registration on PyPI names this environment. + environment: pypi + permissions: + # Only this job can mint the OIDC token that PyPI exchanges for upload rights. + id-token: write + steps: + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: releases + path: dist - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} # zizmor: ignore[use-trusted-publishing] From 5258588128746f0f2bd8f7baef45ae8059cb944e Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 20 Nov 2026 01:08:03 -0600 Subject: [PATCH 4/4] Pass a Codecov token, and skip coverage uploads under act Codecov takes uploads without a token from forks, not from this repository's own branches. Both coverage steps now pass the CODECOV_TOKEN secret; until the secret exists they behave as before. act, which runs these workflows locally, sets ACT and GitHub does not. Both coverage steps are skipped when it is set, so a local run uploads no report. --- .github/workflows/test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 19b4616..f7c8151 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -83,8 +83,12 @@ jobs: coverage run --branch -m pytest --color=yes -v coverage report coverage xml + # act, which runs these workflows locally, sets ACT; GitHub does not. - name: Coverage + if: ${{ !env.ACT }} uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} networkx: # Linux and Python 3.13 only: the suite is slow and tests the dispatch layer, not the platform. @@ -163,4 +167,7 @@ jobs: echo "::warning::NetworkX suite did not pass on networkx ${{ matrix.networkx-version }}: $summary" fi - name: Coverage + if: ${{ !env.ACT }} uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 + with: + token: ${{ secrets.CODECOV_TOKEN }}