Skip to content

Commit c7f1fe6

Browse files
authored
Merge pull request #3326 from ComputeCanada/fix_tweak_versionsuffixes
Only calculate the mapping of version suffixes if they are actually used
2 parents 7027f32 + c85b9d1 commit c7f1fe6

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

easybuild/framework/easyconfig/tweak.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,11 @@ def map_common_versionsuffixes(software_name, original_toolchain, toolchain_mapp
909909
if original_suffix in versionsuffix_mappings:
910910
if mapped_suffix != versionsuffix_mappings[original_suffix]:
911911
raise EasyBuildError("No unique versionsuffix mapping for %s in %s toolchain "
912-
"hierarchy to %s toolchain hierarchy", original_suffix,
913-
original_toolchain, toolchain_mapping[original_toolchain['name']])
912+
"hierarchy to %s toolchain hierarchy (mapped suffix was %s but "
913+
"versionsuffix mappings were %s)",
914+
original_suffix, original_toolchain,
915+
toolchain_mapping[original_toolchain['name']], mapped_suffix,
916+
versionsuffix_mappings)
914917
else:
915918
versionsuffix_mappings[original_suffix] = mapped_suffix
916919

@@ -953,8 +956,9 @@ def map_easyconfig_to_target_tc_hierarchy(ec_spec, toolchain_mapping, targetdir=
953956
parsed_ec = process_easyconfig(ec_spec, validate=False)[0]['ec']
954957

955958
versonsuffix_mapping = {}
956-
957-
if update_dep_versions:
959+
# We only need to map versionsuffixes if we are updating dependency versions and if there are
960+
# versionsuffixes being used in dependencies
961+
if update_dep_versions and list_deps_versionsuffixes(ec_spec):
958962
# We may need to update the versionsuffix if it is like, for example, `-Python-2.7.8`
959963
versonsuffix_mapping = map_common_versionsuffixes('Python', parsed_ec['toolchain'], toolchain_mapping)
960964

@@ -1061,6 +1065,31 @@ def map_easyconfig_to_target_tc_hierarchy(ec_spec, toolchain_mapping, targetdir=
10611065
return tweaked_spec
10621066

10631067

1068+
def list_deps_versionsuffixes(ec_spec):
1069+
"""
1070+
Take an easyconfig spec, parse it, extracts the list of version suffixes used in its dependencies
1071+
1072+
:param ec_spec: location of original easyconfig file
1073+
1074+
:return: The list of versionsuffixes used by the dependencies of this recipe
1075+
"""
1076+
# Fully parse the original easyconfig
1077+
parsed_ec = process_easyconfig(ec_spec, validate=False)[0]['ec']
1078+
1079+
versionsuffix_list = []
1080+
for key in DEPENDENCY_PARAMETERS:
1081+
val = parsed_ec[key]
1082+
1083+
if key in parsed_ec.iterate_options:
1084+
val = flatten(val)
1085+
1086+
for dep in val:
1087+
if dep['versionsuffix']:
1088+
versionsuffix_list += [dep['versionsuffix']]
1089+
1090+
return list(set(versionsuffix_list))
1091+
1092+
10641093
def find_potential_version_mappings(dep, toolchain_mapping, versionsuffix_mapping=None, highest_versions_only=True):
10651094
"""
10661095
Find potential version mapping for a dependency in a new hierarchy

test/framework/tweak.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from easybuild.framework.easyconfig.tweak import get_matching_easyconfig_candidates, map_toolchain_hierarchies
4141
from easybuild.framework.easyconfig.tweak import find_potential_version_mappings
4242
from easybuild.framework.easyconfig.tweak import map_easyconfig_to_target_tc_hierarchy
43+
from easybuild.framework.easyconfig.tweak import list_deps_versionsuffixes
4344
from easybuild.tools.build_log import EasyBuildError
4445
from easybuild.tools.config import module_classes
4546
from easybuild.tools.filetools import change_dir, write_file
@@ -482,6 +483,24 @@ def test_map_easyconfig_to_target_tc_hierarchy(self):
482483
hit_extension += 1
483484
self.assertEqual(hit_extension, 1, "Should only have updated one extension")
484485

486+
def test_list_deps_versionsuffixes(self):
487+
"""Test listing of dependencies' version suffixes"""
488+
test_easyconfigs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
489+
build_options = {
490+
'robot_path': [test_easyconfigs],
491+
'silent': True,
492+
'valid_module_classes': module_classes(),
493+
}
494+
init_config(build_options=build_options)
495+
get_toolchain_hierarchy.clear()
496+
497+
ec_spec = os.path.join(test_easyconfigs, 'g', 'golf', 'golf-2018a.eb')
498+
self.assertEqual(list_deps_versionsuffixes(ec_spec), ['-serial'])
499+
ec_spec = os.path.join(test_easyconfigs, 't', 'toy', 'toy-0.0-deps.eb')
500+
self.assertEqual(list_deps_versionsuffixes(ec_spec), [])
501+
ec_spec = os.path.join(test_easyconfigs, 'g', 'gzip', 'gzip-1.4-GCC-4.6.3.eb')
502+
self.assertEqual(list_deps_versionsuffixes(ec_spec), ['-deps'])
503+
485504
def suite():
486505
""" return all the tests in this file """
487506
return TestLoaderFiltered().loadTestsFromTestCase(TweakTest, sys.argv[1:])

0 commit comments

Comments
 (0)