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.
This commit is contained in:
parent
586fe32166
commit
12cf4eb734
@ -66,13 +66,25 @@ def setup_dependent_package(self, module, dependent_spec):
|
|||||||
|
|
||||||
def patch(self):
|
def patch(self):
|
||||||
spec = self.spec
|
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
|
# for build notes see http://www.scipy.org/scipylib/building/linux.html
|
||||||
lapackblas = LibraryList('')
|
blas_info = []
|
||||||
|
lapack_info = []
|
||||||
|
lapackblas_info = []
|
||||||
|
|
||||||
if '+lapack' in spec:
|
if '+lapack' in spec:
|
||||||
lapackblas += spec['lapack'].libs
|
lapack_info += spec['lapack'].libs
|
||||||
|
|
||||||
if '+blas' in spec:
|
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:
|
if '+blas' in spec or '+lapack' in spec:
|
||||||
# note that one should not use [blas_opt] and [lapack_opt], see
|
# 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:
|
with open('site.cfg', 'w') as f:
|
||||||
# Unfortunately, numpy prefers to provide each BLAS/LAPACK
|
# Unfortunately, numpy prefers to provide each BLAS/LAPACK
|
||||||
# differently.
|
# differently.
|
||||||
names = ','.join(lapackblas.names)
|
blas_names = ','.join(blas_info.names)
|
||||||
dirs = ':'.join(lapackblas.directories)
|
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
|
# Special treatment for some (!) BLAS/LAPACK. Note that
|
||||||
# in this case library_dirs can not be specified within [ALL].
|
# in this case library_dirs can not be specified within [ALL].
|
||||||
if '^openblas' in spec:
|
if '^openblas' in spec:
|
||||||
f.write('[openblas]\n')
|
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:
|
elif '^mkl' in spec:
|
||||||
# numpy does not expect system libraries needed for MKL
|
# numpy does not expect system libraries needed for MKL
|
||||||
# here.
|
# here.
|
||||||
@ -105,10 +122,23 @@ def patch(self):
|
|||||||
# perspective it is no different from throwing away RPATH's
|
# perspective it is no different from throwing away RPATH's
|
||||||
# and using LD_LIBRARY_PATH throughout Spack.
|
# and using LD_LIBRARY_PATH throughout Spack.
|
||||||
f.write('[mkl]\n')
|
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:
|
elif '^atlas' in spec:
|
||||||
f.write('[atlas]\n')
|
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:
|
else:
|
||||||
# The section title for the defaults changed in @1.10, see
|
# The section title for the defaults changed in @1.10, see
|
||||||
# https://github.com/numpy/numpy/blob/master/site.cfg.example
|
# https://github.com/numpy/numpy/blob/master/site.cfg.example
|
||||||
@ -116,12 +146,8 @@ def patch(self):
|
|||||||
f.write('[DEFAULT]\n')
|
f.write('[DEFAULT]\n')
|
||||||
else:
|
else:
|
||||||
f.write('[ALL]\n')
|
f.write('[ALL]\n')
|
||||||
f.write('libraries=%s\n' % names)
|
f.write('libraries=%s\n' % lapackblas_names)
|
||||||
|
write_library_dirs(f, lapackblas_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)
|
|
||||||
|
|
||||||
def build_args(self, spec, prefix):
|
def build_args(self, spec, prefix):
|
||||||
args = []
|
args = []
|
||||||
|
Loading…
Reference in New Issue
Block a user