5353# (see cibuildwheel settings in pyproject.toml), but used by CI jobs already
5454blas_symbol_suffix = get_option (' blas-symbol-suffix' )
5555
56+ use_ilp64 = get_option (' use-ilp64' )
57+ if not use_ilp64
58+ # For now, keep supporting this environment variable too (same as in setup.py)
59+ # `false is the default for the CLI flag, so check if env var was set
60+ use_ilp64 = run_command (py,
61+ [
62+ ' -c' ,
63+ ' import os; print(1) if os.environ.get("NPY_USE_BLAS_ILP64", "0") != "0" else print(0)'
64+ ],
65+ check : true
66+ ).stdout().strip() == ' 1'
67+ endif
68+
5669
5770# TODO: 64-bit (ILP64) BLAS and LAPACK support (e.g., check for more .pc files
5871# so we detect `openblas64_.so` directly). Partially supported now, needs more
@@ -70,7 +83,12 @@ lapack_name = get_option('lapack')
7083# pkg-config uses a lower-case name while CMake uses a capitalized name, so try
7184# that too to make the fallback detection with CMake work
7285if blas_name == ' openblas'
73- blas = dependency ([' openblas' , ' OpenBLAS' ], required : false )
86+ if use_ilp64
87+ _openblas_names = [' openblas64' , ' openblas' , ' OpenBLAS' ]
88+ else
89+ _openblas_names = [' openblas' , ' OpenBLAS' ]
90+ endif
91+ blas = dependency (_openblas_names, required : false )
7492else
7593 blas = dependency (blas_name, required : false )
7694endif
@@ -121,27 +139,22 @@ if have_blas
121139 endif
122140endif
123141
124- use_ilp64 = get_option (' use-ilp64' )
125- if not use_ilp64
126- # For now, keep supporting this environment variable too (same as in setup.py)
127- # `false is the default for the CLI flag, so check if env var was set
128- use_ilp64 = run_command (py,
129- [
130- ' -c' ,
131- ' import os; print(1) if os.environ.get("NPY_USE_BLAS_ILP64", "0") != "0" else print(0)'
132- ],
133- check : true
134- ).stdout().strip() == ' 1'
135- endif
136-
137- # BLAS and LAPACK are optional dependencies for NumPy. We can only use a BLAS
138- # which provides a CBLAS interface. So disable BLAS completely if CBLAS is not
139- # found (lapack-lite will be used instead; xref gh-24200 for a discussion on
140- # whether this silent disabling should stay as-is)
142+ # BLAS and LAPACK are dependencies for NumPy. Since NumPy 2.0, by default the
143+ # build will fail if they are missing; the performance impact is large, so
144+ # using fallback routines must be explicitly opted into by the user. xref
145+ # gh-24200 for a discussion on this.
146+ #
147+ # Note that we can only use a BLAS which provides a CBLAS interface. So disable
148+ # BLAS completely if CBLAS is not found.
149+ allow_noblas = get_option (' allow-noblas' )
141150if have_blas
142151 _args_blas = [] # note: used for C and C++ via `blas_dep` below
143152 if have_cblas
144153 _args_blas += [' -DHAVE_CBLAS' ]
154+ elif not allow_noblas
155+ error (' No CBLAS interface detected! Install a BLAS library with CBLAS ' + \
156+ ' support, or use the `allow-noblas` build option (note, this ' + \
157+ ' may be up to 100x slower for some linear algebra operations).' )
145158 endif
146159 if use_ilp64
147160 _args_blas += [' -DHAVE_BLAS_ILP64' ]
@@ -154,15 +167,25 @@ if have_blas
154167 compile_args : _args_blas,
155168 )
156169else
157- blas_dep = []
170+ if allow_noblas
171+ blas_dep = []
172+ else
173+ error (' No BLAS library detected! Install one, or use the ' + \
174+ ' `allow-noblas` build option (note, this may be up to 100x slower ' + \
175+ ' for some linear algebra operations).' )
176+ endif
158177endif
159178
160179if lapack_name == ' openblas'
161180 lapack_name = [' openblas' , ' OpenBLAS' ]
162181endif
163182lapack_dep = dependency (lapack_name, required : false )
164183have_lapack = lapack_dep.found()
165-
184+ if not have_lapack and not allow_noblas
185+ error (' No LAPACK library detected! Install one, or use the ' + \
186+ ' `allow-noblas` build option (note, this may be up to 100x slower ' + \
187+ ' for some linear algebra operations).' )
188+ endif
166189
167190# Copy the main __init__.py|pxd files to the build dir (needed for Cython)
168191__init__py = fs.copyfile(' __init__.py' )
0 commit comments