summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rwxr-xr-xshare/spack/setup-env.csh6
-rwxr-xr-xshare/spack/setup-env.sh27
2 files changed, 12 insertions, 21 deletions
diff --git a/share/spack/setup-env.csh b/share/spack/setup-env.csh
index 0f67ef7906..a153374028 100755
--- a/share/spack/setup-env.csh
+++ b/share/spack/setup-env.csh
@@ -39,10 +39,8 @@ if ($?SPACK_ROOT) then
alias spack 'set _sp_args = (\!*); source $_spack_share_dir/csh/spack.csh'
alias _spack_pathadd 'set _pa_args = (\!*) && source $_spack_share_dir/csh/pathadd.csh'
- # Shamelessly stolen from setup-env.sh
- set _sp_sys_type = `$SPACK_ROOT/bin/spack python -c 'print(spack.architecture.sys_type())'`
- set _sp_dotkit_root = `$SPACK_ROOT/bin/spack python -c "print(spack.util.path.canonicalize_path(spack.config.get('config:module_roots', {}).get('dotkit')))"`
- set _sp_tcl_root = `$SPACK_ROOT/bin/spack python -c "print(spack.util.path.canonicalize_path(spack.config.get('config:module_roots', {}).get('tcl')))"`
+ # Set variables needed by this script
+ eval `spack --print-shell-vars csh`
# Set up modules and dotkit search paths in the user environment
_spack_pathadd DK_NODE "$_sp_dotkit_root/$_sp_sys_type"
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index b983299975..023056d103 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -218,34 +218,27 @@ if ! _spack_fn_exists use && ! _spack_fn_exists module; then
need_module="yes"
fi;
+
#
-# build and make available environment-modules
+# make available environment-modules
#
if [ "${need_module}" = "yes" ]; then
- #check if environment-modules is installed
- module_prefix="$(spack location -i "environment-modules" 2>&1 || echo "not_installed")"
- module_prefix=$(echo "${module_prefix}" | tail -n 1)
- if [ "${module_prefix}" != "not_installed" ]; then
+ eval `spack --print-shell-vars sh,modules`
+
+ # _sp_module_prefix is set by spack --print-sh-vars
+ if [ "${_sp_module_prefix}" != "not_installed" ]; then
#activate it!
- export MODULE_PREFIX=${module_prefix}
+ export MODULE_PREFIX=${_sp_module_prefix}
_spack_pathadd PATH "${MODULE_PREFIX}/Modules/bin"
module() { eval `${MODULE_PREFIX}/Modules/bin/modulecmd ${SPACK_SHELL} $*`; }
fi;
+else
+ eval `spack --print-shell-vars sh`
fi;
#
-# Set up modules and dotkit search paths in the user environment
+# set module system roots
#
-
-_python_command=$(printf "%s\\\n%s\\\n%s" \
-"print(\'_sp_sys_type={0}\'.format(spack.architecture.sys_type()))" \
-"print(\'_sp_dotkit_root={0}\'.format(spack.util.path.canonicalize_path(spack.config.get(\'config:module_roots\', {}).get(\'dotkit\'))))" \
-"print(\'_sp_tcl_root={0}\'.format(spack.util.path.canonicalize_path(spack.config.get(\'config:module_roots\', {}).get(\'tcl\'))))"
-)
-
-_assignment_command=$(spack-python -c "exec('${_python_command}')")
-eval ${_assignment_command}
-
_spack_pathadd DK_NODE "${_sp_dotkit_root%/}/$_sp_sys_type"
_spack_pathadd MODULEPATH "${_sp_tcl_root%/}/$_sp_sys_type"