Skip to content

Commit 81ec7cc

Browse files
authored
Merge pull request easybuilders#2091 from bartoldeman/exclude_more_deps
Exclude dependencies of dependencies that extend $MODULEPATH
2 parents b86b991 + ee19b00 commit 81ec7cc

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

easybuild/framework/easyblock.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
from easybuild.tools.filetools import verify_checksum, weld_paths
7272
from easybuild.tools.run import run_cmd
7373
from easybuild.tools.jenkins import write_to_xml
74-
from easybuild.tools.module_generator import ModuleGeneratorLua, ModuleGeneratorTcl, module_generator
74+
from easybuild.tools.module_generator import ModuleGeneratorLua, ModuleGeneratorTcl, module_generator, dependencies_for
7575
from easybuild.tools.module_naming_scheme.utilities import det_full_ec_version
7676
from easybuild.tools.modules import ROOT_ENV_VAR_NAME_PREFIX, VERSION_ENV_VAR_NAME_PREFIX, DEVEL_ENV_VAR_NAME_PREFIX
7777
from easybuild.tools.modules import invalidate_module_caches_for, get_software_root, get_software_root_env_var_name
@@ -946,7 +946,15 @@ def make_module_dep(self, unload_info=None):
946946
full_mod_subdir, deps)
947947
self.log.debug("List of excluded deps: %s", excluded_deps)
948948

949+
# load modules that open up the module tree before checking deps of deps (in reverse order)
950+
self.modules_tool.load(excluded_deps[::-1])
951+
949952
deps = [d for d in deps if d not in excluded_deps]
953+
for dep in excluded_deps:
954+
excluded_dep_deps = dependencies_for(dep, self.modules_tool)
955+
self.log.debug("List of dependencies for excluded dependency %s: %s" % (dep, excluded_dep_deps))
956+
deps = [d for d in deps if d not in excluded_dep_deps]
957+
950958
self.log.debug("List of retained deps to load in generated module: %s" % deps)
951959
recursive_unload = self.cfg['recursive_module_unload']
952960

test/framework/easyblock.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,45 @@ def test_make_module_dep(self):
421421
expected = tc_load + '\n\n' + fftw_load + '\n\n' + lapack_load
422422
self.assertEqual(eb.make_module_dep(unload_info=unload_info).strip(), expected)
423423

424+
def test_make_module_dep_hmns(self):
425+
"""Test for make_module_dep under HMNS"""
426+
test_ecs_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
427+
all_stops = [x[0] for x in EasyBlock.get_steps()]
428+
build_options = {
429+
'check_osdeps': False,
430+
'robot_path': [test_ecs_path],
431+
'valid_stops': all_stops,
432+
'validate': False,
433+
}
434+
os.environ['EASYBUILD_MODULE_NAMING_SCHEME'] = 'HierarchicalMNS'
435+
init_config(build_options=build_options)
436+
self.setup_hierarchical_modules()
437+
438+
self.contents = '\n'.join([
439+
'easyblock = "ConfigureMake"',
440+
'name = "pi"',
441+
'version = "3.14"',
442+
'homepage = "http://example.com"',
443+
'description = "test easyconfig"',
444+
"toolchain = {'name': 'goolf', 'version': '1.4.10'}",
445+
'dependencies = [',
446+
" ('GCC', '4.7.2', '', True),"
447+
" ('hwloc', '1.6.2', '', ('GCC', '4.7.2')),",
448+
" ('OpenMPI', '1.6.4', '', ('GCC', '4.7.2')),"
449+
']',
450+
])
451+
self.writeEC()
452+
eb = EasyBlock(EasyConfig(self.eb_file))
453+
454+
eb.installdir = os.path.join(config.install_path(), 'pi', '3.14')
455+
eb.check_readiness_step()
456+
457+
# GCC, OpenMPI and hwloc modules should *not* be included in loads for dependencies
458+
mod_dep_txt = eb.make_module_dep()
459+
for mod in ['GCC/4.7.2', 'OpenMPI/1.6.4', 'hwloc/1.6.2']:
460+
regex = re.compile('load.*%s' % mod)
461+
self.assertFalse(regex.search(mod_dep_txt), "Pattern '%s' found in: %s" % (regex.pattern, mod_dep_txt))
462+
424463
def test_extensions_step(self):
425464
"""Test the extensions_step"""
426465
self.contents = '\n'.join([

0 commit comments

Comments
 (0)