From c96d687c7c9fc1411e77fd1b7004fc80df8990c5 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Thu, 18 Jul 2019 13:57:37 -0500 Subject: [PATCH] Workaround for #9149 (#12050) --- .../repos/builtin/packages/py-numpy/package.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/var/spack/repos/builtin/packages/py-numpy/package.py b/var/spack/repos/builtin/packages/py-numpy/package.py index 0054dfadbc..e4385985f7 100644 --- a/var/spack/repos/builtin/packages/py-numpy/package.py +++ b/var/spack/repos/builtin/packages/py-numpy/package.py @@ -201,15 +201,18 @@ def build_args(self, spec, prefix): return args def setup_environment(self, spack_env, run_env): - python_version = self.spec['python'].version.up_to(2) + # If py-numpy is installed as an external package, python won't + # be available in the spec. See #9149 for details. + if 'python' in self.spec: + python_version = self.spec['python'].version.up_to(2) - include_path = join_path( - self.prefix.lib, - 'python{0}'.format(python_version), - 'site-packages', - 'numpy/core/include') + include_path = join_path( + self.prefix.lib, + 'python{0}'.format(python_version), + 'site-packages', + 'numpy/core/include') - run_env.prepend_path('CPATH', include_path) + run_env.prepend_path('CPATH', include_path) def test(self): # `setup.py test` is not supported. Use one of the following