Skip to content

Commit dc23fd8

Browse files
committed
Render environmental variables in env build script
1 parent 1a23be8 commit dc23fd8

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

mache/spack/env.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from jinja2 import Template
66

77
from mache.machine_info import MachineInfo, discover_machine
8+
from mache.spack.script import get_spack_script
89
from mache.spack.shared import _get_yaml_data
910
from mache.version import __version__
1011

@@ -105,23 +106,18 @@ def make_spack_env(
105106

106107
modules = ''
107108

108-
for shell_filename in [f'{machine}.sh', f'{machine}_{compiler}_{mpi}.sh']:
109-
# load modules, etc. for this machine
110-
path = (
111-
importlib_resources.files('mache.spack.templates') / shell_filename
112-
)
113-
try:
114-
with open(str(path)) as fp:
115-
template = Template(fp.read())
116-
except FileNotFoundError:
117-
# there's nothing to add, which is fine
118-
continue
119-
bash_script = template.render(
120-
e3sm_lapack=include_e3sm_lapack,
121-
e3sm_hdf5_netcdf=include_e3sm_hdf5_netcdf,
122-
)
123-
124-
modules = f'{modules}\n{bash_script}'
109+
bash_script = get_spack_script(
110+
spack_path,
111+
env_name,
112+
compiler,
113+
mpi,
114+
'sh',
115+
machine,
116+
None,
117+
include_e3sm_lapack,
118+
include_e3sm_hdf5_netcdf,
119+
)
120+
modules = f'{modules}\n{bash_script}'
125121

126122
path = (
127123
importlib_resources.files('mache.spack.templates')

0 commit comments

Comments
 (0)