Skip to content

Commit 7fd37c0

Browse files
authored
Merge pull request #3377 from boegel/easyconfig_copy_template_values
also copy template values in EasyConfig.copy method to ensure they are defined when installing extensions
2 parents eedcfc8 + ae0f797 commit 7fd37c0

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

easybuild/framework/easyblock.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,7 @@ def install_step(self):
21332133
"""Install built software (abstract method)."""
21342134
raise NotImplementedError
21352135

2136-
def extensions_step(self, fetch=False):
2136+
def extensions_step(self, fetch=False, install=True):
21372137
"""
21382138
After make install, run this.
21392139
- only if variable len(exts_list) > 0
@@ -2147,7 +2147,7 @@ def extensions_step(self, fetch=False):
21472147

21482148
# load fake module
21492149
fake_mod_data = None
2150-
if not self.dry_run:
2150+
if install and not self.dry_run:
21512151

21522152
# load modules for build dependencies as extra modules
21532153
build_dep_mods = [dep['short_mod_name'] for dep in self.cfg.dependencies(build_only=True)]
@@ -2260,11 +2260,12 @@ def extensions_step(self, fetch=False):
22602260
rpath_filter_dirs=self.rpath_filter_dirs)
22612261

22622262
# real work
2263-
ext.prerun()
2264-
txt = ext.run()
2265-
if txt:
2266-
self.module_extra_extensions += txt
2267-
ext.postrun()
2263+
if install:
2264+
ext.prerun()
2265+
txt = ext.run()
2266+
if txt:
2267+
self.module_extra_extensions += txt
2268+
ext.postrun()
22682269

22692270
# cleanup (unload fake module, remove fake module dir)
22702271
if fake_mod_data:

easybuild/framework/easyconfig/easyconfig.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,9 @@ def copy(self, validate=None):
570570
if self.path:
571571
ec.path = self.path
572572

573+
# also copy template values, since re-generating them may not give the same set of template values straight away
574+
ec.template_values = copy.deepcopy(self.template_values)
575+
573576
return ec
574577

575578
def update(self, key, value, allow_duplicate=True):

test/framework/easyconfig.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,11 +2665,16 @@ def test_copy(self):
26652665
test_easyconfigs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
26662666
ec1 = EasyConfig(os.path.join(test_easyconfigs, 't', 'toy', 'toy-0.0.eb'))
26672667

2668+
# inject fake template value, just to check whether they are copied over too
2669+
ec1.template_values['pyshortver'] = '3.7'
2670+
26682671
ec2 = ec1.copy()
26692672

26702673
self.assertEqual(ec1, ec2)
26712674
self.assertEqual(ec1.rawtxt, ec2.rawtxt)
26722675
self.assertEqual(ec1.path, ec2.path)
2676+
self.assertEqual(ec1.template_values, ec2.template_values)
2677+
self.assertFalse(ec1.template_values is ec2.template_values)
26732678

26742679
def test_eq_hash(self):
26752680
"""Test comparing two EasyConfig instances."""
@@ -3531,6 +3536,14 @@ def test_iter_builddeps_templates(self):
35313536

35323537
test_ec = os.path.join(self.test_prefix, 'test.eb')
35333538
test_ec_txt = toy_ec_txt + "\nmulti_deps = {'Python': ['2.7.15', '3.6.6']}"
3539+
3540+
# inject extension that uses %(pyshortver)s, to check whether the template value is properly resolved
3541+
test_ec_txt += '\n'.join([
3542+
'',
3543+
"exts_defaultclass = 'Toy_Extension'",
3544+
"exts_list = [('bar', '0.0', {'preinstallopts': 'echo \\'py%(pyshortver)s\\' && '})]",
3545+
])
3546+
35343547
write_file(test_ec, test_ec_txt)
35353548

35363549
ec = EasyConfig(test_ec)
@@ -3562,6 +3575,14 @@ def test_iter_builddeps_templates(self):
35623575
self.assertTrue('pyshortver' in ec.template_values)
35633576
self.assertEqual(ec.template_values['pyshortver'], '3.6')
35643577

3578+
# check that extensions inherit these template values too
3579+
# cfr. https://github.com/easybuilders/easybuild-framework/issues/3317
3580+
eb = EasyBlock(ec)
3581+
eb.silent = True
3582+
eb.extensions_step(fetch=True, install=False)
3583+
ext = eb.ext_instances[0]
3584+
self.assertEqual(ext.cfg['preinstallopts'], "echo 'py3.6' && ")
3585+
35653586
def test_fix_deprecated_easyconfigs(self):
35663587
"""Test fix_deprecated_easyconfigs function."""
35673588
test_ecs_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')

0 commit comments

Comments
 (0)