Skip to content

Commit 8e3a5da

Browse files
author
Alan O'Cais
committed
Add a build option to trigger ignoring versionsuffixes when updating deps
1 parent b3dafa0 commit 8e3a5da

File tree

4 files changed

+73
-9
lines changed

4 files changed

+73
-9
lines changed

easybuild/framework/easyconfig/tweak.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ def tweak(easyconfigs, build_specs, modtool, targetdirs=None):
124124
pruned_build_specs = copy.copy(build_specs)
125125

126126
update_dependencies = pruned_build_specs.pop('update_deps', None)
127+
ignore_versionsuffixes = pruned_build_specs.pop('ignore_versionsuffixes', None)
128+
if ignore_versionsuffixes and not update_dependencies:
129+
print_warning("--try-ignore-versionsuffixes is ignored if --try-update-deps is not True")
130+
ignore_versionsuffixes = False
127131
if 'toolchain' in pruned_build_specs:
128132
target_toolchain = pruned_build_specs.pop('toolchain')
129133
pruned_build_specs.pop('toolchain_name', '')
@@ -195,7 +199,8 @@ def tweak(easyconfigs, build_specs, modtool, targetdirs=None):
195199
new_ec_file = map_easyconfig_to_target_tc_hierarchy(orig_ec['spec'], src_to_dst_tc_mapping,
196200
targetdir=tweaked_ecs_path,
197201
update_build_specs=pruned_build_specs,
198-
update_dep_versions=update_dependencies)
202+
update_dep_versions=update_dependencies,
203+
ignore_versionsuffixes=ignore_versionsuffixes)
199204
# Need to update the toolchain in the build_specs to match the toolchain mapping
200205
keys = verification_build_specs.keys()
201206
if 'toolchain_name' in keys:
@@ -217,7 +222,8 @@ def tweak(easyconfigs, build_specs, modtool, targetdirs=None):
217222
# Note pruned_build_specs are not passed down for dependencies
218223
map_easyconfig_to_target_tc_hierarchy(orig_ec['spec'], src_to_dst_tc_mapping,
219224
targetdir=tweaked_ecs_deps_path,
220-
update_dep_versions=update_dependencies)
225+
update_dep_versions=update_dependencies,
226+
ignore_versionsuffixes=ignore_versionsuffixes)
221227
else:
222228
tweak_one(orig_ec['spec'], None, build_specs, targetdir=tweaked_ecs_deps_path)
223229

@@ -939,7 +945,7 @@ def get_matching_easyconfig_candidates(prefix_stub, toolchain):
939945

940946

941947
def map_easyconfig_to_target_tc_hierarchy(ec_spec, toolchain_mapping, targetdir=None, update_build_specs=None,
942-
update_dep_versions=False):
948+
update_dep_versions=False, ignore_versionsuffixes=False):
943949
"""
944950
Take an easyconfig spec, parse it, map it to a target toolchain and dump it out
945951
@@ -1033,8 +1039,12 @@ def map_easyconfig_to_target_tc_hierarchy(ec_spec, toolchain_mapping, targetdir=
10331039
elif update_dep_versions:
10341040
# search for available updates for this dependency:
10351041
# first get highest version candidate paths for this (include search through subtoolchains)
1036-
potential_version_mappings = find_potential_version_mappings(dep, toolchain_mapping,
1037-
versionsuffix_mapping=versonsuffix_mapping)
1042+
potential_version_mappings = find_potential_version_mappings(
1043+
dep,
1044+
toolchain_mapping,
1045+
versionsuffix_mapping=versonsuffix_mapping,
1046+
ignore_versionsuffixes=ignore_versionsuffixes
1047+
)
10381048
# only highest version match is retained by default in potential_version_mappings,
10391049
# compare that version to the original version and replace if appropriate (upgrades only).
10401050
if potential_version_mappings:
@@ -1091,7 +1101,7 @@ def list_deps_versionsuffixes(ec_spec):
10911101

10921102

10931103
def find_potential_version_mappings(dep, toolchain_mapping, versionsuffix_mapping=None, highest_versions_only=True,
1094-
ignore_versionsuffix=False):
1104+
ignore_versionsuffixes=False):
10951105
"""
10961106
Find potential version mapping for a dependency in a new hierarchy
10971107
@@ -1207,7 +1217,7 @@ def find_potential_version_mappings(dep, toolchain_mapping, versionsuffix_mappin
12071217

12081218
exclude_alternate_versionsuffixes = False
12091219
if ignored_versionsuffix_greater:
1210-
if ignore_versionsuffix:
1220+
if ignore_versionsuffixes:
12111221
highest_version = highest_version_ignoring_versionsuffix
12121222
else:
12131223
print_warning(

easybuild/tools/options.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ def software_options(self):
320320
opts['try-update-deps'] = ("Try to update versions of the dependencies of an easyconfig based on what is "
321321
"available in the robot path",
322322
None, 'store_true', False)
323+
opts['try-ignore-versionsuffixes'] = ("Ignore versionsuffix differences when --try-update-deps is used",
324+
None, 'store_true', False)
323325

324326
self.log.debug("software_options: descr %s opts %s" % (descr, opts))
325327
self.add_group_parser(opts, descr)
@@ -1490,7 +1492,8 @@ def process_software_build_specs(options):
14901492
'version': options.try_software_version,
14911493
'toolchain_name': options.try_toolchain_name,
14921494
'toolchain_version': options.try_toolchain_version,
1493-
'update_deps': options.try_update_deps
1495+
'update_deps': options.try_update_deps,
1496+
'ignore_versionsuffixes': options.try_ignore_versionsuffixes,
14941497
}
14951498

14961499
# process easy options

test/framework/options.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,57 @@ def test_try_update_deps(self):
12771277
regex = re.compile(pattern, re.M)
12781278
self.assertTrue(regex.search(outtxt), "Pattern '%s' should be found in: %s" % (regex.pattern, outtxt))
12791279

1280+
# construct another toy easyconfig that is well suited for testing ignoring versionsuffix
1281+
test_ectxt = '\n'.join([
1282+
"easyblock = 'ConfigureMake'",
1283+
'',
1284+
"name = 'test'",
1285+
"version = '1.2.3'",
1286+
''
1287+
"homepage = 'https://test.org'",
1288+
"description = 'this is just a test'",
1289+
'',
1290+
"toolchain = {'name': 'GCC', 'version': '4.8.2'}",
1291+
'',
1292+
"dependencies = [('OpenBLAS', '0.2.8', '-LAPACK-3.4.2')]",
1293+
])
1294+
write_file(test_ec, test_ectxt)
1295+
self.mock_stderr(True)
1296+
outtxt = self.eb_main(args, raise_error=True, do_build=True)
1297+
errtxt = self.get_stderr()
1298+
warning_stub = "\nWARNING: There may be newer version(s) of dep 'OpenBLAS' available with a different " \
1299+
"versionsuffix to '-LAPACK-3.4.2'"
1300+
self.mock_stderr(False)
1301+
self.assertTrue(warning_stub in errtxt)
1302+
patterns = [
1303+
# toolchain got updated
1304+
r"^ \* \[x\] .*/test_ecs/g/GCC/GCC-6.4.0-2.28.eb \(module: GCC/6.4.0-2.28\)$",
1305+
# no version update for OpenBLAS (because there's no corresponding ec using GCC/6.4.0-2.28 (sub)toolchain)
1306+
r"^ \* \[ \] .*/tweaked_dep_easyconfigs/OpenBLAS-0.2.8-GCC-6.4.0-2.28-LAPACK-3.4.2.eb "
1307+
r"\(module: OpenBLAS/0.2.8-GCC-6.4.0-2.28-LAPACK-3.4.2\)$",
1308+
# also generated easyconfig for test/1.2.3 with expected toolchain
1309+
r"^ \* \[ \] .*/tweaked_easyconfigs/test-1.2.3-GCC-6.4.0-2.28.eb \(module: test/1.2.3-GCC-6.4.0-2.28\)$",
1310+
]
1311+
for pattern in patterns:
1312+
regex = re.compile(pattern, re.M)
1313+
self.assertTrue(regex.search(outtxt), "Pattern '%s' should be found in: %s" % (regex.pattern, outtxt))
1314+
1315+
# Now verify that we can ignore versionsuffixes
1316+
args.append('--try-ignore-versionsuffixes')
1317+
outtxt = self.eb_main(args, raise_error=True, do_build=True)
1318+
patterns = [
1319+
# toolchain got updated
1320+
r"^ \* \[x\] .*/test_ecs/g/GCC/GCC-6.4.0-2.28.eb \(module: GCC/6.4.0-2.28\)$",
1321+
# no version update for OpenBLAS (because there's no corresponding ec using GCC/6.4.0-2.28 (sub)toolchain)
1322+
r"^ \* \[x\] .*/test_ecs/o/OpenBLAS/OpenBLAS-0.2.20-GCC-6.4.0-2.28.eb "
1323+
r"\(module: OpenBLAS/0.2.20-GCC-6.4.0-2.28\)$",
1324+
# also generated easyconfig for test/1.2.3 with expected toolchain
1325+
r"^ \* \[ \] .*/tweaked_easyconfigs/test-1.2.3-GCC-6.4.0-2.28.eb \(module: test/1.2.3-GCC-6.4.0-2.28\)$",
1326+
]
1327+
for pattern in patterns:
1328+
regex = re.compile(pattern, re.M)
1329+
self.assertTrue(regex.search(outtxt), "Pattern '%s' should be found in: %s" % (regex.pattern, outtxt))
1330+
12801331
def test_dry_run_hierarchical(self):
12811332
"""Test dry run using a hierarchical module naming scheme."""
12821333
fd, dummylogfn = tempfile.mkstemp(prefix='easybuild-dummy', suffix='.log')

test/framework/tweak.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ def test_find_potential_version_mappings(self):
405405
self.mock_stderr(False)
406406
self.assertTrue(errtxt.startswith(warning_stub))
407407
self.assertEqual(len(potential_versions), 0)
408-
potential_versions = find_potential_version_mappings(openblas_dep, tc_mapping, ignore_versionsuffix=True)
408+
potential_versions = find_potential_version_mappings(openblas_dep, tc_mapping, ignore_versionsuffixes=True)
409409
self.assertEqual(len(potential_versions), 1)
410410
expected = {
411411
'path': os.path.join(test_easyconfigs, 'o', 'OpenBLAS', 'OpenBLAS-0.2.20-GCC-6.4.0-2.28.eb'),

0 commit comments

Comments
 (0)