@@ -2239,54 +2239,27 @@ def install_step(self):
22392239 """Install built software (abstract method)."""
22402240 raise NotImplementedError
22412241
2242- def extensions_step (self , fetch = False , install = True ):
2242+ def init_ext_instances (self ):
22432243 """
2244- After make install, run this.
2245- - only if variable len(exts_list) > 0
2246- - optionally: load module that was just created using temp module file
2247- - find source for extensions, in 'extensions' (and 'packages' for legacy reasons)
2248- - run extra_extensions
2244+ Create class instances for all extensions.
22492245 """
2250- if not self .cfg .get_ref ('exts_list' ):
2251- self .log .debug ("No extensions in exts_list" )
2252- return
2253-
2254- # load fake module
2255- fake_mod_data = None
2256- if install and not self .dry_run :
2257-
2258- # load modules for build dependencies as extra modules
2259- build_dep_mods = [dep ['short_mod_name' ] for dep in self .cfg .dependencies (build_only = True )]
2260-
2261- fake_mod_data = self .load_fake_module (purge = True , extra_modules = build_dep_mods )
22622246
2263- self .prepare_for_extensions ()
2264-
2265- if fetch :
2266- self .exts = self .fetch_extension_sources ()
2267-
2268- self .exts_all = self .exts [:] # retain a copy of all extensions, regardless of filtering/skipping
2269-
2270- # actually install extensions
2271- self .log .debug ("Installing extensions" )
2272- exts_defaultclass = self .cfg ['exts_defaultclass' ]
2247+ self .ext_instances = []
22732248 exts_classmap = self .cfg ['exts_classmap' ]
22742249
2275- # we really need a default class
2276- if not exts_defaultclass and fake_mod_data :
2277- self .clean_up_fake_module (fake_mod_data )
2278- raise EasyBuildError ("ERROR: No default extension class set for %s" , self .name )
2250+ if self .cfg ['exts_list' ] and not self .exts :
2251+ self .exts = self .fetch_extension_sources ()
22792252
22802253 # obtain name and module path for default extention class
2254+ exts_defaultclass = self .cfg ['exts_defaultclass' ]
22812255 if isinstance (exts_defaultclass , string_type ):
22822256 # proper way: derive module path from specified class name
22832257 default_class = exts_defaultclass
22842258 default_class_modpath = get_module_path (default_class , generic = True )
22852259 else :
2286- raise EasyBuildError ("Improper default extension class specification, should be string." )
2260+ error_msg = "Improper default extension class specification, should be string: %s (%s)"
2261+ raise EasyBuildError (error_msg , exts_defaultclass , type (exts_defaultclass ))
22872262
2288- # get class instances for all extensions
2289- self .ext_instances = []
22902263 for ext in self .exts :
22912264 ext_name = ext ['name' ]
22922265 self .log .debug ("Creating class instance for extension %s..." , ext_name )
@@ -2336,6 +2309,44 @@ def extensions_step(self, fetch=False, install=True):
23362309
23372310 self .ext_instances .append (inst )
23382311
2312+ def extensions_step (self , fetch = False , install = True ):
2313+ """
2314+ After make install, run this.
2315+ - only if variable len(exts_list) > 0
2316+ - optionally: load module that was just created using temp module file
2317+ - find source for extensions, in 'extensions' (and 'packages' for legacy reasons)
2318+ - run extra_extensions
2319+ """
2320+ if not self .cfg .get_ref ('exts_list' ):
2321+ self .log .debug ("No extensions in exts_list" )
2322+ return
2323+
2324+ # load fake module
2325+ fake_mod_data = None
2326+ if install and not self .dry_run :
2327+
2328+ # load modules for build dependencies as extra modules
2329+ build_dep_mods = [dep ['short_mod_name' ] for dep in self .cfg .dependencies (build_only = True )]
2330+
2331+ fake_mod_data = self .load_fake_module (purge = True , extra_modules = build_dep_mods )
2332+
2333+ self .prepare_for_extensions ()
2334+
2335+ if fetch :
2336+ self .exts = self .fetch_extension_sources ()
2337+
2338+ self .exts_all = self .exts [:] # retain a copy of all extensions, regardless of filtering/skipping
2339+
2340+ # actually install extensions
2341+ self .log .info ("Installing extensions" )
2342+
2343+ # we really need a default class
2344+ if not self .cfg ['exts_defaultclass' ] and fake_mod_data :
2345+ self .clean_up_fake_module (fake_mod_data )
2346+ raise EasyBuildError ("ERROR: No default extension class set for %s" , self .name )
2347+
2348+ self .init_ext_instances ()
2349+
23392350 if self .skip :
23402351 self .skip_extensions ()
23412352
@@ -2351,7 +2362,7 @@ def extensions_step(self, fetch=False, install=True):
23512362 print_msg ("installing extension %s %s (%d/%d)..." % tup , silent = self .silent )
23522363
23532364 if self .dry_run :
2354- tup = (ext .name , ext .version , cls .__name__ )
2365+ tup = (ext .name , ext .version , ext . __class__ .__name__ )
23552366 msg = "\n * installing extension %s %s using '%s' easyblock\n " % tup
23562367 self .dry_run_msg (msg )
23572368
@@ -2881,6 +2892,13 @@ def _sanity_check_step_dry_run(self, custom_paths=None, custom_commands=None, **
28812892 def _sanity_check_step_extensions (self ):
28822893 """Sanity check on extensions (if any)."""
28832894 failed_exts = []
2895+
2896+ # class instances for extensions may not be initialized yet here,
2897+ # for example when using --module-only or --sanity-check-only
2898+ if not self .ext_instances :
2899+ self .prepare_for_extensions ()
2900+ self .init_ext_instances ()
2901+
28842902 for ext in self .ext_instances :
28852903 success , fail_msg = None , None
28862904 res = ext .sanity_check_step ()
0 commit comments