diff --git a/create_lmodrc.py b/create_lmodrc.py index 28ad2a1915..1720b762f0 100755 --- a/create_lmodrc.py +++ b/create_lmodrc.py @@ -33,6 +33,12 @@ def error(msg): error("Prefix directory %s does not exist!" % prefix) lmodrc_path = os.path.join(prefix, DOT_LMOD, 'lmodrc.lua') +# Lmod itself doesn't care about the accelerator subdir so remove this duplication from +# the target path (if it exists) +accel_subdir = os.getenv("EESSI_ACCELERATOR_TARGET") +if accel_subdir: + lmodrc_path = lmodrc_path.replace("/accel/%s" % accel_subdir, '') + lmodrc_txt = TEMPLATE_LMOD_RC % { 'dot_lmod': DOT_LMOD, 'prefix': prefix, diff --git a/create_lmodsitepackage.py b/create_lmodsitepackage.py index 62f073c9a6..11ca614be5 100755 --- a/create_lmodsitepackage.py +++ b/create_lmodsitepackage.py @@ -8,7 +8,7 @@ DOT_LMOD = '.lmod' -hook_txt ="""require("strict") +hook_txt = """require("strict") local hook = require("Hook") local open = io.open @@ -36,7 +36,7 @@ -- eessi_prefix_host_injections is the prefix with site-extensions (i.e. additional modules) -- to the official EESSI modules, e.g. /cvmfs/software.eessi.io/host_injections/2023.06 local eessi_prefix_host_injections = string.gsub(eessi_prefix, 'versions', 'host_injections') - + -- Check if the full modulepath starts with the eessi_prefix_* return string.find(t.fn, "^" .. eessi_prefix) ~= nil or string.find(t.fn, "^" .. eessi_prefix_host_injections) ~= nil end @@ -103,7 +103,7 @@ if isFile(archSitePackage) then dofile(archSitePackage) end - + end @@ -111,7 +111,7 @@ local frameStk = require("FrameStk"):singleton() local mt = frameStk:mt() local simpleName = string.match(t.modFullName, "(.-)/") - -- If we try to load CUDA itself, check if the full CUDA SDK was installed on the host in host_injections. + -- If we try to load CUDA itself, check if the full CUDA SDK was installed on the host in host_injections. -- This is required for end users to build additional CUDA software. If the full SDK isn't present, refuse -- to load the CUDA module and print an informative message on how to set up GPU support for EESSI local refer_to_docs = "For more information on how to do this, see https://www.eessi.io/docs/gpu/.\\n" @@ -207,6 +207,7 @@ load_site_specific_hooks() """ + def error(msg): sys.stderr.write("ERROR: %s\n" % msg) sys.exit(1) @@ -221,12 +222,18 @@ def error(msg): error("Prefix directory %s does not exist!" % prefix) sitepackage_path = os.path.join(prefix, DOT_LMOD, 'SitePackage.lua') + +# Lmod itself doesn't care about compute capability so remove this duplication from +# the install path (if it exists) +accel_subdir = os.getenv("EESSI_ACCELERATOR_TARGET") +if accel_subdir: + sitepackage_path = sitepackage_path.replace("/accel/%s" % accel_subdir, '') try: os.makedirs(os.path.dirname(sitepackage_path), exist_ok=True) with open(sitepackage_path, 'w') as fp: fp.write(hook_txt) # Make sure that the created Lmod file has "read/write" for the user/group and "read" permissions for others - os.chmod(sitepackage_path, S_IREAD|S_IWRITE|S_IRGRP|S_IWGRP|S_IROTH) + os.chmod(sitepackage_path, S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH) except (IOError, OSError) as err: error("Failed to create %s: %s" % (sitepackage_path, err))