Skip to content

Commit 26d1d56

Browse files
committed
add context manager to handle fake modules in EasyBlock
1 parent 3a82615 commit 26d1d56

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

easybuild/framework/easyblock.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import time
5757
import traceback
5858
from concurrent.futures import ThreadPoolExecutor
59+
from contextlib import contextmanager
5960
from datetime import datetime
6061
from string import ascii_letters
6162
from textwrap import indent
@@ -2294,6 +2295,24 @@ def start_dir(self):
22942295
"""Start directory in build directory"""
22952296
return self.cfg['start_dir']
22962297

2298+
@contextmanager
2299+
def fake_module_environment(self):
2300+
"""
2301+
Load/Unload fake module
2302+
"""
2303+
# load fake module
2304+
fake_mod_data = None
2305+
if not self.dry_run:
2306+
# load modules for build dependencies as extra modules
2307+
build_dep_mods = [dep['short_mod_name'] for dep in self.cfg.dependencies(build_only=True)]
2308+
fake_mod_data = self.load_fake_module(purge=True, extra_modules=build_dep_mods)
2309+
2310+
yield
2311+
2312+
# cleanup (unload fake module, remove fake module dir)
2313+
if fake_mod_data:
2314+
self.clean_up_fake_module(fake_mod_data)
2315+
22972316
def guess_start_dir(self):
22982317
"""
22992318
Return the directory where to start the whole configure/make/make install cycle from

0 commit comments

Comments
 (0)