From 06461ea123980c124d4fd73fbe6037f6df0b8fe3 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 14 Dec 2023 10:53:15 +0100 Subject: [PATCH] Introduce `--module-cache-suffix` to allow multiple caches This is useful when having multiple module trees (i.e. different `--installprefix`) to not overwrite the cache file of one with the other when using `--update-modules-tool-cache`. Inspired by how LMod itself creates the cache, e.g. `~/.cache/lmod/spiderT.rapids_x86_64_Linux.lua` --- easybuild/tools/config.py | 1 + easybuild/tools/modules.py | 3 ++- easybuild/tools/options.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/easybuild/tools/config.py b/easybuild/tools/config.py index 6c0a173fe4..ee8eb5fc53 100644 --- a/easybuild/tools/config.py +++ b/easybuild/tools/config.py @@ -239,6 +239,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX): 'job_polling_interval', 'job_target_resource', 'locks_dir', + 'module_cache_suffix', 'modules_footer', 'modules_header', 'mpi_cmd_template', diff --git a/easybuild/tools/modules.py b/easybuild/tools/modules.py index 386643e706..f2d74c2137 100644 --- a/easybuild/tools/modules.py +++ b/easybuild/tools/modules.py @@ -1436,7 +1436,8 @@ def update(self): # don't actually update local cache when testing, just return the cache contents return stdout else: - cache_fp = os.path.join(self.USER_CACHE_DIR, 'moduleT.lua') + suffix = build_option('module_cache_suffix') or '' + cache_fp = os.path.join(self.USER_CACHE_DIR, 'moduleT%s.lua' % suffix) self.log.debug("Updating Lmod spider cache %s with output from '%s'" % (cache_fp, ' '.join(cmd))) cache_dir = os.path.dirname(cache_fp) if not os.path.exists(cache_dir): diff --git a/easybuild/tools/options.py b/easybuild/tools/options.py index eeba800c09..b840bc4d53 100644 --- a/easybuild/tools/options.py +++ b/easybuild/tools/options.py @@ -461,6 +461,9 @@ def override_options(self): "environment variable and its value separated by a colon (':')", None, 'store', DEFAULT_MINIMAL_BUILD_ENV), 'minimal-toolchains': ("Use minimal toolchain when resolving dependencies", None, 'store_true', False), + 'module-cache-suffix': ("Suffix to add to the cache file name (before the extension) " + "when updating the modules tool cache", + None, 'store', None), 'module-only': ("Only generate module file(s); skip all steps except for %s" % ', '.join(MODULE_ONLY_STEPS), None, 'store_true', False), 'modules-tool-version-check': ("Check version of modules tool being used", None, 'store_true', True),