Skip to content

Commit 8e53b0b

Browse files
committed
always set spack env
1 parent 438168b commit 8e53b0b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

reframe/core/buildsystems.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -845,10 +845,13 @@ class Spack(BuildSystem):
845845
#: :default: ``[]``
846846
install_opts = variable(typ.List[str], value=[])
847847

848+
def __init__(self):
849+
self._rfm_spack_env = False
850+
848851
def emit_build_commands(self, environ):
849852
ret = self._env_activate_cmds()
850853

851-
if not self.environment:
854+
if self._rfm_spack_env:
852855
install_tree = self.install_tree or 'opt/spack'
853856
ret.append(f'spack config add '
854857
f'"config:install_tree:root:{install_tree}"')
@@ -866,13 +869,12 @@ def emit_build_commands(self, environ):
866869

867870
def _env_activate_cmds(self):
868871
cmds = ['. "$(spack location --spack-root)/share/spack/setup-env.sh"']
869-
if self.environment:
870-
environment = self.environment
871-
else:
872-
environment = 'rfm_spack_env'
873-
cmds.append(f'spack env create -d {environment}')
872+
if not self.environment:
873+
self.environment = 'rfm_spack_env'
874+
cmds.append(f'spack env create -d {self.environment}')
875+
self._rfm_spack_env = True
874876

875-
cmds.append(f'spack env activate -V -d {environment}')
877+
cmds.append(f'spack env activate -V -d {self.environment}')
876878
return cmds
877879

878880
def prepare_cmds(self):

0 commit comments

Comments
 (0)