Skip to content

Commit

Permalink
Merge pull request #1863 from boegel/filter_deps_minimal_toolchains
Browse files Browse the repository at this point in the history
honor --filter-deps under --minimal-toolchains
  • Loading branch information
boegel authored Aug 4, 2016
2 parents de753b3 + fb0e712 commit f87558e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions easybuild/framework/easyconfig/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@ def _parse_dependency(self, dep, hidden=False, build_only=False):
def _finalize_dependencies(self):
"""Finalize dependency parameters, after initial parsing."""

filter_deps = build_option('filter_deps')

for key in DEPENDENCY_PARAMETERS:
# loop over a *copy* of dependency dicts (with resolved templates);
# to update the original dep dict, we need to index with idx into self._config[key][0]...
Expand All @@ -857,6 +859,10 @@ def _finalize_dependencies(self):
# reference to original dep dict, this is the one we should be updating
orig_dep = self._config[key][0][idx]

if filter_deps and orig_dep['name'] in filter_deps:
self.log.debug("Skipping filtered dependency %s when finalising dependencies", orig_dep['name'])
continue

# minimize toolchains for dependencies with inherited toolchain, if requested
# this *must* be done after parsing all dependencies, to avoid problems with templates like %(pyver)s
if dep['toolchain_inherited'] and build_option('minimal_toolchains'):
Expand Down
25 changes: 25 additions & 0 deletions test/framework/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,31 @@ def test_filter_deps(self):
opts = init_config(args=['--filter-deps=zlib,ncurses'])
self.assertEqual(opts.filter_deps, ['zlib', 'ncurses'])

# make sure --filter-deps is honored when combined with --minimal-toolchains,
# i.e. that toolchain for dependencies which are filtered out is not being minized
build_options = {
'external_modules_metadata': ConfigObj(),
'minimal_toolchains': True,
'robot_path': [test_ecs_dir],
'valid_module_classes': module_classes(),
}
init_config(build_options=build_options)

ec_file = os.path.join(self.test_prefix, 'test.eb')
shutil.copy2(os.path.join(test_ecs_dir, 'OpenMPI-1.6.4-GCC-4.6.4.eb'), ec_file)

ec_txt = read_file(ec_file)
ec_txt = ec_txt.replace('hwloc', 'deptobefiltered')
write_file(ec_file, ec_txt)

self.assertErrorRegex(EasyBuildError, "No easyconfig for .* that matches toolchain hierarchy",
EasyConfig, ec_file, validate=False)

build_options.update({'filter_deps': ['deptobefiltered']})
init_config(build_options=build_options)
ec = EasyConfig(ec_file, validate=False)
self.assertEqual(ec.dependencies(), [])

def test_replaced_easyconfig_parameters(self):
"""Test handling of replaced easyconfig parameters."""
test_ecs_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs')
Expand Down

0 comments on commit f87558e

Please sign in to comment.