yig / PySPQR

Python wrapper for the sparse QR decomposition in SuiteSparseQR.
Creative Commons Zero v1.0 Universal
34 stars 27 forks source link

Custom suitesparse library configuration support in sparseqr_gen.py #18

Closed stuart-nolan closed 3 years ago

stuart-nolan commented 3 years ago

In PySPQR version 1, I use to be able to edit sparseqr_gen.py similar to

include_dirs = [ '/home/ul/local/include/suitesparse-5.8.1.mkl' ]
library_dirs = [ '/home/ul/local/lib/suitesparse-5.8.1.mkl' ]

for custom library/include directory support on ubuntu.

For this to work in version 1.1.2, I now also must make the edit to ffibuilder.set_source call to add the library_dirs. e.g.:

ffibuilder.set_source( "sparseqr._sparseqr",
    """#include <SuiteSparseQR_C.h>
""",
    ## You may need to modify the following line,
    ## which is needed on Ubuntu and harmless on Mac OS.
    include_dirs = include_dirs, library_dirs = library_dirs,
    libraries = libraries )

Easy enough and it works.

For those of us that complicate our lives with custom built suitesparse libs, is it possible to make the sparseqr_gen.py configuration closer to the prior versions? I.e. is it possible to including the library_dirs parameter in the ffibuilder.set_source call by default so that edits for custom libs can be grouped in one part of sparseqr_gen.py?

Thank you for continuing to support sparseqr.

yig commented 3 years ago

I don't see any previous version of PySPQR that passed the library_dirs parameter to ffibuilder.set_source(), but it should be easy to add.

stuart-nolan commented 3 years ago

If it can be added by default that would be great.

Yes, prior versions do not explicitly have library_dirs. I use a script to modify sparseqr_gen.py and build PySPQR (mostly for python updates as that tends to happen fairly frequently). For version 1, the script would modify the include_dirs and add the library_dirs parameter directly to the ffibuilder.set_source call at the top of the file.

It's clear why sparseqr_gen.py changed and perhaps this thread might help someone else looking to use custom libraries.

Thank you again.

yig commented 3 years ago

What if sparseqr_gen.py added environment variables LIBRARY_PATH and C_INCLUDE_PATH or CPATH?

stuart-nolan commented 3 years ago

Well this is a little embarrassing... if i do:

git clone https://github.com/yig/PySPQR.git PySPQR; cd PySPQR;
python setup.py build_ext --library-dirs='/home/ul/local/lib/suitesparse-5.8.1.mkl' --include-dirs='/home/ul/local/include/suitesparse-5.8.1.mkl' install

it builds as expected using my custom libraries. I thought I had tried that before I set up my script some time ago but apparently not. As this solves my issue, I'll close this.

FYI, ldd libspqr.so shows a link to libcholmod.so.3. The reason i don't use ubuntu suitesparse libs is they are (or use to be) built with openblas. As your likely aware, there is bug affecting openblas and suitesparse that degrades cholmod performance with large problems so I try to avoid openblas with suitesparse until that gets fixed.

Apologies for the noise.