summaryrefslogtreecommitdiff
path: root/lib/spack
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@googlemail.com>2017-09-29 18:23:13 +0200
committerbecker33 <becker33@llnl.gov>2017-09-29 09:23:13 -0700
commit554937780bf9bad2e1e2b238aa95c6fd862b711e (patch)
treef4851c682d313c647763c291c823ffe3dd6914fd /lib/spack
parenta63fdc8f354d2394ec64c960ff50bc29381d69bb (diff)
downloadspack-554937780bf9bad2e1e2b238aa95c6fd862b711e.tar.gz
spack-554937780bf9bad2e1e2b238aa95c6fd862b711e.tar.bz2
spack-554937780bf9bad2e1e2b238aa95c6fd862b711e.tar.xz
spack-554937780bf9bad2e1e2b238aa95c6fd862b711e.zip
modules: specialized configure_options for external packages (#5543)
closes #5473 Prior to this PR we were not exiting early for external packages, which caused the `configure_options` property of the contexts to fail with e.g. a key error because the DAG gets truncated for them. More importantly Spack configure options don't make any sense for externals. Now we exit early, and leave a message in the module file clarifying that this package has been installed outside of Spack.
Diffstat (limited to 'lib/spack')
-rw-r--r--lib/spack/spack/modules/common.py12
-rw-r--r--lib/spack/spack/test/modules/lmod.py10
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py
index f5cbacc078..89f6234705 100644
--- a/lib/spack/spack/modules/common.py
+++ b/lib/spack/spack/modules/common.py
@@ -457,16 +457,24 @@ class BaseContext(tengine.Context):
def configure_options(self):
pkg = self.spec.package
+ # If the spec is external Spack doesn't know its configure options
+ if self.spec.external:
+ msg = 'unknown, software installed outside of Spack'
+ return msg
+
# This is quite simple right now, but contains information on how
# to call different build system classes.
for attr in ('configure_args', 'cmake_args'):
try:
configure_args = getattr(pkg, attr)()
return ' '.join(configure_args)
- except (AttributeError, IOError):
+ except (AttributeError, IOError, KeyError):
+ # The method doesn't exist in the current spec,
+ # or it's not usable
pass
- # The default is to return None
+ # Returning a false-like value makes the default templates skip
+ # the configure option section
return None
@tengine.context_property
diff --git a/lib/spack/spack/test/modules/lmod.py b/lib/spack/spack/test/modules/lmod.py
index 06dbaa9fb0..afc7ddb518 100644
--- a/lib/spack/spack/test/modules/lmod.py
+++ b/lib/spack/spack/test/modules/lmod.py
@@ -236,3 +236,13 @@ class TestLmod(object):
content = modulefile_content('mpileaks arch=x86-linux')
assert 'Override even better!' in content
+
+ @pytest.mark.usefixtures('config')
+ def test_external_configure_args(
+ self, factory
+ ):
+ # If this package is detected as an external, its configure option line
+ # in the module file starts with 'unknown'
+ writer, spec = factory('externaltool')
+
+ assert 'unknown' in writer.context.configure_options