scipy: DOC: linking to custom BLAS/LAPACK locations is not clear
Issue with current documentation:
I have tried to figure out how the meson
(new) build system understands the linking stages for BLAS and LAPACK. But there seems to some missing points. Perhaps it is my ignorance in how meson
understands flags etc.
So I want to build my own scipy
and NOT use pip
or conda. I also want to forcefully go away from using distutils (to be prepared for 3.12).
**scipy version: 1.10.1 **
I have tried to understand this page: https://docs.scipy.org/doc/scipy/dev/contributor/building_faq.html#how-do-i-use-a-custom-blas-distribution-on-linux
However, when trying to build with meson:
scipy/meson.build:135:0: ERROR: Dependency "OpenBLAS" not found, tried pkgconfig and cmake
meson setup build-dir -Dblas=blis
The Meson build system
Version: 1.0.1
Source dir: /home/software/bash-build/.compile/py-3.11/scipy-1.10.1
Build dir: /home/software/bash-build/.compile/py-3.11/scipy-1.10.1/build-dir
Build type: native build
Project name: SciPy
Project version: 1.10.1
C compiler for the host machine: gcc (gcc 12.2.0 "gcc (GCC) 12.2.0")
C linker for the host machine: gcc ld.bfd 2.40
C++ compiler for the host machine: g++ (gcc 12.2.0 "g++ (GCC) 12.2.0")
C++ linker for the host machine: g++ ld.bfd 2.40
Cython compiler for the host machine: cython (cython 0.29.33)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -Wno-unused-but-set-variable: YES
Compiler for C supports arguments -Wno-unused-function: YES
Compiler for C supports arguments -Wno-conversion: YES
Compiler for C supports arguments -Wno-misleading-indentation: YES
Compiler for C supports arguments -Wno-incompatible-pointer-types: YES
Library m found: YES
Fortran compiler for the host machine: gfortran (gcc 12.2.0 "GNU Fortran (GCC) 12.2.0")
Fortran linker for the host machine: gfortran ld.bfd 2.40
Compiler for Fortran supports arguments -Wno-conversion: YES
Checking if "-Wl,--version-script" : links: YES
Program cython found: YES (/opt/gnu/12.2.0/python/packages/3.11.2/cython/0.29.33/bin/cython)
Program python3 found: YES (/opt/gnu/12.2.0/python/3.11.2/bin/python3)
Found pkg-config: /opt/generic/build-tools/1.0/bin/pkg-config (1.9.4)
Program pythran found: YES (/opt/gnu/12.2.0/python/packages/3.11.2/pythran/0.12.1/bin/pythran)
Run-time dependency threads found: YES
Library npymath found: YES
Library npyrandom found: YES
Run-time dependency blis found: YES 0.9.0
Found CMake: /opt/generic/build-tools/1.0/bin/cmake (3.25.3)
WARNING: CMake Toolchain: Failed to determine CMake compilers state
Run-time dependency openblas found: NO (tried pkgconfig and cmake)
Run-time dependency openblas found: NO (tried pkgconfig and cmake)
scipy/meson.build:135:0: ERROR: Dependency "OpenBLAS" not found, tried pkgconfig and cmake
basically regardless of the blas=<>
argument. Tried, default, none
and blis
(my actual library).
The above is actually a bit misleading since users may think that this is the blas
option which is not discovered, it is not, it is the lapack option.
I have lapack
installed in a directory with no pc
or cmake files. Is it possible to link that library to meson?
meson setup build-d -Dblas=blis -Dlapack=lapack
...
WARNING: CMake Toolchain: Failed to determine CMake compilers state
WARNING: CMake Toolchain: Failed to determine CMake compilers state
Run-time dependency lapack found: NO (tried pkgconfig and cmake)
scipy/meson.build:135:0: ERROR: Dependency "lapack" not found, tried pkgconfig and cmake
There is little documentation on how to bypass the dependency checking, and even with env-vars (not going to be supported: https://github.com/mesonbuild/meson/issues/9).
The whole problem of fixing names for dependencies makes it difficult to customize the build. I.e. if -Dblas=<argument>
where <argument>
has the restriction that it must be a name that used via pkg-config
, i.e. pkg-conf --libs <argument>
. So it seems to me that I have to provide a manual *.pc
file for customizing a library usage? Really? š
I tried:
- put everything in FC flags etc., but this also fails since the dependency is forcefully added regardless of whether linking can occur
- put complete information in the
-Dlapack='-L/path/to/lapack/... -llapack
option, to no avail
python setup.py
works but
I can get scipy to be installed using the regular setup.py
installation, but that will use my numpy site.cfg
which I am not keen on.
Idea or request for content:
It would be really valuable if the documentation showed how to link to a BLAS library located in a custom folder, without a pc
file. That would show end-users how to play around with settings, and/or test various BLAS implementations (lets for now forget about flexiblas š ).
Additional context (e.g. screenshots, GIFs)
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (18 by maintainers)
Iāll have a go at cleaning up the docs today. Thereās also still a bunch of places with very detailed explanations on
distutils
usage; Iāll replace those with ālook at examples in currentmeson.build
filesā.We had a good discussion at the community meeting with both some new contributors and some old hands. The most popular idea was to replace the āGetting Startedā tile on the front page of the docs (http://scipy.github.io/devdocs/), which is basically empty, with a dedicated āBuilding from sourceā section. Weād then still have four tiles:
I probably wonāt get started on that this week, but itād be good to hear any concerns with that plan.
No, quite the opposite. This always goes out of date, as the current state of our docs shows. I want to explain the principle only, and then say something like āfor any details on build options and how to use them, see
dev.py build --help
ā.next community meeting sounds good to me
Related question to maintainers: should we clean the docs now? The āadvanced Mesonā page is quite difficult to find, and the
setup.py
content basically is no longer relevant even though itās still possible to trigger that build (but not viapip
for example).Ok, Iāll try and adapt to scikit-build-core then. More work š
Happy to help. š
And yes, please do ping me!
Great!
Ok.
Yes, this would be great to have! š
It was just a contrived example š
Thanks for this sentiment. I am continuously struggling to find a path in the package nightmare of python. There are too many tools and too few standards⦠š¦ I know this isnāt easy and I can see this frustration across the Python community. I truly hope that the coming years will try to manage a more standardized approach, pep 517 + friends. And then meson + scikit-build and others are another layer of complexity. I am not blaming anybody, but I can just see that the obfuscation and very diverse avocations of different build-tools, ends up being a problem for the small devās who cannot figure out what is the endorsed approach.
Agreed!
Ok. I will do then. š
Let me note one thing about meson that is not clear for builders. Environment variables. One expects that env-vars are obeyed,
CC
,CFLAGS
. Now meson is very particular here to never allowing env-vars. I understand their concerns and decisions, but perhaps this needs a clarification in the documentation (here as well). References: https://github.com/mesonbuild/meson/issues/9 and https://github.com/mesonbuild/meson/pull/2796 Yet, some of the flags are still read: https://github.com/mesonbuild/meson/issues/4664 Finding this in the documentation is not easy⦠š¦Yes, this is much better, thanks! Could I suggest that the Note in https://docs.scipy.org/doc/scipy/dev/contributor/meson_advanced.html#select-a-different-blas-or-lapack-library is complimented by the filename of the
pkg-config
file and the resultingmeson
commandline for building it. It is relatively clear, but⦠šAnother thing, on the documentation pages it is not easy to go back and forth in the pages. For instance, if I just follow your link to the advanced meson page, I cannot easily find this https://docs.scipy.org/doc/scipy/dev/contributor/meson.html, no links to that page? And vice-versa. No link from the simple -> advanced. There is only an āon this pageā in the right block.
It seems to me that the section structure is missing, somehow? (this is a generic problem I think)
That would be great! The older versions documentations still works, so one could link to prior versions documentations in a simple statement where it is then much clearer that it is deprecated. Basically what @tupul said š
It would also be nice to discuss how to change CFLAGS etc. It is not clear to me whether the CFLAGS from meson build-setup or from the
dev.py
file are used. So if I do:what would happen where?
Thanks for all of the discussion!