Skip to content

Commit

Permalink
Make things more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
ocaisa committed Aug 5, 2024
1 parent 14e4c45 commit 3615517
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion easybuild/tools/toolchain/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@
* Kenneth Hoste (Ghent University)
"""
import copy
import os
import re
import sys

import easybuild.tools.toolchain
from easybuild.base import fancylogger
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.toolchain.toolchain import Toolchain
from easybuild.tools.environment import setvar
from easybuild.tools.toolchain.toolchain import Toolchain, RPATH_WRAPPERS_SUBDIR
from easybuild.tools.utilities import get_subclasses, import_available_modules, nub


Expand Down Expand Up @@ -157,6 +159,11 @@ def export_rpath_wrappers(targetdir, toolchain_name, toolchain_version, rpath_fi
rpath_include_dirs=None):
tc = get_toolchain({'name': toolchain_name, 'version': toolchain_version}, {})

# Temporarily filter any existing RPATH wrappers from the PATH
orig_paths = os.getenv('PATH')
filtered_paths = [path for path in orig_paths.split(':') if RPATH_WRAPPERS_SUBDIR not in path]
setvar('PATH', ':'.join(filtered_paths))

tc.prepare_rpath_wrappers(
rpath_filter_dirs=rpath_filter_dirs,
rpath_include_dirs=rpath_include_dirs,
Expand All @@ -165,3 +172,6 @@ def export_rpath_wrappers(targetdir, toolchain_name, toolchain_version, rpath_fi
disable_wrapper_log=True,
)
_log.debug("Installed RPATH wrappers in command specific subdirectories of %s" % (str(targetdir)))

# Restore the PATH
setvar('PATH', orig_paths)
3 changes: 3 additions & 0 deletions test/framework/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2939,6 +2939,9 @@ def test_export_rpath(self):
# enable --rpath for a toolchain so we test against it
init_config(build_options={'rpath': True, 'silent': True})
tc = self.get_toolchain('gompi', version='2018a')
tc.set_options({'rpath': True})
# allow the underlying toolchain to be in a prepared state (which may include rpath wrapping)
tc.prepare()

# export the wrappers to a target location
target_wrapper_dir = os.path.join(self.test_prefix, 'target')
Expand Down

0 comments on commit 3615517

Please sign in to comment.