Skip to content
Merged

02 ci #101

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
19 changes: 15 additions & 4 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions:
contents: read

jobs:
build_and_deploy:
build:
runs-on: ubuntu-latest
if: github.repository == 'python-graphblas/graphblas-algorithms'
defaults:
Expand Down Expand Up @@ -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]
47 changes: 37 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -58,30 +66,41 @@ 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: |
python -c 'import sys, graphblas_algorithms; assert "networkx" not in sys.modules'
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
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 10 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand All @@ -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]"]
Expand Down Expand Up @@ -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"]
Expand Down
Loading