From 7495faf142e81ffb60f55f5d15d0d7a51362e653 Mon Sep 17 00:00:00 2001 From: Tadej Novak Date: Mon, 27 Sep 2021 10:36:26 +0200 Subject: [PATCH] Defer preloads evaluation to the execution time --- Tools/PyJobTransforms/python/trfEnv.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Tools/PyJobTransforms/python/trfEnv.py b/Tools/PyJobTransforms/python/trfEnv.py index 7a38a436abe..6043f8a06be 100644 --- a/Tools/PyJobTransforms/python/trfEnv.py +++ b/Tools/PyJobTransforms/python/trfEnv.py @@ -48,8 +48,8 @@ class environmentUpdate(object): if 'ATLASMKLLIBDIR_PRELOAD' in os.environ: if "LD_PRELOAD" not in self._envdict: self._envdict["LD_PRELOAD"] = pathVar("LD_PRELOAD") - self._envdict["LD_PRELOAD"].add(path.join(os.environ['ATLASMKLLIBDIR_PRELOAD'], "libimf.so")) - self._envdict["LD_PRELOAD"].add(path.join(os.environ['ATLASMKLLIBDIR_PRELOAD'], "libintlc.so.5")) + self._envdict["LD_PRELOAD"].add(path.join("$ATLASMKLLIBDIR_PRELOAD", "libimf.so")) + self._envdict["LD_PRELOAD"].add(path.join("$ATLASMKLLIBDIR_PRELOAD", "libintlc.so.5")) ## @brief Add TCMALLOC to the setup @@ -67,7 +67,7 @@ class environmentUpdate(object): # For now we support the minimal version (it's the default) if "LD_PRELOAD" not in self._envdict: self._envdict["LD_PRELOAD"] = pathVar("LD_PRELOAD") - self._envdict["LD_PRELOAD"].add(path.join(os.environ['TCMALLOCDIR'], "libtcmalloc_minimal.so")) + self._envdict["LD_PRELOAD"].add(path.join("$TCMALLOCDIR", "libtcmalloc_minimal.so")) ## @brief Add other settings @@ -120,7 +120,11 @@ class pathVar(object): if value in self._value: msg.warning('Attempt to add environment element {0} twice to {1}'.format(value, self._name)) if self._testExistance: - if not os.access(value, os.R_OK): + # expand environment variables (will only check current release, but this is the most common anyways) + test_value = value + if '$' in test_value: + test_value = os.path.join(os.environ[os.path.dirname(value)[1:]], os.path.basename(value)) + if not os.access(test_value, os.R_OK): msg.warning("Path to {0} is not readable - will not add it to {1}".format(value, self._name)) return if prepend: -- GitLab