Skip to content
Snippets Groups Projects
Commit 12cf4eb7 authored by Jon Rood's avatar Jon Rood Committed by Adam J. Stewart
Browse files

Explicitly listing blas and lapack sections in site.cfg for numpy (#8708)

* Explicitly listing blas and lapack sections in site.cfg for numpy when using netlib-lapack so that scipy can find them as well.

* Reducing code to use a function call instead of copying and pasting.

* Fixing flake8 errors.

* Fixing python 3.6 error when site.cfg lists library_dirs multiple times.

* Formatting.

* Verifying blas and lapack are enabled before writing to site.cfg.

* Fixing flake8 errors.

* Fixing conflicts since this package file has been updated.

* Fixing flake8 stuff.

* Handling blas and lapack variants for netlib-lapack in site.cfg for py-numpy.

* Don't write netlib-lapack site.cfg file if no blas or lapack variants enabled in py-numpy.

* Removing redundant if statement.

* Fixing mistake in py-numpy site.cfg generation.

* Separating blas and lapack further in site.cfg for netlib-lapack in py-numpy.
parent 586fe321
No related branches found
No related tags found
No related merge requests found
......@@ -66,13 +66,25 @@ def setup_dependent_package(self, module, dependent_spec):
def patch(self):
spec = self.spec
def write_library_dirs(f, dirs):
f.write('library_dirs=%s\n' % dirs)
if not ((platform.system() == "Darwin") and
(platform.mac_ver()[0] == '10.12')):
f.write('rpath=%s\n' % dirs)
# for build notes see http://www.scipy.org/scipylib/building/linux.html
lapackblas = LibraryList('')
blas_info = []
lapack_info = []
lapackblas_info = []
if '+lapack' in spec:
lapackblas += spec['lapack'].libs
lapack_info += spec['lapack'].libs
if '+blas' in spec:
lapackblas += spec['blas'].libs
blas_info += spec['blas'].libs
lapackblas_info = lapack_info + blas_info
if '+blas' in spec or '+lapack' in spec:
# note that one should not use [blas_opt] and [lapack_opt], see
......@@ -80,14 +92,19 @@ def patch(self):
with open('site.cfg', 'w') as f:
# Unfortunately, numpy prefers to provide each BLAS/LAPACK
# differently.
names = ','.join(lapackblas.names)
dirs = ':'.join(lapackblas.directories)
blas_names = ','.join(blas_info.names)
blas_dirs = ':'.join(blas_info.directories)
lapack_names = ','.join(lapack_info.names)
lapack_dirs = ':'.join(lapack_info.directories)
lapackblas_names = ','.join(lapackblas_info.names)
lapackblas_dirs = ':'.join(lapackblas_info.directories)
# Special treatment for some (!) BLAS/LAPACK. Note that
# in this case library_dirs can not be specified within [ALL].
if '^openblas' in spec:
f.write('[openblas]\n')
f.write('libraries=%s\n' % names)
f.write('libraries=%s\n' % lapackblas_names)
write_library_dirs(f, lapackblas_dirs)
elif '^mkl' in spec:
# numpy does not expect system libraries needed for MKL
# here.
......@@ -105,10 +122,23 @@ def patch(self):
# perspective it is no different from throwing away RPATH's
# and using LD_LIBRARY_PATH throughout Spack.
f.write('[mkl]\n')
f.write('mkl_libs=%s\n' % 'mkl_rt')
f.write('mkl_libs=%s\n' % 'mkl_rt')
write_library_dirs(f, lapackblas_dirs)
elif '^atlas' in spec:
f.write('[atlas]\n')
f.write('atlas_libs=%s\n' % names)
f.write('atlas_libs=%s\n' % lapackblas_names)
write_library_dirs(f, lapackblas_dirs)
elif '^netlib-lapack' in spec:
# netlib requires blas and lapack listed
# separately so that scipy can find them
if spec.satisfies('+blas'):
f.write('[blas]\n')
f.write('blas_libs=%s\n' % blas_names)
write_library_dirs(f, blas_dirs)
if spec.satisfies('+lapack'):
f.write('[lapack]\n')
f.write('lapack_libs=%s\n' % lapack_names)
write_library_dirs(f, lapack_dirs)
else:
# The section title for the defaults changed in @1.10, see
# https://github.com/numpy/numpy/blob/master/site.cfg.example
......@@ -116,12 +146,8 @@ def patch(self):
f.write('[DEFAULT]\n')
else:
f.write('[ALL]\n')
f.write('libraries=%s\n' % names)
f.write('library_dirs=%s\n' % dirs)
if not ((platform.system() == "Darwin") and
(platform.mac_ver()[0] == '10.12')):
f.write('rpath=%s\n' % dirs)
f.write('libraries=%s\n' % lapackblas_names)
write_library_dirs(f, lapackblas_dirs)
def build_args(self, spec, prefix):
args = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment