Skip to content

Commit cc96e4e

Browse files
committed
When iterating, make all iteropts except builddependencies lists
Since some easyblocks, e.g. `CMakeMake` modify `self.cfg['configopts']` it's safer to start afresh for every iteration. This PR implements this by turning options like these, if not already lists, into lists with identical element copies, e.g. `[self.cfg['configopts']] * <number_of_iterations>` This modification does not affect the logic of iterative `builddependencies` itself since it is used in some other places in the code.
1 parent 68a38e5 commit cc96e4e

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

easybuild/framework/easyblock.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2380,8 +2380,13 @@ def handle_iterate_opts(self):
23802380
# only needs to be done during first iteration, since after that the options won't be lists anymore
23812381
if self.iter_idx == 0:
23822382
# keep track of list, supply first element as first option to handle
2383+
iter_cnt = self.det_iter_cnt()
23832384
for opt in self.cfg.iterate_options:
2384-
self.iter_opts[opt] = self.cfg[opt] # copy
2385+
if isinstance(self.cfg[opt], (list, tuple)):
2386+
self.iter_opts[opt] = self.cfg[opt] # copy
2387+
elif iter_cnt > 1:
2388+
# make iter_cnt copies for every opt since easyblocks can modify them
2389+
self.iter_opts[opt] = [self.cfg[opt]] * iter_cnt
23852390
self.log.debug("Found list for %s: %s", opt, self.iter_opts[opt])
23862391

23872392
if self.iter_opts:

easybuild/framework/easyconfig/easyconfig.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,14 +1037,8 @@ def validate_iterate_opts_lists(self):
10371037
def start_iterating(self):
10381038
"""Start iterative mode."""
10391039

1040-
for opt in ITERATE_OPTIONS:
1041-
# builddpendencies is already handled, see __init__
1042-
if opt == 'builddependencies':
1043-
continue
1044-
1045-
# list of values indicates that this is a value to iterate over
1046-
if isinstance(self[opt], (list, tuple)):
1047-
self.iterate_options.append(opt)
1040+
# builddependencies is already handled, see __init__
1041+
self.iterate_options.extend([opt for opt in ITERATE_OPTIONS if opt != 'builddependencies'])
10481042

10491043
# keep track of when we're iterating (used by builddependencies())
10501044
self.iterating = True

0 commit comments

Comments
 (0)