setup-env: allow users to skip slow parts (#24545)

This commit is contained in:
Adam J. Stewart 2021-07-08 10:07:26 -05:00 committed by GitHub
parent a22686279c
commit 0c5402ea5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 102 additions and 98 deletions

View File

@ -699,20 +699,21 @@ set -xg _sp_shell "fish"
#
# Check whether we need environment-variables (module) <= `use` is not available
#
set -l need_module "no"
if test -z "$SPACK_SKIP_MODULES"; and not functions -q use; and not functions -q module
if test -z "$SPACK_SKIP_MODULES"
#
# Check whether we need environment-variables (module) <= `use` is not available
#
set -l need_module "no"
if not functions -q use; and not functions -q module
set need_module "yes"
end
end
#
# Make environment-modules available to shell
#
function sp_apply_shell_vars -d "applies expressions of the type `a='b'` as `set a b`"
#
# Make environment-modules available to shell
#
function sp_apply_shell_vars -d "applies expressions of the type `a='b'` as `set a b`"
# convert `a='b' to array variable `a b`
set -l expr_token (string trim -c "'" (string split "=" $argv))
@ -720,10 +721,10 @@ function sp_apply_shell_vars -d "applies expressions of the type `a='b'` as `set
# run set command to takes, converting lists of type `a:b:c` to array
# variables `a b c` by splitting around the `:` character
set -xg $expr_token[1] (string split ":" $expr_token[2])
end
end
if test "$need_module" = "yes"
if test "$need_module" = "yes"
set -l sp_shell_vars (command spack --print-shell-vars sh,modules)
for sp_var_expr in $sp_shell_vars
@ -736,7 +737,7 @@ if test "$need_module" = "yes"
spack_pathadd PATH "$MODULE_PREFIX/bin"
end
else
else
set -l sp_shell_vars (command spack --print-shell-vars sh)
@ -744,26 +745,27 @@ else
sp_apply_shell_vars $sp_var_expr
end
end
end
if test "$need_module" = "yes"
if test "$need_module" = "yes"
function module -d "wrapper for the `module` command to point at Spack's modules instance" --inherit-variable MODULE_PREFIX
eval $MODULE_PREFIX/bin/modulecmd $SPACK_SHELL $argv
end
end
end
#
# set module system roots
#
#
# set module system roots
#
# Search of MODULESPATHS by trying all possible compatible system types as
# module roots.
if test -z "$MODULEPATH"
# Search of MODULESPATHS by trying all possible compatible system types as
# module roots.
if test -z "$MODULEPATH"
set -gx MODULEPATH
end
sp_multi_pathadd MODULEPATH $_sp_tcl_roots
end
sp_multi_pathadd MODULEPATH $_sp_tcl_roots

View File

@ -306,11 +306,6 @@ _spack_fn_exists() {
LANG= type $1 2>&1 | grep -q 'function'
}
need_module="no"
if [ -z "${SPACK_SKIP_MODULES+x}" ] && ! _spack_fn_exists use && ! _spack_fn_exists module; then
need_module="yes"
fi;
# Define the spack shell function with some informative no-ops, so when users
# run `which spack`, they see the path to spack and where the function is from.
eval "spack() {
@ -334,10 +329,16 @@ for cmd in "${SPACK_PYTHON:-}" python3 python python2; do
fi
done
#
# make available environment-modules
#
if [ "${need_module}" = "yes" ]; then
if [ -z "${SPACK_SKIP_MODULES+x}" ]; then
need_module="no"
if ! _spack_fn_exists use && ! _spack_fn_exists module; then
need_module="yes"
fi;
#
# make available environment-modules
#
if [ "${need_module}" = "yes" ]; then
eval `spack --print-shell-vars sh,modules`
# _sp_module_prefix is set by spack --print-sh-vars
@ -356,15 +357,15 @@ if [ "${need_module}" = "yes" ]; then
eval "$_sp_cmd"
_spack_pathadd PATH "${_sp_module_bin}"
fi;
else
else
eval `spack --print-shell-vars sh`
fi;
fi;
#
# set module system roots
#
_sp_multi_pathadd() {
#
# set module system roots
#
_sp_multi_pathadd() {
local IFS=':'
if [ "$_sp_shell" = zsh ]; then
emulate -L sh
@ -374,8 +375,9 @@ _sp_multi_pathadd() {
_spack_pathadd "$1" "${pth}/${systype}"
done
done
}
_sp_multi_pathadd MODULEPATH "$_sp_tcl_roots"
}
_sp_multi_pathadd MODULEPATH "$_sp_tcl_roots"
fi
# Add programmable tab completion for Bash
#