Skip to content

Commit e763c30

Browse files
committed
determine initial set of template values without passing Toolchain instance, roll back workaround in test_resolve_dependencies_minimal w.r.t. use of %(version_minor)s template to define toolchain version
1 parent c6b0048 commit e763c30

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

easybuild/framework/easyconfig/easyconfig.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,15 +1459,30 @@ def generate_template_values(self):
14591459

14601460
def _generate_template_values(self, ignore=None):
14611461
"""Actual code to generate the template values"""
1462-
if self.template_values is None:
1463-
self.template_values = {}
14641462

14651463
# step 0. self.template_values can/should be updated from outside easyconfig
1466-
# (eg the run_setp code in EasyBlock)
1464+
# (eg the run_step code in EasyBlock)
14671465

14681466
# step 1-3 work with easyconfig.templates constants
14691467
# disable templating with creating dict with template values to avoid looping back to here via __getitem__
14701468
prev_enable_templating = self.enable_templating
1469+
1470+
self.enable_templating = False
1471+
1472+
if self.template_values is None:
1473+
# if no template values are set yet, initiate with a minimal set of template values;
1474+
# this is important for easyconfig that use %(version_minor)s to define 'toolchain',
1475+
# which is a pretty weird use case, but fine...
1476+
self.template_values = template_constant_dict(self, ignore=ignore)
1477+
1478+
self.enable_templating = prev_enable_templating
1479+
1480+
# grab toolchain instance with templating support enabled,
1481+
# which is important in case the Toolchain instance was not created yet
1482+
toolchain = self.toolchain
1483+
1484+
# get updated set of template values, now with toolchain instance
1485+
# (which is used to define the %(mpi_cmd_prefix)s template)
14711486
self.enable_templating = False
14721487
template_values = template_constant_dict(self, ignore=ignore, toolchain=self.toolchain)
14731488
self.enable_templating = prev_enable_templating

test/framework/robot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def test_resolve_dependencies_minimal(self):
432432
" ('SQLite', '3.8.10.2'),",
433433
"]",
434434
# toolchain as list line, for easy modification later;
435-
"toolchain = {'name': 'foss', 'version': '2018a'}",
435+
"toolchain = {'name': 'foss', 'version': '%(version_minor)s018a'}",
436436
]
437437
write_file(barec, '\n'.join(barec_lines))
438438
bar = process_easyconfig(barec)[0]

0 commit comments

Comments
 (0)