summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-07-16 15:43:44 -0700
committerGitHub <noreply@github.com>2018-07-16 15:43:44 -0700
commit06418a3dcd5dda0c45151ceec08aa91d8e3fa651 (patch)
tree6c95acba1b2799e8e809d051c46e755f44a95198 /share
parentd006139e3cb7fc1fe42792a4961494db31ded7c9 (diff)
downloadspack-06418a3dcd5dda0c45151ceec08aa91d8e3fa651.tar.gz
spack-06418a3dcd5dda0c45151ceec08aa91d8e3fa651.tar.bz2
spack-06418a3dcd5dda0c45151ceec08aa91d8e3fa651.tar.xz
spack-06418a3dcd5dda0c45151ceec08aa91d8e3fa651.zip
add `spack --print-shell-vars` to speed up `setup-env.[c]sh` (#8101)
- The setup-env.sh script currently makes two calls to spack, but it should only need to make one. - Add a fast-path shell setup routine in `main.py` to allow the shell setup to happen in a single, fast call that doesn't load more than it needs to. - This simplifies setup code, as it has to eval what Spack prints - TODO: consider eventually making the whole setup script the output of a spack command
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"