Skip to content

Commit da5e0a2

Browse files
committed
Do not create module in sanity check of extensioneasyblock
Using the "fake module environment" creates a module file. However in `--module-only` setups we want to use the real module file instead. This also avoids potentially loading the real AND the fake module.
1 parent cb6ea0b commit da5e0a2

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

easybuild/framework/easyblock.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,6 +2408,31 @@ def fake_module_environment(self, extra_modules=None, with_build_deps=False):
24082408
if fake_mod_data:
24092409
self.clean_up_fake_module(fake_mod_data)
24102410

2411+
@contextmanager
2412+
def sanity_check_module_environment(self, extra_modules=None, with_build_deps=False, check_loaded=True):
2413+
"""Load/Unload module for performing sanity checks"""
2414+
if self.sanity_check_module_loaded and check_loaded:
2415+
raise EasyBuildError("Sanity check module is already loaded and must not be loaded again")
2416+
2417+
if self.sanity_check_module_loaded:
2418+
unload_module = False
2419+
else:
2420+
if with_build_deps:
2421+
# load modules for build dependencies as extra modules
2422+
extra_modules = [dep['short_mod_name'] for dep in self.cfg.dependencies(build_only=True)]
2423+
self.sanity_check_load_module(extension=self.is_extension, extra_modules=extra_modules)
2424+
unload_module = True
2425+
2426+
try:
2427+
yield
2428+
finally:
2429+
# cleanup (unload fake module, remove fake module dir)
2430+
if unload_module:
2431+
if self.fake_mod_data:
2432+
self.clean_up_fake_module(self.fake_mod_data)
2433+
self.fake_mod_data = None
2434+
self.sanity_check_module_loaded = False
2435+
24112436
def guess_start_dir(self):
24122437
"""
24132438
Return the directory where to start the whole configure/make/make install cycle from

easybuild/framework/extensioneasyblock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def sanity_check_step(self, exts_filter=None, custom_paths=None, custom_commands
181181
# take into account that module may already be loaded earlier in sanity check
182182
if not (self.sanity_check_module_loaded or self.is_extension or self.dry_run):
183183
for extra_modules in lists_of_extra_modules:
184-
with self.fake_module_environment(extra_modules=extra_modules):
184+
with self.sanity_check_module_environment(extra_modules=extra_modules):
185185
if extra_modules:
186186
info_msg = f"Running extension sanity check with extra modules: {', '.join(extra_modules)}"
187187
self.log.info(info_msg)

0 commit comments

Comments
 (0)