Skip to content

Commit daf0bac

Browse files
authored
Merge pull request #5150 from Flamefire/arch-dict-doc
Document where architecture dicts are allowed in easyconfig parameters & fix version templates for removed dependencies
2 parents 46f609f + 7c82aab commit daf0bac

3 files changed

Lines changed: 48 additions & 49 deletions

File tree

easybuild/framework/easyconfig/default.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@
134134
'sanity_check_commands': [[], ("format: [(name, options)] e.g. [('gzip','-h')]. "
135135
"Using a non-tuple is equivalent to (name, '-h')"), BUILD],
136136
'sanity_check_paths': [{}, ("List of files and directories to check "
137-
"(format: {'files':<list>, 'dirs':<list>})"), BUILD],
137+
"(format: {'files':<list>, 'dirs':<list>}). "
138+
"Architecture-specific list items are supported."), BUILD],
138139
'skip': [False, "Skip existing software", BUILD],
139140
'skip_mod_files_sanity_check': [False, "Skip the check for .mod files in a GCCcore level install", BUILD],
140141
'skipsteps': [[], "Skip these steps", BUILD],
@@ -169,8 +170,10 @@
169170

170171
# DEPENDENCIES easyconfig parameters
171172
'allow_system_deps': [[], "Allow listed system dependencies (format: (<name>, <version>))", DEPENDENCIES],
172-
'builddependencies': [[], "List of build dependencies", DEPENDENCIES],
173-
'dependencies': [[], "List of dependencies", DEPENDENCIES],
173+
'builddependencies': [[], ("List of build dependencies. Architecture-specific versions are supported "
174+
"with 'False' to exclude the dependency"), DEPENDENCIES],
175+
'dependencies': [[], ("List of dependencies. Architecture-specific versions are supported "
176+
"with 'False' to exclude the dependency"), DEPENDENCIES],
174177
'hiddendependencies': [[], "List of dependencies available as hidden modules", DEPENDENCIES],
175178
'multi_deps': [{}, "Dict of lists of dependency versions over which to iterate", DEPENDENCIES],
176179
'multi_deps_load_default': [True, "Load module for first version listed in multi_deps by default", DEPENDENCIES],

easybuild/framework/easyconfig/templates.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,15 @@ def template_constant_dict(config, ignore=None, toolchain=None):
440440
if isinstance(dep_name, str) and dep_version:
441441
pref = name_to_prefix.get(dep_name.lower())
442442
if pref:
443+
# Resolve version if not already done
443444
dep_version = pick_dep_version(dep_version)
444-
template_values['%sver' % pref] = dep_version
445-
dep_version_parts = dep_version.split('.')
446-
template_values['%smajver' % pref] = dep_version_parts[0]
447-
if len(dep_version_parts) > 1:
448-
template_values['%sminver' % pref] = dep_version_parts[1]
449-
template_values['%sshortver' % pref] = '.'.join(dep_version_parts[:2])
445+
if dep_version:
446+
template_values['%sver' % pref] = dep_version
447+
dep_version_parts = dep_version.split('.')
448+
template_values['%smajver' % pref] = dep_version_parts[0]
449+
if len(dep_version_parts) > 1:
450+
template_values['%sminver' % pref] = dep_version_parts[1]
451+
template_values['%sshortver' % pref] = '.'.join(dep_version_parts[:2])
450452

451453
# step 2.1: CUDA templates in NVHPC
452454
if toolchain is not None and hasattr(toolchain, 'name') and toolchain.name in TEMPLATE_CUDA_VERSION_NVHPC:

test/framework/easyconfig.py

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3676,18 +3676,22 @@ def test_template_constant_dict(self):
36763676
my_arch = st.get_cpu_architecture()
36773677

36783678
# add Java dep with version specified using a dict value
3679-
toy_ec_txt += '\n'.join([
3680-
"dependencies += [",
3681-
" ('Python', '3.7.2'),"
3682-
" ('Java', {",
3683-
" 'arch=%s': '1.8.0_221'," % my_arch,
3684-
" 'arch=fooarch': '1.8.0-foo',",
3685-
" })",
3686-
"]",
3687-
"builddependencies = [",
3688-
" ('CMake', '3.18.4'),",
3689-
"]",
3690-
])
3679+
toy_ec_txt += textwrap.dedent("""
3680+
dependencies += [
3681+
('Python', '3.7.2'),
3682+
('Java', {
3683+
'arch=<arch>': '1.8.0_221',
3684+
'arch=fooarch': '1.8.0-foo',
3685+
}),
3686+
('Perl', {
3687+
'arch=<arch>': False,
3688+
'arch=fooarch': '1.42',
3689+
}),
3690+
]
3691+
builddependencies = [
3692+
('CMake', '3.18.4'),
3693+
]
3694+
""").replace('<arch>', my_arch)
36913695

36923696
test_ec = os.path.join(self.test_prefix, 'test.eb')
36933697
write_file(test_ec, toy_ec_txt)
@@ -3722,39 +3726,29 @@ def test_template_constant_dict(self):
37223726
}
37233727

37243728
# proper EasyConfig instance
3725-
ec = EasyConfig(test_ec)
3726-
3727-
# CMake should *not* be included, since it's a build-only dependency
3728-
dep_names = [x['name'] for x in ec['dependencies']]
3729-
self.assertFalse('CMake' in dep_names, "CMake should not be included in list of dependencies: %s" % dep_names)
3730-
res = template_constant_dict(ec)
3731-
dep_names = [x['name'] for x in ec['dependencies']]
3732-
self.assertFalse('CMake' in dep_names, "CMake should not be included in list of dependencies: %s" % dep_names)
3733-
3734-
self.assertIn('arch', res)
3735-
arch = res.pop('arch')
3736-
self.assertTrue(arch_regex.match(arch), "'%s' matches with pattern '%s'" % (arch, arch_regex.pattern))
3737-
3738-
self.assertEqual(res, expected)
3739-
3729+
full_ec = EasyConfig(test_ec)
3730+
expected_full = expected
37403731
# only perform shallow/quick parse (as is done in list_software function)
3741-
ec = EasyConfigParser(filename=test_ec).get_config_dict()
3742-
3743-
expected['module_name'] = None
3732+
shallow_ec = EasyConfigParser(filename=test_ec).get_config_dict()
3733+
expected_shallow = expected.copy()
3734+
expected_shallow['module_name'] = None
37443735
for key in ('bitbucket_account', 'github_account', 'versionprefix'):
3745-
del expected[key]
3736+
del expected_shallow[key]
37463737

3747-
dep_names = [x[0] for x in ec['dependencies']]
3748-
self.assertFalse('CMake' in dep_names, "CMake should not be included in list of dependencies: %s" % dep_names)
3749-
res = template_constant_dict(ec)
3750-
dep_names = [x[0] for x in ec['dependencies']]
3751-
self.assertFalse('CMake' in dep_names, "CMake should not be included in list of dependencies: %s" % dep_names)
3738+
for name, ec, expected in (('Full', full_ec, expected_full), ('Shallow', shallow_ec, expected_shallow)):
3739+
with self.subTest(f'{name} easyconfig'):
3740+
# CMake should *not* be included, since it's a build-only dependency
3741+
dep_names = [x['name'] if isinstance(x, dict) else x[0] for x in ec['dependencies']]
3742+
self.assertNotIn('CMake', dep_names)
37523743

3753-
self.assertIn('arch', res)
3754-
arch = res.pop('arch')
3755-
self.assertTrue(arch_regex.match(arch), "'%s' matches with pattern '%s'" % (arch, arch_regex.pattern))
3744+
res = template_constant_dict(ec)
3745+
self.assertIn('arch', res)
3746+
arch = res.pop('arch')
3747+
self.assertRegex(arch, arch_regex)
37563748

3757-
self.assertEqual(res, expected)
3749+
self.assertNotIn('perlver', res, "Perl should be filtered out")
3750+
3751+
self.assertEqual(res, expected)
37583752

37593753
# also check result of template_constant_dict when dict representing extension is passed
37603754
ext_dict = {

0 commit comments

Comments
 (0)