summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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