diff --git a/easybuild/framework/easyconfig/tweak.py b/easybuild/framework/easyconfig/tweak.py index df3d39f343..60ed4e2c22 100644 --- a/easybuild/framework/easyconfig/tweak.py +++ b/easybuild/framework/easyconfig/tweak.py @@ -909,8 +909,11 @@ def map_common_versionsuffixes(software_name, original_toolchain, toolchain_mapp if original_suffix in versionsuffix_mappings: if mapped_suffix != versionsuffix_mappings[original_suffix]: raise EasyBuildError("No unique versionsuffix mapping for %s in %s toolchain " - "hierarchy to %s toolchain hierarchy", original_suffix, - original_toolchain, toolchain_mapping[original_toolchain['name']]) + "hierarchy to %s toolchain hierarchy (mapped suffix was %s but " + "versionsuffix mappings were %s)", + original_suffix, original_toolchain, + toolchain_mapping[original_toolchain['name']], mapped_suffix, + versionsuffix_mappings) else: versionsuffix_mappings[original_suffix] = mapped_suffix @@ -953,8 +956,9 @@ def map_easyconfig_to_target_tc_hierarchy(ec_spec, toolchain_mapping, targetdir= parsed_ec = process_easyconfig(ec_spec, validate=False)[0]['ec'] versonsuffix_mapping = {} - - if update_dep_versions: + # We only need to map versionsuffixes if we are updating dependency versions and if there are + # versionsuffixes being used in dependencies + if update_dep_versions and list_deps_versionsuffixes(ec_spec): # We may need to update the versionsuffix if it is like, for example, `-Python-2.7.8` versonsuffix_mapping = map_common_versionsuffixes('Python', parsed_ec['toolchain'], toolchain_mapping) @@ -1061,6 +1065,31 @@ def map_easyconfig_to_target_tc_hierarchy(ec_spec, toolchain_mapping, targetdir= return tweaked_spec +def list_deps_versionsuffixes(ec_spec): + """ + Take an easyconfig spec, parse it, extracts the list of version suffixes used in its dependencies + + :param ec_spec: location of original easyconfig file + + :return: The list of versionsuffixes used by the dependencies of this recipe + """ + # Fully parse the original easyconfig + parsed_ec = process_easyconfig(ec_spec, validate=False)[0]['ec'] + + versionsuffix_list = [] + for key in DEPENDENCY_PARAMETERS: + val = parsed_ec[key] + + if key in parsed_ec.iterate_options: + val = flatten(val) + + for dep in val: + if dep['versionsuffix']: + versionsuffix_list += [dep['versionsuffix']] + + return list(set(versionsuffix_list)) + + def find_potential_version_mappings(dep, toolchain_mapping, versionsuffix_mapping=None, highest_versions_only=True): """ Find potential version mapping for a dependency in a new hierarchy diff --git a/test/framework/tweak.py b/test/framework/tweak.py index e0660cc96b..16cd6ee31e 100644 --- a/test/framework/tweak.py +++ b/test/framework/tweak.py @@ -40,6 +40,7 @@ from easybuild.framework.easyconfig.tweak import get_matching_easyconfig_candidates, map_toolchain_hierarchies from easybuild.framework.easyconfig.tweak import find_potential_version_mappings from easybuild.framework.easyconfig.tweak import map_easyconfig_to_target_tc_hierarchy +from easybuild.framework.easyconfig.tweak import list_deps_versionsuffixes from easybuild.tools.build_log import EasyBuildError from easybuild.tools.config import module_classes from easybuild.tools.filetools import change_dir, write_file @@ -482,6 +483,24 @@ def test_map_easyconfig_to_target_tc_hierarchy(self): hit_extension += 1 self.assertEqual(hit_extension, 1, "Should only have updated one extension") + def test_list_deps_versionsuffixes(self): + """Test listing of dependencies' version suffixes""" + test_easyconfigs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs') + build_options = { + 'robot_path': [test_easyconfigs], + 'silent': True, + 'valid_module_classes': module_classes(), + } + init_config(build_options=build_options) + get_toolchain_hierarchy.clear() + + ec_spec = os.path.join(test_easyconfigs, 'g', 'golf', 'golf-2018a.eb') + self.assertEqual(list_deps_versionsuffixes(ec_spec), ['-serial']) + ec_spec = os.path.join(test_easyconfigs, 't', 'toy', 'toy-0.0-deps.eb') + self.assertEqual(list_deps_versionsuffixes(ec_spec), []) + ec_spec = os.path.join(test_easyconfigs, 'g', 'gzip', 'gzip-1.4-GCC-4.6.3.eb') + self.assertEqual(list_deps_versionsuffixes(ec_spec), ['-deps']) + def suite(): """ return all the tests in this file """ return TestLoaderFiltered().loadTestsFromTestCase(TweakTest, sys.argv[1:])