File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -845,10 +845,14 @@ class Spack(BuildSystem):
845845 #: :default: ``[]``
846846 install_opts = variable (typ .List [str ], value = [])
847847
848+ def __init__ (self ):
849+ # Set to True if the environment was auto-generated
850+ self ._auto_env = False
851+
848852 def emit_build_commands (self , environ ):
849853 ret = self ._env_activate_cmds ()
850854
851- if not self .environment :
855+ if self ._auto_env :
852856 install_tree = self .install_tree or 'opt/spack'
853857 ret .append (f'spack config add '
854858 f'"config:install_tree:root:{ install_tree } "' )
@@ -866,13 +870,12 @@ def emit_build_commands(self, environ):
866870
867871 def _env_activate_cmds (self ):
868872 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 } ' )
873+ if not self .environment :
874+ self .environment = 'rfm_spack_env'
875+ cmds .append (f'spack env create -d { self .environment } ' )
876+ self ._auto_env = True
874877
875- cmds .append (f'spack env activate -V -d { environment } ' )
878+ cmds .append (f'spack env activate -V -d { self . environment } ' )
876879 return cmds
877880
878881 def prepare_cmds (self ):
Original file line number Diff line number Diff line change @@ -289,6 +289,9 @@ def test_spack_no_env(environ, tmp_path):
289289 f'spack install'
290290 ]
291291
292+ assert build_system .environment == 'rfm_spack_env'
293+
294+
292295def test_easybuild (environ , tmp_path ):
293296 build_system = bs .EasyBuild ()
294297 build_system .easyconfigs = ['ec1.eb' , 'ec2.eb' ]
You can’t perform that action at this time.
0 commit comments