3333import stat
3434
3535from easybuild .easyblocks .generic .bundle import Bundle
36+ from easybuild .framework .easyconfig import CUSTOM
37+ from easybuild .tools .build_log import EasyBuildError
3638from easybuild .tools .filetools import adjust_permissions , apply_regex_substitutions , copy_dir
3739from easybuild .tools .toolchain .toolchain import RPATH_WRAPPERS_SUBDIR
3840
@@ -42,6 +44,15 @@ class BuildEnv(Bundle):
4244 Build environment of toolchain: only generate module file
4345 """
4446
47+ @staticmethod
48+ def extra_options ():
49+ """Add extra easyconfig parameters for Boost."""
50+ extra_vars = {
51+ 'python_executable' : ['python3' , "Python executable to use for the wrappers (use None to use path to "
52+ "Python executable used by EasyBuild)." , CUSTOM ],
53+ }
54+ return Bundle .extra_options (extra_vars )
55+
4556 def prepare_step (self , * args , ** kwargs ):
4657 """
4758 Custom prepare step for buildenv: export rpath wrappers if they are being used
@@ -63,10 +74,14 @@ def install_step(self, *args, **kwargs):
6374 self .rpath_wrappers_dir = os .path .join (self .installdir , 'bin' )
6475 rpath_wrappers_path = os .path .join (self .rpath_wrappers_dir , RPATH_WRAPPERS_SUBDIR )
6576 copy_dir (wrappers_dir , rpath_wrappers_path )
66- wrapper_files = list (filter (os .path .isfile , glob .glob (os .path .join (rpath_wrappers_path , '*' , '*' ))))
67- # replace path to Python executable with python3 in the wrappers,
68- # as this is the executable that runs EasyBuild and may be unavailable when using the buildenv wrappers.
69- apply_regex_substitutions (wrapper_files , [(r'^PYTHON_EXE=.*$' , 'PYTHON_EXE=python3' )], backup = False )
77+ py_exe = self .cfg ['python_executable' ]
78+ if py_exe is not None :
79+ if not isinstance (py_exe , str ) or not py_exe :
80+ raise EasyBuildError (f"python_executable should be None or non-empty string, got { py_exe } " )
81+ wrapper_files = list (filter (os .path .isfile , glob .glob (os .path .join (rpath_wrappers_path , '*' , '*' ))))
82+ # replace path to Python executable with python_executable in the wrappers,
83+ # as this is the executable that runs EasyBuild and may be unavailable when using the buildenv wrappers.
84+ apply_regex_substitutions (wrapper_files , [(r'^PYTHON_EXE=.*$' , f'PYTHON_EXE={ py_exe } ' )], backup = False )
7085 # Make sure wrappers are readable/executable by everyone
7186 adjust_permissions (
7287 self .rpath_wrappers_dir ,
0 commit comments