SciPy with OpenBlas

Hi Developers

I have built SciPy wheel with openblas from OpenMathLib(OpenMathLib · GitHub) using pkg-config method on windows without scipy-openblas32. How to link the built openblas.dll dynamically with wheel to get the functionality of BLAS/LAPACK packages?
Thanks

The short answer is that Windows doesn’t have RPATH support, so for any DLLs that aren’t in a directory that’s searched for DLLs by default, you should use os.add_dll_directory to add that directory to the search path. You can edit scipy/_distributor_init.py to do so.

Alternatively, you can run delvewheel over the built SciPy wheel. That will vendor the openblas and libgfortran DLLs into the wheel. The README of GitHub - adang1345/delvewheel: Self-contained Python wheels for Windows will have more details.

@rgommers

  1. Does SciPy indeed have any scripts to build wheel from the build install dir? else users needs to bring setup.py files?
  2. Can users use any variant of openblas, what configuration does scipy needs for openblas to be supported?

Thanks

You don’t build wheels from a build or build-install dir. Rather, starting from a clean repository, you build a wheel with python -m build --wheel for local usage.

In case you want a redistributable wheel, that is a bit harder - see Building redistributable binaries — SciPy v1.15.0.dev Manual for docs.

For (2), yes any OpenBLAS or other BLAS/LAPACK library, see BLAS and LAPACK — SciPy v1.15.0.dev Manual.

@rgommers
I tried the following command you shared, but it tries to download numpy source code and building numpy on top of it, is there any reason why numpy comes into play here? Since i am having my own numpy installed via pypi

That is what is called “build isolation” - it’s build doing that (pip will do the same). Use python -m build -wnx to disable build isolation.

1 Like

@rgommers Thanks, will try it out come back

Thanks @rgommers man! this works fine, now I have got the wheel how can I run tests on this wheel?

Install it, the pytest --pyargs scipy or in the interpreter import scipy; scipy.test().

Note that all of this is completely standard usage of build and pytest, the defaults as in the docs of those projects just work.