Skip to content

Commit 6401880

Browse files
authored
Merge pull request #3940 from Flamefire/20250923173504_new_pr_bundle
Fix unresolved templates in modextravars/paths of components
2 parents e74370b + 08284b6 commit 6401880

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

easybuild/easyblocks/generic/bundle.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
import easybuild.tools.environment as env
4141
from easybuild.framework.easyblock import EasyBlock
4242
from easybuild.framework.easyconfig import CUSTOM
43-
from easybuild.framework.easyconfig.default import DEFAULT_CONFIG
43+
from easybuild.framework.easyconfig.default import get_easyconfig_parameter_default
44+
from easybuild.framework.easyconfig.default import is_easyconfig_parameter_default_value
4445
from easybuild.framework.easyconfig.easyconfig import get_easyblock_class
4546
from easybuild.tools.build_log import EasyBuildError, print_msg
4647
from easybuild.tools.config import build_option
@@ -131,24 +132,6 @@ def __init__(self, *args, **kwargs):
131132
if len(comp) == 3:
132133
comp_specs = comp[2]
133134

134-
comp_cfg = self.cfg.copy()
135-
136-
comp_cfg['name'] = comp_name
137-
comp_cfg['version'] = comp_version
138-
139-
# The copy above may include unexpected settings for common values.
140-
# In particular for a Pythonbundle we have seen a component inheriting
141-
# runtest = True
142-
# which is not a valid value for many easyblocks.
143-
# Reset runtest to the original default, if people want the test step
144-
# they can set it explicitly, in default_component_specs or by the component easyblock
145-
if comp_cfg._config['runtest'] != DEFAULT_CONFIG["runtest"]:
146-
self.log.warning(
147-
"Resetting runtest to default value for component easyblock "
148-
f"(from {comp_cfg._config['runtest']})."
149-
)
150-
comp_cfg._config['runtest'] = DEFAULT_CONFIG["runtest"]
151-
152135
# determine easyblock to use for this component
153136
# - if an easyblock is specified explicitly, that will be used
154137
# - if not, a software-specific easyblock will be considered by get_easyblock_class
@@ -170,27 +153,45 @@ def __init__(self, *args, **kwargs):
170153
if easyblock == 'Bundle':
171154
raise EasyBuildError("The Bundle easyblock can not be used to install components in a bundle")
172155

156+
comp_cfg = self.cfg.copy()
173157
comp_cfg.easyblock = easyblock_class
174158

175159
# make sure that extra easyconfig parameters are known, so they can be set
176160
extra_opts = comp_cfg.easyblock.extra_options()
177161
comp_cfg.extend_params(copy.deepcopy(extra_opts))
178162

179-
comp_cfg.generate_template_values()
163+
# The copy above may include unexpected settings for common values.
164+
# In particular for a Pythonbundle we have seen a component inheriting
165+
# runtest = True
166+
# which is not a valid value for many easyblocks.
167+
# Reset runtest to the original default, if people want the test step
168+
# they can set it explicitly, in default_component_specs or by the component easyblock
169+
if not is_easyconfig_parameter_default_value('runtest', comp_cfg.get('runtest', resolve=False)):
170+
self.log.warning(
171+
"Resetting runtest to default value for component easyblock "
172+
f"(from {comp_cfg.get('runtest', resolve=False)})."
173+
)
174+
comp_cfg['runtest'] = get_easyconfig_parameter_default('runtest')
180175

181-
# do not inherit easyblock to use from parent
182-
# (since that would result in an infinite loop in install_step)
183-
comp_cfg['easyblock'] = None
176+
# Reset others to their default value
177+
# Inheriting easyblock would lead to an infinite loop in the install step
178+
for var in ('easyblock',
179+
'sources', 'source_urls', 'checksums',
180+
'patches', 'postinstallpatches',
181+
'modextravars', 'modextrapaths'):
182+
comp_cfg[var] = copy.deepcopy(get_easyconfig_parameter_default(var))
184183

185-
# reset list of sources/source_urls/checksums
186-
comp_cfg['sources'] = comp_cfg['source_urls'] = comp_cfg['checksums'] = comp_cfg['patches'] = []
184+
comp_cfg['name'] = comp_name
185+
comp_cfg['version'] = comp_version
187186

188187
for key in self.cfg['default_component_specs']:
189188
comp_cfg[key] = self.cfg['default_component_specs'][key]
190189

191190
for key in comp_specs:
192191
comp_cfg[key] = comp_specs[key]
193192

193+
comp_cfg.generate_template_values()
194+
194195
# Don't require that all template values can be resolved at this point but still resolve them.
195196
# This is important to ensure that template values like %(name)s and %(version)s
196197
# are correctly resolved with the component name/version before values are copied over to self.cfg

0 commit comments

Comments
 (0)