Skip to content

Commit

Permalink
Update9.1.0 (#128)
Browse files Browse the repository at this point in the history
* Update to SuiteSparse:GraphBLAS 9.1.0

* maybe fix? (path and extra constant)

* Update default include path to include "suitesparse"

* Try this

* Maybe don't need this anymore for arm on mac os

* Explicit macos x86 and arm runners

* Add dir dump

* Look in "/usr/local"

* Try installing to prefix

* Cmake from .

* Add lib64

* Try installing to . instead of /tmp

* Set MACOSX_DEPLOYMENT_TARGET

* Try installing to /usr/local/graphblas

* Try installing to {package}

* Fix

* Add prints

* Add print

* Try installing to .

* parent

* retry

* Disable JIT on Windows

* retry

* Fix if

* Revert to sys install

* Fix sudo

* Disable JIT on Windows

* tweaks

* MSVC complex values

* Revert prints

* Silence workflow warnings

* Delete no longer used script

* Undo run tests on push

* Make linter happy

* Linter

* Support both suitesparse.sh and conda install paths

* Fix cibw_test_skip typo

* Build with numpy 2; add Python 3.13; drop Python 3.8

* Bump

* Try setuptools<74

* experiment w/ setuptools as runtime dep

* undo

* Update cibuildwheel

We need pypa/cibuildwheel#1915 to `yum install`

* Use cibuildwheel 2.21, not 2.21.3

* Delete unnecessary code b/c we dropped Python 3.8

---------

Co-authored-by: Erik Welch <[email protected]>
  • Loading branch information
alugowski and eriknw authored Oct 14, 2024
1 parent 045d489 commit 4bf5c72
Show file tree
Hide file tree
Showing 11 changed files with 783 additions and 450 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
source: ["conda-forge"]
# os: ["ubuntu-latest"]
# source: ["source"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
26 changes: 11 additions & 15 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,14 @@ jobs:
cibw_skip: "pp* *musl*"

# macOS x86
- os: macos-latest
# Note: keep as old as possible as due to libomp this will be the oldest supported macOS version.
- os: macos-12
cibw_archs: "x86_64"

# macOS Apple Silicon cross-compiled on x86 macOS runner.
# GitHub does not offer Apple Silicon yet (only for self-hosted).
# See https://github.com/github/roadmap/issues/528
- os: macos-latest
# macOS Apple Silicon
# Note: keep as old as possible as due to libomp this will be the oldest supported macOS version.
- os: macos-14
cibw_archs: "arm64"
# Skip macOS ARM tests on Intel runner.
cibw_test_skip: "*-macosx_arm64"

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -139,17 +137,15 @@ jobs:
if: contains(matrix.os, 'macos')
# Install coreutils which includes `nproc` used by `make -j` in suitesparse.sh
#
# GitHub actions comes with libomp already installed, but for its native arch only. Must build universal one
# manually so that both x86 and arm builds can be built.
# Explicitly install libomp to be clear about the dependency.
#
# libomp determines the minimum macOS version that we can build for
run: |
brew fetch --retry coreutils && brew install coreutils
brew fetch --retry libomp && brew install libomp
if [[ ${{ matrix.cibw_archs }} == "arm64" ]] ; then
echo "Building universal libomp manually"
sh add_arm_to_libomp_dylib.sh || exit 1
fi
brew fetch --retry libomp && brew reinstall libomp
echo MACOSX_DEPLOYMENT_TARGET=$(otool -l $(brew --prefix libomp)/lib/libomp.dylib | grep minos | awk '{print $2}') >> $GITHUB_ENV
- uses: pypa/cibuildwheel@v2.16
- uses: pypa/cibuildwheel@v2.21
with:
output-dir: wheelhouse
env:
Expand Down
24 changes: 12 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -20,43 +20,43 @@ repos:
- id: mixed-line-ending
# - id: trailing-whitespace
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.14
rev: v0.20.2
hooks:
- id: validate-pyproject
name: Validate pyproject.toml
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
rev: v2.3.1
hooks:
- id: autoflake
args: [--in-place]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.13.0
rev: v3.18.0
hooks:
- id: pyupgrade
args: [--py38-plus]
args: [--py39-plus]
# - repo: https://github.com/MarcoGorelli/auto-walrus
# rev: v0.2.2
# hooks:
# - id: auto-walrus
# args: [--line-length, "100"]
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 24.10.0
hooks:
- id: black
# - id: black-jupyter
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: &flake8_dependencies
# These versions need updated manually
- flake8==6.1.0
- flake8-comprehensions==3.14.0
- flake8-bugbear==23.9.16
- flake8==7.1.1
- flake8-comprehensions==3.15.0
- flake8-bugbear==24.8.19
# - flake8-simplify==0.20.0
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
Expand All @@ -71,6 +71,6 @@ repos:
# - id: pyroma
# args: [-n, "10", .]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: no-commit-to-branch # no commit directly to main
2 changes: 1 addition & 1 deletion GB_VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.2.1
9.1.0
53 changes: 0 additions & 53 deletions add_arm_to_libomp_dylib.sh

This file was deleted.

24 changes: 20 additions & 4 deletions build_graphblas_cffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,30 @@
# Expected subdirectories: include/ (contains GraphBLAS.h), lib/, and bin/ (on Windows only)
# Otherwise fallback to default system folders.
graphblas_root = os.environ.get("GraphBLAS_ROOT", None)

if not graphblas_root:
# Windows wheels.yml configures suitesparse.sh to install GraphBLAS to "C:\\GraphBLAS".
graphblas_root = "C:\\GraphBLAS" if is_win else sys.prefix

include_dirs = [os.path.join(graphblas_root, "include")]
library_dirs = [os.path.join(graphblas_root, "lib")]
if is_win:
graphblas_root = "C:\\GraphBLAS"
elif Path("/usr/local/include/suitesparse").exists():
# SuiteSparse:GraphBLAS 9.1+ built by suitesparse.sh
graphblas_root = "/usr/local"
else:
# Conda install
graphblas_root = sys.prefix

include_dirs = [
os.path.join(graphblas_root, "include"),
os.path.join(graphblas_root, "include", "suitesparse"),
]
library_dirs = [os.path.join(graphblas_root, "lib"), os.path.join(graphblas_root, "lib64")]
if is_win:
include_dirs.append(os.path.join(sys.prefix, "Library", "include"))
include_dirs.append(os.path.join(sys.prefix, "Library", "include", "suitesparse"))
library_dirs.append(os.path.join(sys.prefix, "Library", "lib"))

include_dirs.append(os.path.join(graphblas_root, "include"))
include_dirs.append(os.path.join(graphblas_root, "include", "suitesparse"))
library_dirs.append(os.path.join(graphblas_root, "lib"))
library_dirs.append(os.path.join(graphblas_root, "bin"))

Expand Down Expand Up @@ -68,6 +81,9 @@ def get_extension(apply_msvc_patch: bool = None, extra_compile_args=()):
msvc_code = msvc_code.replace("double _Complex", "_Dcomplex")
code_path.write_text(msvc_code)

# Hack: tell GraphBLAS.h that we need MSVC-style complex values
extra_compile_args = list(extra_compile_args) + ["-DGxB_HAVE_COMPLEX_MSVC"]

return Extension(
"suitesparse_graphblas._graphblas",
[os.path.join("suitesparse_graphblas", "_graphblas.c")],
Expand Down
19 changes: 8 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools >=64",
# setuptools<74 until PyPy vendors cffi 1.15.1
"setuptools >=64, <74",
"setuptools-git-versioning",
"wheel",
"cffi>=1.11",
"cython",
"oldest-supported-numpy; platform_python_implementation != 'PyPy'",
# Inspired by SciPy: unpin numpy version for PyPy builds,
# as oldest-supported-numpy does not take PyPy into account.
"numpy; platform_python_implementation=='PyPy'",
"numpy>=2.0",
]

[project]
name = "suitesparse-graphblas"
dynamic = ["version"]
description = "SuiteSparse:GraphBLAS Python bindings."
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
license = {file = "LICENSE"}
authors = [
{name = "Erik Welch", email = "[email protected]"},
Expand Down Expand Up @@ -53,11 +51,11 @@ classifiers = [
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"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.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3 :: Only",
"Intended Audience :: Developers",
"Intended Audience :: Other Audience",
Expand All @@ -68,9 +66,8 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
# These are super-old; can/should we update them?
"cffi>=1.11",
"numpy>=1.19",
"cffi>=1.15",
"numpy>=1.23",
]
[project.urls]
homepage = "https://github.com/GraphBLAS/python-suitesparse-graphblas"
Expand All @@ -96,7 +93,7 @@ dirty_template = "{tag}+{ccount}.g{sha}.dirty"

[tool.black]
line-length = 100
target-version = ["py38", "py39", "py310", "py311"]
target-version = ["py39", "py310", "py311", "py312", "py313"]

[tool.isort]
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
Expand Down
26 changes: 22 additions & 4 deletions suitesparse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,29 @@ if [ -n "${SUITESPARSE_FASTEST_BUILD}" ]; then
cmake_params+=(-DCMAKE_CUDA_DEV=1)
fi

# Use `-DJITINIT=2` so that the JIT functionality is available, but disabled by default.
# Level 2, "run", means that pre-JIT kernels may be used, which does not require a compiler at runtime.
cmake .. -DJITINIT=2 -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles' "${cmake_params[@]}"
if [ -n "${CMAKE_GNUtoMS}" ]; then
# Windows options
echo "Skipping JIT on Windows for now because it fails to build."
cmake_params+=(-DGRAPHBLAS_USE_JIT=OFF)
else
# Use `-DJITINIT=2` so that the JIT functionality is available, but disabled by default.
# Level 2, "run", means that pre-JIT kernels may be used, which does not require a compiler at runtime.
cmake_params+=(-DJITINIT=2)

# Disable JIT here too to not segfault in tests
cmake_params+=(-DGRAPHBLAS_USE_JIT=OFF)
fi

# some platforms require sudo for installation, some don't have sudo at all
if [ "$(uname)" == "Darwin" ]; then
SUDO=sudo
else
SUDO=""
fi

cmake .. -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles' "${cmake_params[@]}"
make -j$NPROC
make install
$SUDO make install

if [ -n "${CMAKE_GNUtoMS}" ]; then
if [ -z "${GRAPHBLAS_PREFIX}" ]; then
Expand Down
5 changes: 4 additions & 1 deletion suitesparse_graphblas/create_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Run `python create_headers.py --help` to see more help.
"""

import argparse
import os
import re
Expand Down Expand Up @@ -325,6 +326,7 @@ def groupby(index, seq):
"RMM_WRAP_H",
"GXB_COMPLEX_H",
"GxB_STATIC_INLINE_VOID",
"GxB_HAVE_COMPLEX_C99",
# deprecated
"GxB_HYPER",
}
Expand Down Expand Up @@ -633,6 +635,7 @@ def handle_function_node(node):
"init": "core",
"wait": "core",
"deserialize": "core",
"Serialized": "core", # Added in version 9
}[group]
return {
"name": node.name,
Expand Down Expand Up @@ -782,7 +785,7 @@ def main():
parser.add_argument(
"--graphblas",
help="Path to GraphBLAS.h of SuiteSparse. Default will look in Python prefix path.",
default=os.path.join(sys.prefix, "include", "GraphBLAS.h"),
default=os.path.join(sys.prefix, "include", "suitesparse", "GraphBLAS.h"),
)
parser.add_argument(
"--show-skipped",
Expand Down
Loading

0 comments on commit 4bf5c72

Please sign in to comment.