9898from easybuild .tools .filetools import is_sha256_checksum , mkdir , move_file , move_logs , read_file , remove_dir
9999from easybuild .tools .filetools import remove_file , remove_lock , symlink , verify_checksum , weld_paths , write_file
100100from easybuild .tools .hooks import (
101- BUILD_STEP , CLEANUP_STEP , CONFIGURE_STEP , EXTENSIONS_STEP , EXTRACT_STEP , FETCH_STEP , INSTALL_STEP , MODULE_STEP ,
102- MODULE_WRITE , PACKAGE_STEP , PATCH_STEP , PERMISSIONS_STEP , POSTITER_STEP , POSTPROC_STEP , PREPARE_STEP , READY_STEP ,
103- SANITYCHECK_STEP , SINGLE_EXTENSION , TEST_STEP , TESTCASES_STEP , load_hooks , run_hook ,
101+ BUILD_STEP , CLEANUP_STEP , CONFIGURE_STEP , EASYBLOCK , EXTENSIONS_STEP , EXTRACT_STEP , FETCH_STEP , INSTALL_STEP ,
102+ MODULE_STEP , MODULE_WRITE , PACKAGE_STEP , PATCH_STEP , PERMISSIONS_STEP , POSTITER_STEP , POSTPROC_STEP , PREPARE_STEP ,
103+ READY_STEP , SANITYCHECK_STEP , SINGLE_EXTENSION , TEST_STEP , TESTCASES_STEP , load_hooks , run_hook ,
104104)
105105from easybuild .tools .run import RunShellCmdError , raise_run_shell_cmd_error , run_shell_cmd
106106from easybuild .tools .jenkins import write_to_xml
@@ -448,7 +448,7 @@ def get_checksum_for(self, checksums, filename=None, index=None):
448448 if checksum and chksum_input_git is not None :
449449 # ignore any checksum for given filename due to changes in https://github.com/python/cpython/issues/90021
450450 # tarballs made for git repos are not reproducible when created with Python < 3.9
451- if sys .version_info [ 0 ] >= 3 and sys . version_info [ 1 ] < 9 :
451+ if sys .version_info < ( 3 , 9 ) :
452452 print_warning (
453453 "Reproducible tarballs of Git repos are only possible when using Python 3.9+ to run EasyBuild. "
454454 f"Skipping checksum verification of { chksum_input } since Python < 3.9 is used."
@@ -2830,8 +2830,6 @@ def patch_step(self, beginpath=None, patches=None):
28302830 self .log .info ("Applying patch %s" % patch ['name' ])
28312831 trace_msg ("applying patch %s" % patch ['name' ])
28322832
2833- # patch source at specified index (first source if not specified)
2834- srcind = patch .get ('source' , 0 )
28352833 # if patch level is specified, use that (otherwise let apply_patch derive patch level)
28362834 level = patch .get ('level' , None )
28372835 # determine suffix of source path to apply patch in (if any)
@@ -2840,16 +2838,14 @@ def patch_step(self, beginpath=None, patches=None):
28402838 copy_patch = 'copy' in patch and 'sourcepath' not in patch
28412839 options = patch .get ('opts' , None ) # Extra options for patch command
28422840
2843- self .log .debug ("Source index: %s; patch level: %s; source path suffix: %s; copy patch: %s; options: %s" ,
2844- srcind , level , srcpathsuffix , copy_patch , options )
2841+ self .log .debug ("Patch level: %s; source path suffix: %s; copy patch: %s; options: %s" ,
2842+ level , srcpathsuffix , copy_patch , options )
28452843
28462844 if beginpath is None :
2847- try :
2848- beginpath = self .src [srcind ]['finalpath' ]
2849- self .log .debug ("Determine begin path for patch %s: %s" % (patch ['name' ], beginpath ))
2850- except IndexError as err :
2851- raise EasyBuildError ("Can't apply patch %s to source at index %s of list %s: %s" ,
2852- patch ['name' ], srcind , self .src , err )
2845+ if not self .src :
2846+ raise EasyBuildError ("Can't apply patch %s to source if no sources are given" , patch ['name' ])
2847+ beginpath = self .src [0 ]['finalpath' ]
2848+ self .log .debug ("Determined begin path for patch %s: %s" % (patch ['name' ], beginpath ))
28532849 else :
28542850 self .log .debug ("Using specified begin path for patch %s: %s" % (patch ['name' ], beginpath ))
28552851
@@ -4662,18 +4658,19 @@ def run_step(self, step, step_methods):
46624658 run_hook (step , self .hooks , pre_step_hook = True , args = [self ])
46634659
46644660 for step_method in step_methods :
4661+ # step_method is a lambda function that takes an EasyBlock instance as an argument,
4662+ # and returns the actual method
4663+ current_method = step_method (self )
46654664 # Remove leading underscore from e.g. "_test_step"
4666- method_name = '_' . join ( step_method . __code__ . co_names ) .lstrip ('_' )
4665+ method_name = current_method . __name__ .lstrip ('_' )
46674666 self .log .info ("Running method %s part of step %s" , method_name , step )
46684667
46694668 if self .dry_run :
46704669 self .dry_run_msg ("[%s method]" , method_name )
46714670
46724671 # if an known possible error occurs, just report it and continue
46734672 try :
4674- # step_method is a lambda function that takes an EasyBlock instance as an argument,
4675- # and returns the actual method, so use () to execute it
4676- step_method (self )()
4673+ current_method ()
46774674 except Exception as err :
46784675 if build_option ('extended_dry_run_ignore_errors' ):
46794676 dry_run_warning ("ignoring error %s" % err , silent = self .silent )
@@ -4682,9 +4679,7 @@ def run_step(self, step, step_methods):
46824679 raise
46834680 self .dry_run_msg ('' )
46844681 else :
4685- # step_method is a lambda function that takes an EasyBlock instance as an argument,
4686- # and returns the actual method, so use () to execute it
4687- step_method (self )()
4682+ current_method ()
46884683
46894684 run_hook (step , self .hooks , post_step_hook = True , args = [self ])
46904685
@@ -5001,6 +4996,8 @@ def build_and_install_one(ecdict, init_env):
50014996 _log .debug ("Skip set to %s" % skip )
50024997 app .cfg ['skip' ] = skip
50034998
4999+ hooks = load_hooks (build_option ('hooks' ))
5000+
50045001 # build easyconfig
50055002 error_msg = '(no error)'
50065003 exit_code = None
@@ -5022,6 +5019,8 @@ def build_and_install_one(ecdict, init_env):
50225019 else :
50235020 enabled_write_permissions = False
50245021
5022+ run_hook (EASYBLOCK , hooks , pre_step_hook = True , args = [app ])
5023+
50255024 result = app .run_all_steps (run_test_cases = run_test_cases )
50265025
50275026 if not dry_run :
@@ -5127,6 +5126,8 @@ def ensure_writable_log_dir(log_dir):
51275126 except EasyBuildError as err :
51285127 _log .warning ("Unable to commit easyconfig to repository: %s" , err )
51295128
5129+ run_hook (EASYBLOCK , hooks , post_step_hook = True , args = [app ])
5130+
51305131 # cleanup logs
51315132 app .close_log ()
51325133
0 commit comments