Skip to content

Commit b235c7c

Browse files
committed
Make sure Lmod site package and RC file do not appear in accelerator subdir
1 parent 247a743 commit b235c7c

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

create_lmodrc.py

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ def error(msg):
3333
error("Prefix directory %s does not exist!" % prefix)
3434

3535
lmodrc_path = os.path.join(prefix, DOT_LMOD, 'lmodrc.lua')
36+
# Lmod itself doesn't care about compute capability so remove this duplication from
37+
# the install path (if it exists)
38+
accel_subdir = os.getenv("EESSI_ACCELERATOR_TARGET")
39+
if accel_subdir:
40+
lmodrc_path = lmodrc_path.replace("/accel/%s" % accel_subdir, '')
41+
3642
lmodrc_txt = TEMPLATE_LMOD_RC % {
3743
'dot_lmod': DOT_LMOD,
3844
'prefix': prefix,

create_lmodsitepackage.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
DOT_LMOD = '.lmod'
1010

11-
hook_txt ="""require("strict")
11+
hook_txt = """require("strict")
1212
local hook = require("Hook")
1313
local open = io.open
1414
@@ -36,7 +36,7 @@
3636
-- eessi_prefix_host_injections is the prefix with site-extensions (i.e. additional modules)
3737
-- to the official EESSI modules, e.g. /cvmfs/software.eessi.io/host_injections/2023.06
3838
local eessi_prefix_host_injections = string.gsub(eessi_prefix, 'versions', 'host_injections')
39-
39+
4040
-- Check if the full modulepath starts with the eessi_prefix_*
4141
return string.find(t.fn, "^" .. eessi_prefix) ~= nil or string.find(t.fn, "^" .. eessi_prefix_host_injections) ~= nil
4242
end
@@ -103,15 +103,15 @@
103103
if isFile(archSitePackage) then
104104
dofile(archSitePackage)
105105
end
106-
106+
107107
end
108108
109109
110110
local function eessi_cuda_enabled_load_hook(t)
111111
local frameStk = require("FrameStk"):singleton()
112112
local mt = frameStk:mt()
113113
local simpleName = string.match(t.modFullName, "(.-)/")
114-
-- If we try to load CUDA itself, check if the full CUDA SDK was installed on the host in host_injections.
114+
-- If we try to load CUDA itself, check if the full CUDA SDK was installed on the host in host_injections.
115115
-- This is required for end users to build additional CUDA software. If the full SDK isn't present, refuse
116116
-- to load the CUDA module and print an informative message on how to set up GPU support for EESSI
117117
local refer_to_docs = "For more information on how to do this, see https://www.eessi.io/docs/gpu/.\\n"
@@ -207,6 +207,7 @@
207207
load_site_specific_hooks()
208208
"""
209209

210+
210211
def error(msg):
211212
sys.stderr.write("ERROR: %s\n" % msg)
212213
sys.exit(1)
@@ -221,12 +222,18 @@ def error(msg):
221222
error("Prefix directory %s does not exist!" % prefix)
222223

223224
sitepackage_path = os.path.join(prefix, DOT_LMOD, 'SitePackage.lua')
225+
226+
# Lmod itself doesn't care about compute capability so remove this duplication from
227+
# the install path (if it exists)
228+
accel_subdir = os.getenv("EESSI_ACCELERATOR_TARGET")
229+
if accel_subdir:
230+
sitepackage_path = sitepackage_path.replace("/accel/%s" % accel_subdir, '')
224231
try:
225232
os.makedirs(os.path.dirname(sitepackage_path), exist_ok=True)
226233
with open(sitepackage_path, 'w') as fp:
227234
fp.write(hook_txt)
228235
# Make sure that the created Lmod file has "read/write" for the user/group and "read" permissions for others
229-
os.chmod(sitepackage_path, S_IREAD|S_IWRITE|S_IRGRP|S_IWGRP|S_IROTH)
236+
os.chmod(sitepackage_path, S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH)
230237

231238
except (IOError, OSError) as err:
232239
error("Failed to create %s: %s" % (sitepackage_path, err))

0 commit comments

Comments
 (0)