Skip to content

Commit b9f33ea

Browse files
committed
Allow tweaking of ECs from different toolchains
This is useful to bulk-install e.g. Python with enable_lto=False set for all ECs. The restriction is only required when changing the toolchain so move the check down and add a simple test.
1 parent fcab3eb commit b9f33ea

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

easybuild/framework/easyconfig/tweak.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,7 @@ def tweak(easyconfigs, build_specs, modtool, targetdirs=None):
9191
tweaked_ecs_path, tweaked_ecs_deps_path = None, None
9292
if targetdirs is not None:
9393
tweaked_ecs_path, tweaked_ecs_deps_path = targetdirs
94-
# make sure easyconfigs all feature the same toolchain (otherwise we *will* run into trouble)
95-
toolchains = nub(['%(name)s/%(version)s' % ec['ec']['toolchain'] for ec in easyconfigs])
96-
if len(toolchains) > 1:
97-
raise EasyBuildError("Multiple toolchains featured in easyconfigs, --try-X not supported in that case: %s",
98-
toolchains)
99-
# Toolchain is unique, let's store it
100-
source_toolchain = easyconfigs[-1]['ec']['toolchain']
10194
modifying_toolchains_or_deps = False
102-
target_toolchain = {}
10395
src_to_dst_tc_mapping = {}
10496
revert_to_regex = False
10597

@@ -117,6 +109,16 @@ def tweak(easyconfigs, build_specs, modtool, targetdirs=None):
117109
revert_to_regex = True
118110

119111
if not revert_to_regex:
112+
# make sure easyconfigs all feature the same toolchain (otherwise we *will* run into trouble)
113+
toolchains = nub(['%(name)s/%(version)s' % ec['ec']['toolchain'] for ec in easyconfigs])
114+
if len(toolchains) > 1:
115+
raise EasyBuildError("Multiple toolchains featured in easyconfigs, "
116+
"--try-X not supported in that case: %s",
117+
toolchains)
118+
# Toolchain is unique, let's store it
119+
source_toolchain = easyconfigs[-1]['ec']['toolchain']
120+
target_toolchain = {}
121+
120122
# we're doing something that involves the toolchain hierarchy;
121123
# obtain full dependency graph for specified easyconfigs;
122124
# easyconfigs will be ordered 'top-to-bottom' (toolchains and dependencies appearing first)

test/framework/easyconfig.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@
5757
from easybuild.framework.easyconfig.parser import EasyConfigParser, fetch_parameters_from_easyconfig
5858
from easybuild.framework.easyconfig.templates import template_constant_dict, to_template_str
5959
from easybuild.framework.easyconfig.style import check_easyconfigs_style
60-
from easybuild.framework.easyconfig.tools import categorize_files_by_type, check_sha256_checksums, dep_graph
61-
from easybuild.framework.easyconfig.tools import det_copy_ec_specs, find_related_easyconfigs, get_paths_for
60+
from easybuild.framework.easyconfig.tools import alt_easyconfig_paths, categorize_files_by_type, check_sha256_checksums
61+
from easybuild.framework.easyconfig.tools import dep_graph, det_copy_ec_specs, find_related_easyconfigs, get_paths_for
6262
from easybuild.framework.easyconfig.tools import parse_easyconfigs
63-
from easybuild.framework.easyconfig.tweak import obtain_ec_for, tweak_one
63+
from easybuild.framework.easyconfig.tweak import obtain_ec_for, tweak, tweak_one
6464
from easybuild.framework.extension import resolve_exts_filter_template
6565
from easybuild.toolchains.system import SystemToolchain
6666
from easybuild.tools.build_log import EasyBuildError
@@ -73,7 +73,7 @@
7373
from easybuild.tools.module_naming_scheme.utilities import det_full_ec_version
7474
from easybuild.tools.options import parse_external_modules_metadata
7575
from easybuild.tools.py2vs3 import OrderedDict, reload
76-
from easybuild.tools.robot import resolve_dependencies
76+
from easybuild.tools.robot import det_robot_path, resolve_dependencies
7777
from easybuild.tools.systemtools import AARCH64, KNOWN_ARCH_CONSTANTS, POWER, X86_64
7878
from easybuild.tools.systemtools import get_cpu_architecture, get_shared_lib_ext, get_os_name, get_os_version
7979

@@ -728,6 +728,38 @@ def test_tweaking(self):
728728
# cleanup
729729
os.remove(tweaked_fn)
730730

731+
def test_tweak_multiple_tcs(self):
732+
"""Test that tweaking variables of ECs from multiple toolchains works"""
733+
test_easyconfigs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
734+
735+
# Create directories to store the tweaked easyconfigs
736+
tweaked_ecs_paths, pr_path = alt_easyconfig_paths(self.test_prefix, tweaked_ecs=True)
737+
robot_path = det_robot_path([test_easyconfigs], tweaked_ecs_paths, pr_path, auto_robot=True)
738+
739+
init_config(build_options={
740+
'valid_module_classes': module_classes(),
741+
'robot_path': robot_path,
742+
'check_osdeps': False,
743+
})
744+
745+
# Allow tweaking of non-toolchain values for multiple ECs of different toolchains
746+
untweaked_openmpi_1 = os.path.join(test_easyconfigs, 'o', 'OpenMPI', 'OpenMPI-2.1.2-GCC-4.6.4.eb')
747+
untweaked_openmpi_2 = os.path.join(test_easyconfigs, 'o', 'OpenMPI', 'OpenMPI-3.1.1-GCC-7.3.0-2.30.eb')
748+
easyconfigs, _ = parse_easyconfigs([(untweaked_openmpi_1, False), (untweaked_openmpi_2, False)])
749+
tweak_specs = {'moduleclass': 'debugger'}
750+
easyconfigs = tweak(easyconfigs, tweak_specs, self.modtool, targetdirs=tweaked_ecs_paths)
751+
# Check that all expected tweaked easyconfigs exists
752+
tweaked_openmpi_1 = os.path.join(tweaked_ecs_paths[0], os.path.basename(untweaked_openmpi_1))
753+
tweaked_openmpi_2 = os.path.join(tweaked_ecs_paths[0], os.path.basename(untweaked_openmpi_2))
754+
self.assertTrue(os.path.isfile(tweaked_openmpi_1))
755+
self.assertTrue(os.path.isfile(tweaked_openmpi_2))
756+
tweaked_openmpi_content_1 = read_file(tweaked_openmpi_1)
757+
tweaked_openmpi_content_2 = read_file(tweaked_openmpi_2)
758+
self.assertTrue('moduleclass = "debugger"' in tweaked_openmpi_content_1,
759+
"Tweaked value not found in " + tweaked_openmpi_content_1)
760+
self.assertTrue('moduleclass = "debugger"' in tweaked_openmpi_content_2,
761+
"Tweaked value not found in " + tweaked_openmpi_content_2)
762+
731763
def test_installversion(self):
732764
"""Test generation of install version."""
733765

0 commit comments

Comments
 (0)