Skip to content

Commit

Permalink
Merge pull request #1498 from boegel/extra_options_extension
Browse files Browse the repository at this point in the history
[bugfix] make sure that extra custom easyconfig parameters are known for extensions
  • Loading branch information
boegel committed Dec 4, 2015
2 parents 8b9a59b + 66f9d1a commit 6227bd3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
30 changes: 23 additions & 7 deletions easybuild/framework/easyconfig/easyconfig.py
Expand Up @@ -161,15 +161,10 @@ def __init__(self, path, extra_options=None, build_specs=None, validate=True, hi
tup = (type(self.extra_options), self.extra_options)
self.log.nosupport("extra_options return value should be of type 'dict', found '%s': %s" % tup, '2.0')

# deep copy to make sure self.extra_options remains unchanged
self._config.update(copy.deepcopy(self.extra_options))

self.mandatory = MANDATORY_PARAMS[:]

# extend mandatory keys
for key, value in self.extra_options.items():
if value[2] == MANDATORY:
self.mandatory.append(key)
# deep copy to make sure self.extra_options remains unchanged
self.extend_params(copy.deepcopy(self.extra_options))

# set valid stops
self.valid_stops = build_option('valid_stops')
Expand Down Expand Up @@ -220,6 +215,27 @@ def __init__(self, path, extra_options=None, build_specs=None, validate=True, hi

self.software_license = None

def extend_params(self, extra, overwrite=True):
"""Extend list of known parameters via provided list of extra easyconfig parameters."""

self.log.debug("Extending list of known easyconfig parameters with: %s", ' '.join(extra.keys()))

if overwrite:
self._config.update(extra)
else:
for key in extra:
if key not in self._config:
self._config[key] = extra[key]
self.log.debug("Added new easyconfig parameter: %s", key)
else:
self.log.debug("Easyconfig parameter %s already known, not overwriting", key)

# extend mandatory keys
for key, value in extra.items():
if value[2] == MANDATORY:
self.mandatory.append(key)
self.log.debug("Updated list of mandatory easyconfig parameters: %s", self.mandatory)

def copy(self):
"""
Return a copy of this EasyConfig instance.
Expand Down
4 changes: 4 additions & 0 deletions easybuild/framework/extensioneasyblock.py
Expand Up @@ -80,6 +80,10 @@ def __init__(self, *args, **kwargs):
self.installdir = self.master.installdir
self.is_extension = True
self.unpack_options = None

# make sure that extra custom easyconfig parameters are known
extra_params = self.__class__.extra_options()
self.cfg.extend_params(extra_params, overwrite=False)
else:
EasyBlock.__init__(self, *args, **kwargs)
self.options = copy.deepcopy(self.cfg.get('options', {})) # we need this for Extension.sanity_check_step
Expand Down

0 comments on commit 6227bd3

Please sign in to comment.