@@ -636,34 +636,36 @@ def pre_fetch_hook_unsupported_modules(self, *args, **kwargs):
636636def pre_module_hook_unsupported_module (self , * args , ** kwargs ):
637637 """Make module load-able during module step"""
638638 ignore_lmoderror_envvar = is_unsupported_module (self )
639- if ignore_lmoderror_envvar and hasattr (self , 'initial_environ' ):
640- # Allow the module to be loaded in the module step (which uses initial environment)
641- print_msg (f"Setting { ignore_lmoderror_envvar } in initial environment" )
642- self .initial_environ [ignore_lmoderror_envvar ] = "1"
639+ if ignore_lmoderror_envvar :
640+ if hasattr (self , 'initial_environ' ):
641+ # Allow the module to be loaded in the module step (which uses initial environment)
642+ print_msg (f"Setting { ignore_lmoderror_envvar } in initial environment" )
643+ self .initial_environ [ignore_lmoderror_envvar ] = "1"
643644
644645
645646def post_module_hook_unsupported_module (self , * args , ** kwargs ):
646647 """Revert changes from pre_fetch_hook_unsupported_modules"""
647648 ignore_lmoderror_envvar = is_unsupported_module (self )
648- if hasattr (self , EESSI_MODULE_ONLY_ATTR ):
649- update_build_option ('module_only' , getattr (self , EESSI_MODULE_ONLY_ATTR ))
650- print_msg ("Restored original build option 'module_only' to %s" % getattr (self , EESSI_MODULE_ONLY_ATTR ))
651- else :
652- raise EasyBuildError ("Cannot restore module_only to it's original value: 'self' is missing attribute %s." ,
653- EESSI_MODULE_ONLY_ATTR )
649+ if ignore_lmoderror_envvar :
650+ if hasattr (self , EESSI_MODULE_ONLY_ATTR ):
651+ update_build_option ('module_only' , getattr (self , EESSI_MODULE_ONLY_ATTR ))
652+ print_msg ("Restored original build option 'module_only' to %s" % getattr (self , EESSI_MODULE_ONLY_ATTR ))
653+ else :
654+ raise EasyBuildError ("Cannot restore module_only to it's original value: 'self' is missing attribute %s." ,
655+ EESSI_MODULE_ONLY_ATTR )
654656
655- if hasattr (self , EESSI_FORCE_ATTR ):
656- update_build_option ('force' , getattr (self , EESSI_FORCE_ATTR ))
657- print_msg ("Restored original build option 'force' to %s" % getattr (self , EESSI_FORCE_ATTR ))
658- else :
659- raise EasyBuildError ("Cannot restore force to it's original value: 'self' is misisng attribute %s." ,
660- EESSI_FORCE_ATTR )
657+ if hasattr (self , EESSI_FORCE_ATTR ):
658+ update_build_option ('force' , getattr (self , EESSI_FORCE_ATTR ))
659+ print_msg ("Restored original build option 'force' to %s" % getattr (self , EESSI_FORCE_ATTR ))
660+ else :
661+ raise EasyBuildError ("Cannot restore force to it's original value: 'self' is misisng attribute %s." ,
662+ EESSI_FORCE_ATTR )
661663
662- # If the variable to allow loading is set, remove it
663- if ignore_lmoderror_envvar and hasattr (self , 'initial_environ' ):
664- if self .initial_environ .get (ignore_lmoderror_envvar , False ):
665- print_msg (f"Removing { ignore_lmoderror_envvar } in initial environment" )
666- del self .initial_environ [ignore_lmoderror_envvar ]
664+ # If the variable to allow loading is set, remove it
665+ if hasattr (self , 'initial_environ' ):
666+ if self .initial_environ .get (ignore_lmoderror_envvar , False ):
667+ print_msg (f"Removing { ignore_lmoderror_envvar } in initial environment" )
668+ del self .initial_environ [ignore_lmoderror_envvar ]
667669
668670
669671def post_easyblock_hook_copy_easybuild_subdir (self , * args , ** kwargs ):
@@ -1526,8 +1528,7 @@ def pre_module_hook(self, *args, **kwargs):
15261528 PRE_MODULE_HOOKS [self .name ](self , * args , ** kwargs )
15271529
15281530 # Always trigger this one, regardless of self.name
1529- if is_unsupported_module (self ):
1530- pre_module_hook_unsupported_module (self , * args , ** kwargs )
1531+ pre_module_hook_unsupported_module (self , * args , ** kwargs )
15311532
15321533
15331534def post_module_hook (self , * args , ** kwargs ):
@@ -1536,8 +1537,7 @@ def post_module_hook(self, *args, **kwargs):
15361537 POST_MODULE_HOOKS [self .name ](self , * args , ** kwargs )
15371538
15381539 # Always trigger this one, regardless of self.name
1539- if is_unsupported_module (self ):
1540- post_module_hook_unsupported_module (self , * args , ** kwargs )
1540+ post_module_hook_unsupported_module (self , * args , ** kwargs )
15411541
15421542
15431543# The post_easyblock_hook was introduced in EasyBuild 5.1.1.
0 commit comments