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] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a0bcbc..f7c8151 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: | @@ -72,16 +83,24 @@ 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: - # 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 +131,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 +157,17 @@ 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 + if: ${{ !env.ACT }} uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} 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..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", @@ -55,7 +57,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 +79,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]"] @@ -125,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"]