Skip to content

Try adding a simple CI script for GithubActions. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Apr 29, 2021
Merged
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
24 changes: 19 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: python-suitesparse-graphblas
name: Test

on:
push:
branches: [main]
branches: [ main ]
pull_request:

jobs:
test:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
Expand All @@ -21,20 +24,31 @@ jobs:
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: continuous_integration/environment.yml
channels: conda-forge
activate-environment: suitesparse-graphblas
- name: Build
run: |
conda info
conda list
conda install -c conda-forge cffi cython numpy graphblas pytest coverage black flake8 # TODO: environment.yml
python setup.py build_ext --inplace
python setup.py develop
- name: Test
env:
CYTHON_COVERAGE: true
run: |
coverage run --branch -m pytest
coverage run -a --branch suitesparse_graphblas/tests/test_initialize.py
- name: Lint
run: |
black *py suitesparse_graphblas --check --diff
flake8 *py suitesparse_graphblas
- name: create_headers.py check
if: (! contains(matrix.os, 'windows'))
run: |
# These shouldn't change, so make copies to compare to
cp suitesparse_graphblas/suitesparse_graphblas.h .
cp suitesparse_graphblas/suitesparse_graphblas_no_complex.h .
cp suitesparse_graphblas/source.c .
coverage run -a --branch suitesparse_graphblas/create_headers.py
diff suitesparse_graphblas/suitesparse_graphblas.h suitesparse_graphblas.h
diff suitesparse_graphblas/suitesparse_graphblas_no_complex.h suitesparse_graphblas_no_complex.h
diff suitesparse_graphblas/source.c source.c
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# python-suitesparse-graphblas

[![Version](https://img.shields.io/pypi/v/suitesparse-graphblas.svg)](https://pypi.org/project/suitesparse-graphblas/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/GraphBLAS/python-suitesparse-graphblas/blob/main/LICENSE)
[![Build Status](https://github.com/GraphBLAS/python-suitesparse-graphblas/workflows/Test/badge.svg)](https://github.com/GraphBLAS/python-suitesparse-graphblas/actions)
[![Code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

Python CFFI Binding around
[SuiteSparse:GraphBLAS](https://github.com/DrTimothyAldenDavis/GraphBLAS)

Expand Down
13 changes: 13 additions & 0 deletions continuous_integration/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: suitesparse-graphblas
channels:
- conda-forge
- defaults
dependencies:
- graphblas=4.0.3
- cffi
- cython
- numpy
- pytest
- coverage
- black
- flake8
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools", "wheel", "numpy>=1.15"]
requires = ["setuptools", "wheel", "numpy>=1.15", "cython"]

[tool.black]
line-length = 100
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sys
import versioneer

is_win = sys.platform.startswith("win")
define_macros = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]

if use_cython:
Expand All @@ -25,6 +26,13 @@
define_macros.append(("CYTHON_TRACE_NOGIL", "1"))
else:
suffix = ".c"
# Make sure all required .c files are here
pyx_files = glob("suitesparse_graphblas/**.pyx", recursive=True)
c_files = glob("suitesparse_graphblas/**.c", recursive=True)
missing = {x[:-4] for x in pyx_files} - {x[:-2] for x in c_files}
if missing:
missing_c = sorted(x + ".c" for x in missing)
raise RuntimeError("Cython required when missing C files: " + ", ".join(missing_c))

include_dirs = [np.get_include(), os.path.join(sys.prefix, "include")]
ext_modules = [
Expand All @@ -43,7 +51,7 @@
long_description = f.read()

package_data = {"suitesparse_graphblas": ["*.pyx", "*.pxd", "*.c", "*.h"]}
if sys.platform == "win32":
if is_win:
package_data["suitesparse_graphblas"].append("*.dll")

setup(
Expand Down
9 changes: 8 additions & 1 deletion suitesparse_graphblas/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@
with open(os.path.join(thisdir, "source.c")) as f:
source = f.read()

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

ffibuilder.set_source(
"suitesparse_graphblas._graphblas",
source,
libraries=["graphblas"],
include_dirs=[os.path.join(sys.prefix, "include")],
include_dirs=include_dirs,
library_dirs=library_dirs,
)

header = "suitesparse_graphblas.h"
Expand Down
2 changes: 1 addition & 1 deletion suitesparse_graphblas/create_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


def sort_key(string):
""" e.g., sort 'INT8' before 'INT16'"""
"""e.g., sort 'INT8' before 'INT16'"""
return string.replace("8", "08")


Expand Down
9 changes: 9 additions & 0 deletions suitesparse_graphblas/tests/test_initialize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if __name__ == "__main__":
import suitesparse_graphblas as ssgb
import pytest

assert ssgb.is_initialized() is False
ssgb.initialize()
assert ssgb.is_initialized() is True
with pytest.raises(RuntimeError, match="GraphBLAS is already initialized"):
ssgb.initialize()
2 changes: 1 addition & 1 deletion suitesparse_graphblas/tests/test_package.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from suitesparse_graphblas import lib, ffi
from suitesparse_graphblas import lib, ffi # noqa


def test_matrix_existence():
Expand Down