summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2019-01-22 12:18:54 -0600
committerGitHub <noreply@github.com>2019-01-22 12:18:54 -0600
commitc0972a32609347bb2fc8cfa492789936b6a2050f (patch)
tree93c7aa5e62ea33ff93fc11d797cafbeb579a8447
parent636d6007baaec34f6845b8e3c43e31651972ffd2 (diff)
downloadspack-c0972a32609347bb2fc8cfa492789936b6a2050f.tar.gz
spack-c0972a32609347bb2fc8cfa492789936b6a2050f.tar.bz2
spack-c0972a32609347bb2fc8cfa492789936b6a2050f.tar.xz
spack-c0972a32609347bb2fc8cfa492789936b6a2050f.zip
Exclude system mkl installs from numpy (#10383)
Fixes #10361 Fixes #6634 When mkl isnt in the spec, still write an explicit mkl entry to prevent numpy from looking in system dirs and using a system install of mkl. Do the same for openblas and atlas (although mkl was the only system install reported to interfere with Spack's choice).
-rw-r--r--var/spack/repos/builtin/packages/py-numpy/package.py32
1 files changed, 28 insertions, 4 deletions
diff --git a/var/spack/repos/builtin/packages/py-numpy/package.py b/var/spack/repos/builtin/packages/py-numpy/package.py
index aba417c54b..f2142a5315 100644
--- a/var/spack/repos/builtin/packages/py-numpy/package.py
+++ b/var/spack/repos/builtin/packages/py-numpy/package.py
@@ -86,6 +86,11 @@ class PyNumpy(PythonPackage):
lapackblas_info = lapack_info + blas_info
+ def write_empty_libs(f, provider):
+ f.write('[{0}]\n'.format(provider))
+ f.write('libraries=\n')
+ write_library_dirs(f, '')
+
if '+blas' in spec or '+lapack' in spec:
# note that one should not use [blas_opt] and [lapack_opt], see
# https://github.com/numpy/numpy/commit/ffd4332262ee0295cb942c94ed124f043d801eb6
@@ -99,13 +104,19 @@ class PyNumpy(PythonPackage):
lapackblas_names = ','.join(lapackblas_info.names)
lapackblas_dirs = ':'.join(lapackblas_info.directories)
+ handled_blas_and_lapack = False
+
# 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' % lapackblas_names)
write_library_dirs(f, lapackblas_dirs)
- elif '^mkl' in spec:
+ handled_blas_and_lapack = True
+ else:
+ write_empty_libs(f, 'openblas')
+
+ if '^mkl' in spec:
# numpy does not expect system libraries needed for MKL
# here.
# names = [x for x in names if x.startswith('mkl')]
@@ -124,11 +135,22 @@ class PyNumpy(PythonPackage):
f.write('[mkl]\n')
f.write('mkl_libs=%s\n' % 'mkl_rt')
write_library_dirs(f, lapackblas_dirs)
- elif '^atlas' in spec:
+ handled_blas_and_lapack = True
+ else:
+ # Without explicitly setting the search directories to be
+ # an empty list, numpy may retrieve and use mkl libs from
+ # the system.
+ write_empty_libs(f, 'mkl')
+
+ if '^atlas' in spec:
f.write('[atlas]\n')
f.write('atlas_libs=%s\n' % lapackblas_names)
write_library_dirs(f, lapackblas_dirs)
- elif '^netlib-lapack' in spec:
+ handled_blas_and_lapack = True
+ else:
+ write_empty_libs(f, 'atlas')
+
+ if '^netlib-lapack' in spec:
# netlib requires blas and lapack listed
# separately so that scipy can find them
if spec.satisfies('+blas'):
@@ -139,7 +161,9 @@ class PyNumpy(PythonPackage):
f.write('[lapack]\n')
f.write('lapack_libs=%s\n' % lapack_names)
write_library_dirs(f, lapack_dirs)
- else:
+ handled_blas_and_lapack = True
+
+ if not handled_blas_and_lapack:
# The section title for the defaults changed in @1.10, see
# https://github.com/numpy/numpy/blob/master/site.cfg.example
if spec.satisfies('@:1.9.2'):