Skip to content

Commit 969c899

Browse files
committed
Do not load spack env before it has been created
1 parent 854bdb7 commit 969c899

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

mache/spack/env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def make_spack_env(
116116
None,
117117
include_e3sm_lapack,
118118
include_e3sm_hdf5_netcdf,
119+
load_spack_env=False,
119120
)
120121
modules = f'{modules}\n{bash_script}'
121122

mache/spack/script.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def get_spack_script(
1616
config_file=None,
1717
include_e3sm_lapack=False,
1818
include_e3sm_hdf5_netcdf=False,
19+
load_spack_env=True,
1920
):
2021
"""
2122
Build a snippet of a load script for the given spack environment
@@ -52,6 +53,10 @@ def get_spack_script(
5253
Whether to include the same hdf5, netcdf-c, netcdf-fortran and pnetcdf
5354
as used in E3SM
5455
56+
load_spack_env : bool, optional
57+
Whether to load the spack environment at the start of script.
58+
Must be set to False when initially building the environment
59+
5560
Returns
5661
-------
5762
load_script : str
@@ -72,10 +77,13 @@ def get_spack_script(
7277
if config_file is not None:
7378
config.read(config_file)
7479

75-
load_script_template = (
76-
f'source {spack_path}/share/spack/setup-env.{shell}\n'
77-
f'spack env activate {env_name}'
78-
)
80+
load_script_template = ''
81+
82+
if load_spack_env:
83+
load_script_template += (
84+
f'source {spack_path}/share/spack/setup-env.{shell}\n'
85+
f'spack env activate {env_name}'
86+
)
7987

8088
# start with the shell script from the config_machines.xml for the
8189
# given machine, compiler, and mpi

0 commit comments

Comments
 (0)