Skip to content

Commit eccba07

Browse files
authored
Merge pull request #12 from eriknw/basic_ci
Try adding a simple CI script for GithubActions.
2 parents 8cd7770 + 7ebe084 commit eccba07

File tree

9 files changed

+67
-10
lines changed

9 files changed

+67
-10
lines changed

.github/workflows/test.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
name: python-suitesparse-graphblas
1+
name: Test
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [ main ]
66
pull_request:
77

88
jobs:
99
test:
1010
runs-on: ${{ matrix.os }}
11+
defaults:
12+
run:
13+
shell: bash -l {0}
1114
strategy:
1215
fail-fast: false
1316
matrix:
@@ -21,20 +24,31 @@ jobs:
2124
with:
2225
auto-update-conda: true
2326
python-version: ${{ matrix.python-version }}
27+
environment-file: continuous_integration/environment.yml
2428
channels: conda-forge
29+
activate-environment: suitesparse-graphblas
2530
- name: Build
2631
run: |
27-
conda info
28-
conda list
29-
conda install -c conda-forge cffi cython numpy graphblas pytest coverage black flake8 # TODO: environment.yml
3032
python setup.py build_ext --inplace
3133
python setup.py develop
3234
- name: Test
3335
env:
3436
CYTHON_COVERAGE: true
3537
run: |
3638
coverage run --branch -m pytest
39+
coverage run -a --branch suitesparse_graphblas/tests/test_initialize.py
3740
- name: Lint
3841
run: |
3942
black *py suitesparse_graphblas --check --diff
4043
flake8 *py suitesparse_graphblas
44+
- name: create_headers.py check
45+
if: (! contains(matrix.os, 'windows'))
46+
run: |
47+
# These shouldn't change, so make copies to compare to
48+
cp suitesparse_graphblas/suitesparse_graphblas.h .
49+
cp suitesparse_graphblas/suitesparse_graphblas_no_complex.h .
50+
cp suitesparse_graphblas/source.c .
51+
coverage run -a --branch suitesparse_graphblas/create_headers.py
52+
diff suitesparse_graphblas/suitesparse_graphblas.h suitesparse_graphblas.h
53+
diff suitesparse_graphblas/suitesparse_graphblas_no_complex.h suitesparse_graphblas_no_complex.h
54+
diff suitesparse_graphblas/source.c source.c

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# python-suitesparse-graphblas
2+
3+
[![Version](https://img.shields.io/pypi/v/suitesparse-graphblas.svg)](https://pypi.org/project/suitesparse-graphblas/)
4+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/GraphBLAS/python-suitesparse-graphblas/blob/main/LICENSE)
5+
[![Build Status](https://github.com/GraphBLAS/python-suitesparse-graphblas/workflows/Test/badge.svg)](https://github.com/GraphBLAS/python-suitesparse-graphblas/actions)
6+
[![Code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
7+
28
Python CFFI Binding around
39
[SuiteSparse:GraphBLAS](https://github.com/DrTimothyAldenDavis/GraphBLAS)
410

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: suitesparse-graphblas
2+
channels:
3+
- conda-forge
4+
- defaults
5+
dependencies:
6+
- graphblas=4.0.3
7+
- cffi
8+
- cython
9+
- numpy
10+
- pytest
11+
- coverage
12+
- black
13+
- flake8

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "numpy>=1.15"]
2+
requires = ["setuptools", "wheel", "numpy>=1.15", "cython"]
33

44
[tool.black]
55
line-length = 100

setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import sys
1414
import versioneer
1515

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

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

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

4553
package_data = {"suitesparse_graphblas": ["*.pyx", "*.pxd", "*.c", "*.h"]}
46-
if sys.platform == "win32":
54+
if is_win:
4755
package_data["suitesparse_graphblas"].append("*.dll")
4856

4957
setup(

suitesparse_graphblas/build.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@
1010
with open(os.path.join(thisdir, "source.c")) as f:
1111
source = f.read()
1212

13+
include_dirs = [os.path.join(sys.prefix, "include")]
14+
library_dirs = [os.path.join(sys.prefix, "lib")]
15+
if is_win:
16+
include_dirs.append(os.path.join(sys.prefix, "Library", "include"))
17+
library_dirs.append(os.path.join(sys.prefix, "Library", "lib"))
18+
1319
ffibuilder.set_source(
1420
"suitesparse_graphblas._graphblas",
1521
source,
1622
libraries=["graphblas"],
17-
include_dirs=[os.path.join(sys.prefix, "include")],
23+
include_dirs=include_dirs,
24+
library_dirs=library_dirs,
1825
)
1926

2027
header = "suitesparse_graphblas.h"

suitesparse_graphblas/create_headers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
def sort_key(string):
35-
""" e.g., sort 'INT8' before 'INT16'"""
35+
"""e.g., sort 'INT8' before 'INT16'"""
3636
return string.replace("8", "08")
3737

3838

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if __name__ == "__main__":
2+
import suitesparse_graphblas as ssgb
3+
import pytest
4+
5+
assert ssgb.is_initialized() is False
6+
ssgb.initialize()
7+
assert ssgb.is_initialized() is True
8+
with pytest.raises(RuntimeError, match="GraphBLAS is already initialized"):
9+
ssgb.initialize()

suitesparse_graphblas/tests/test_package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from suitesparse_graphblas import lib, ffi
1+
from suitesparse_graphblas import lib, ffi # noqa
22

33

44
def test_matrix_existence():

0 commit comments

Comments
 (0)