@@ -134,14 +134,22 @@ if not use_ilp64
134134 ).stdout().strip() == ' 1'
135135endif
136136
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)
137+ # BLAS and LAPACK are dependencies for NumPy. Since NumPy 2.0, by default the
138+ # build will fail if they are missing; the performance impact is large, so
139+ # using fallback routines must be explicitly opted into by the user. xref
140+ # gh-24200 for a discussion on this.
141+ #
142+ # Note that we can only use a BLAS which provides a CBLAS interface. So disable
143+ # BLAS completely if CBLAS is not found.
144+ allow_noblas = get_option (' allow-noblas' )
141145if have_blas
142146 _args_blas = [] # note: used for C and C++ via `blas_dep` below
143147 if have_cblas
144148 _args_blas += [' -DHAVE_CBLAS' ]
149+ elif not allow_noblas
150+ error (' No CBLAS interface detected! Install a BLAS library with CBLAS ' + \
151+ ' support, or use the `allow-noblas` build option (note, this ' + \
152+ ' may be up to 100x slower for some linear algebra operations).' )
145153 endif
146154 if use_ilp64
147155 _args_blas += [' -DHAVE_BLAS_ILP64' ]
@@ -154,15 +162,25 @@ if have_blas
154162 compile_args : _args_blas,
155163 )
156164else
157- blas_dep = []
165+ if allow_noblas
166+ blas_dep = []
167+ else
168+ error (' No BLAS library detected! Install one, or use the ' + \
169+ ' `allow-noblas` build option (note, this may be up to 100x slower ' + \
170+ ' for some linear algebra operations).' )
171+ endif
158172endif
159173
160174if lapack_name == ' openblas'
161175 lapack_name = [' openblas' , ' OpenBLAS' ]
162176endif
163177lapack_dep = dependency (lapack_name, required : false )
164178have_lapack = lapack_dep.found()
165-
179+ if not have_lapack and not allow_noblas
180+ error (' No LAPACK library detected! Install one, or use the ' + \
181+ ' `allow-noblas` build option (note, this may be up to 100x slower ' + \
182+ ' for some linear algebra operations).' )
183+ endif
166184
167185# Copy the main __init__.py|pxd files to the build dir (needed for Cython)
168186__init__py = fs.copyfile(' __init__.py' )
0 commit comments