6262from easybuild .tools .build_log import EasyBuildError , dry_run_msg , print_warning
6363from easybuild .tools .config import build_option , install_path
6464from easybuild .tools .environment import setvar
65- from easybuild .tools .filetools import adjust_permissions , find_eb_script , read_file , which , write_file
65+ from easybuild .tools .filetools import adjust_permissions , copy_file , find_eb_script , mkdir , read_file , which , write_file
6666from easybuild .tools .module_generator import dependencies_for
6767from easybuild .tools .modules import get_software_root , get_software_root_env_var_name
6868from easybuild .tools .modules import get_software_version , get_software_version_env_var_name
@@ -985,6 +985,8 @@ def prepare_rpath_wrappers(self, rpath_filter_dirs=None, rpath_include_dirs=None
985985 Put RPATH wrapper script in place for compiler and linker commands
986986
987987 :param rpath_filter_dirs: extra directories to include in RPATH filter (e.g. build dir, tmpdir, ...)
988+ :param rpath_include_dirs: extra directories to include in RPATH
989+ :param rpath_wrappers_dir: directory in which to create RPATH wrappers (tmpdir is created if None)
988990 """
989991 if get_os_type () == LINUX :
990992 self .log .info ("Putting RPATH wrappers in place..." )
@@ -994,6 +996,9 @@ def prepare_rpath_wrappers(self, rpath_filter_dirs=None, rpath_include_dirs=None
994996 if rpath_filter_dirs is None :
995997 rpath_filter_dirs = []
996998
999+ # only enable logging by RPATH wrapper scripts in debug mode
1000+ enable_wrapper_log = build_option ('debug' )
1001+
9971002 # always include filter for 'stubs' library directory,
9981003 # cfr. https://github.com/easybuilders/easybuild-framework/issues/2683
9991004 # (since CUDA 11.something the stubs are in $EBROOTCUDA/stubs/lib64)
@@ -1002,19 +1007,26 @@ def prepare_rpath_wrappers(self, rpath_filter_dirs=None, rpath_include_dirs=None
10021007 if lib_stubs_pattern not in rpath_filter_dirs :
10031008 rpath_filter_dirs .append (lib_stubs_pattern )
10041009
1005- # directory where all wrappers will be placed
1006- disable_wrapper_log = False
1010+ # directory where all RPATH wrapper script will be placed;
1011+ # note: it's important to honor RPATH_WRAPPERS_SUBDIR, see is_rpath_wrapper method
10071012 if rpath_wrappers_dir is None :
10081013 wrappers_dir = os .path .join (tempfile .mkdtemp (), RPATH_WRAPPERS_SUBDIR )
10091014 else :
10101015 wrappers_dir = os .path .join (rpath_wrappers_dir , RPATH_WRAPPERS_SUBDIR )
1011- # No logging when we may be exporting wrappers
1012- disable_wrapper_log = True
1016+ mkdir (wrappers_dir , parents = True )
1017+ # disable logging in RPATH wrapper scripts when they may be exported for use outside of EasyBuild
1018+ enable_wrapper_log = False
10131019
10141020 # must also wrap compilers commands, required e.g. for Clang ('gcc' on OS X)?
10151021 c_comps , fortran_comps = self .compilers ()
10161022
1023+ # copy rpath_args.py script along RPATH wrappers,
1024+ # to avoid that they rely on an script that's located elsewhere;
1025+ # that's mostly important when RPATH wrapper scripts are retained to be used outside of EasyBuild
10171026 rpath_args_py = find_eb_script ('rpath_args.py' )
1027+ copy_file (rpath_args_py , wrappers_dir )
1028+ rpath_args_py = os .path .join (wrappers_dir , os .path .basename (rpath_args_py ))
1029+
10181030 rpath_wrapper_template = find_eb_script ('rpath_wrapper_template.sh.in' )
10191031
10201032 # figure out list of patterns to use in rpath filter
@@ -1056,8 +1068,8 @@ def prepare_rpath_wrappers(self, rpath_filter_dirs=None, rpath_include_dirs=None
10561068 raise EasyBuildError ("Refusing to create a fork bomb, which(%s) == %s" , cmd , orig_cmd )
10571069
10581070 # enable debug mode in wrapper script by specifying location for log file
1059- if build_option ( 'debug' ) and not disable_wrapper_log :
1060- rpath_wrapper_log = os .path .join (tempfile .gettempdir (), 'rpath_wrapper_%s .log' % cmd )
1071+ if enable_wrapper_log :
1072+ rpath_wrapper_log = os .path .join (tempfile .gettempdir (), f 'rpath_wrapper_{ cmd } .log' )
10611073 else :
10621074 rpath_wrapper_log = '/dev/null'
10631075
0 commit comments