Skip to content

Commit

Permalink
vendor suitesparse library in source distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
flaport committed Jul 2, 2023
1 parent d0e9179 commit c1ff0bd
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 23 deletions.
12 changes: 12 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
klujax.cpp
include suitesparse/SuiteSparse_config/*.h
include suitesparse/SuiteSparse_config/*.c
include suitesparse/AMD/Include/*.h
include suitesparse/COLAMD/Include/*.h
include suitesparse/BTF/Include/*.h
include suitesparse/KLU/Include/*.h
include suitesparse/AMD/Source/*.c
include suitesparse/COLAMD/Source/*.c
include suitesparse/BTF/Source/*.c
include suitesparse/KLU/Source/*.c
include suitesparse/LICENSE.txt
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ test:
pytest tests.py

suitesparse:
git clone --depth 1 --branch stable git@github.com:DrTimothyAldenDavis/SuiteSparse suitesparse || true
git clone --depth 1 --branch stable https://github.com/DrTimothyAldenDavis/SuiteSparse suitesparse || true
cd suitesparse && rm -rf .git

clean:
find . -not -path "./suitesparse*" -name "dist" | xargs rm -rf
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ sure you have the necessary build dependencies installed.

### Linux

On linux, you'll need `gcc` and `g++` and pybind11 (`pip install pybind11`)
On linux, you'll need `gcc` and `g++`. Then just do a normal pip install:

```sh
pip install klujax
```

### Windows

Expand All @@ -83,7 +87,7 @@ Command Prompt for VS 2017:

```
set DISTUTILS_USE_SDK=1
pip install pybind11 klujax
pip install klujax
```

## License & Credits
Expand All @@ -96,3 +100,10 @@ This library was partly based on:
- [SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse), LGPL-2.1
- [kagami-c/PyKLU](https://github.com/kagami-c/PyKLU), LGPL-2.1
- [scipy.sparse](https://github.com/scipy/scipy/tree/master/scipy/sparse), BSD-3

This library vendors an unmodified version of the
[SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse) libraries in its source
(.tar.gz) distribution to allow for static linking.
This is in accordance with their
[LGPL licence](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/LICENSE.txt).

53 changes: 33 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,41 @@
"posix": ["-static-libgcc", "-static-libstdc++"],
}

sources = [
"suitesparse/SuiteSparse_config/SuiteSparse_config.c",
*glob("suitesparse/AMD/Source/*.c"),
*glob("suitesparse/COLAMD/Source/*.c"),
*glob("suitesparse/BTF/Source/*.c"),
*glob("suitesparse/KLU/Source/*.c"),
"klujax.cpp",
]

include_dirs = [
libroot,
pybind11_include[os.name],
"suitesparse/SuiteSparse_config",
"suitesparse/AMD/Include",
"suitesparse/COLAMD/Include",
"suitesparse/BTF/Include",
"suitesparse/KLU/Include",
]

library_dirs = [site_packages]

suitesparse_headers = [
*glob("suitesparse/SuiteSparse_config/*.h"),
*glob("suitesparse/AMD/Include/*.h"),
*glob("suitesparse/COLAMD/Include/*.h"),
*glob("suitesparse/BTF/Include/*.h"),
*glob("suitesparse/KLU/Include/*.h"),
]


klujax_cpp = Extension(
name="klujax_cpp",
sources=[
"suitesparse/SuiteSparse_config/SuiteSparse_config.c",
*glob("suitesparse/AMD/Source/*.c"),
*glob("suitesparse/COLAMD/Source/*.c"),
*glob("suitesparse/BTF/Source/*.c"),
*glob("suitesparse/KLU/Source/*.c"),
"klujax.cpp",
],
include_dirs=[
libroot,
pybind11_include[os.name],
"suitesparse/SuiteSparse_config",
"suitesparse/AMD/Include",
"suitesparse/COLAMD/Include",
"suitesparse/BTF/Include",
"suitesparse/KLU/Include",
],
library_dirs=[
site_packages,
],
sources=sources,
include_dirs=include_dirs,
library_dirs=library_dirs,
extra_compile_args=extra_compile_args[os.name],
extra_link_args=extra_link_args[os.name],
language="c++",
Expand Down Expand Up @@ -81,6 +93,7 @@
"*": [
"LICENSE",
"README.md",
"MANIFEST.in",
],
},
)

0 comments on commit c1ff0bd

Please sign in to comment.