setup-env: allow users to skip slow parts (#24545)
This commit is contained in:
parent
a22686279c
commit
0c5402ea5c
@ -699,74 +699,76 @@ set -xg _sp_shell "fish"
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
if test -z "$SPACK_SKIP_MODULES"
|
||||||
# Check whether we need environment-variables (module) <= `use` is not available
|
#
|
||||||
#
|
# 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
|
set -l need_module "no"
|
||||||
set need_module "yes"
|
if not functions -q use; and not functions -q module
|
||||||
end
|
set need_module "yes"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# 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))
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
sp_apply_shell_vars $sp_var_expr
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# _sp_module_prefix is set by spack --print-sh-vars
|
|
||||||
if test "$_sp_module_prefix" != "not_installed"
|
|
||||||
set -xg MODULE_PREFIX $_sp_module_prefix
|
#
|
||||||
spack_pathadd PATH "$MODULE_PREFIX/bin"
|
# 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))
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
set -l sp_shell_vars (command spack --print-shell-vars sh)
|
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
|
||||||
|
sp_apply_shell_vars $sp_var_expr
|
||||||
|
end
|
||||||
|
|
||||||
|
# _sp_module_prefix is set by spack --print-sh-vars
|
||||||
|
if test "$_sp_module_prefix" != "not_installed"
|
||||||
|
set -xg MODULE_PREFIX $_sp_module_prefix
|
||||||
|
spack_pathadd PATH "$MODULE_PREFIX/bin"
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
set -l sp_shell_vars (command spack --print-shell-vars sh)
|
||||||
|
|
||||||
|
for sp_var_expr in $sp_shell_vars
|
||||||
|
sp_apply_shell_vars $sp_var_expr
|
||||||
|
end
|
||||||
|
|
||||||
for sp_var_expr in $sp_shell_vars
|
|
||||||
sp_apply_shell_vars $sp_var_expr
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
if test "$need_module" = "yes"
|
||||||
|
function module -d "wrapper for the `module` command to point at Spack's modules instance" --inherit-variable MODULE_PREFIX
|
||||||
if test "$need_module" = "yes"
|
eval $MODULE_PREFIX/bin/modulecmd $SPACK_SHELL $argv
|
||||||
function module -d "wrapper for the `module` command to point at Spack's modules instance" --inherit-variable MODULE_PREFIX
|
end
|
||||||
eval $MODULE_PREFIX/bin/modulecmd $SPACK_SHELL $argv
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# set module system roots
|
||||||
|
#
|
||||||
|
|
||||||
|
# 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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# set module system roots
|
|
||||||
#
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# NOTES
|
# NOTES
|
||||||
#
|
#
|
||||||
|
@ -306,11 +306,6 @@ _spack_fn_exists() {
|
|||||||
LANG= type $1 2>&1 | grep -q 'function'
|
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
|
# 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.
|
# run `which spack`, they see the path to spack and where the function is from.
|
||||||
eval "spack() {
|
eval "spack() {
|
||||||
@ -334,48 +329,55 @@ for cmd in "${SPACK_PYTHON:-}" python3 python python2; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
#
|
if [ -z "${SPACK_SKIP_MODULES+x}" ]; then
|
||||||
# make available environment-modules
|
need_module="no"
|
||||||
#
|
if ! _spack_fn_exists use && ! _spack_fn_exists module; then
|
||||||
if [ "${need_module}" = "yes" ]; then
|
need_module="yes"
|
||||||
eval `spack --print-shell-vars sh,modules`
|
fi;
|
||||||
|
|
||||||
# _sp_module_prefix is set by spack --print-sh-vars
|
#
|
||||||
if [ "${_sp_module_prefix}" != "not_installed" ]; then
|
# make available environment-modules
|
||||||
# activate it!
|
#
|
||||||
# environment-modules@4: has a bin directory inside its prefix
|
if [ "${need_module}" = "yes" ]; then
|
||||||
_sp_module_bin="${_sp_module_prefix}/bin"
|
eval `spack --print-shell-vars sh,modules`
|
||||||
if [ ! -d "${_sp_module_bin}" ]; then
|
|
||||||
# environment-modules@3 has a nested bin directory
|
# _sp_module_prefix is set by spack --print-sh-vars
|
||||||
_sp_module_bin="${_sp_module_prefix}/Modules/bin"
|
if [ "${_sp_module_prefix}" != "not_installed" ]; then
|
||||||
fi
|
# activate it!
|
||||||
|
# environment-modules@4: has a bin directory inside its prefix
|
||||||
# _sp_module_bin and _sp_shell are evaluated here; the quoted
|
_sp_module_bin="${_sp_module_prefix}/bin"
|
||||||
# eval statement and $* are deferred.
|
if [ ! -d "${_sp_module_bin}" ]; then
|
||||||
_sp_cmd="module() { eval \`${_sp_module_bin}/modulecmd ${_sp_shell} \$*\`; }"
|
# environment-modules@3 has a nested bin directory
|
||||||
eval "$_sp_cmd"
|
_sp_module_bin="${_sp_module_prefix}/Modules/bin"
|
||||||
_spack_pathadd PATH "${_sp_module_bin}"
|
fi
|
||||||
|
|
||||||
|
# _sp_module_bin and _sp_shell are evaluated here; the quoted
|
||||||
|
# eval statement and $* are deferred.
|
||||||
|
_sp_cmd="module() { eval \`${_sp_module_bin}/modulecmd ${_sp_shell} \$*\`; }"
|
||||||
|
eval "$_sp_cmd"
|
||||||
|
_spack_pathadd PATH "${_sp_module_bin}"
|
||||||
|
fi;
|
||||||
|
else
|
||||||
|
eval `spack --print-shell-vars sh`
|
||||||
fi;
|
fi;
|
||||||
else
|
|
||||||
eval `spack --print-shell-vars sh`
|
|
||||||
fi;
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# set module system roots
|
# set module system roots
|
||||||
#
|
#
|
||||||
_sp_multi_pathadd() {
|
_sp_multi_pathadd() {
|
||||||
local IFS=':'
|
local IFS=':'
|
||||||
if [ "$_sp_shell" = zsh ]; then
|
if [ "$_sp_shell" = zsh ]; then
|
||||||
emulate -L sh
|
emulate -L sh
|
||||||
fi
|
fi
|
||||||
for pth in $2; do
|
for pth in $2; do
|
||||||
for systype in ${_sp_compatible_sys_types}; do
|
for systype in ${_sp_compatible_sys_types}; do
|
||||||
_spack_pathadd "$1" "${pth}/${systype}"
|
_spack_pathadd "$1" "${pth}/${systype}"
|
||||||
|
done
|
||||||
done
|
done
|
||||||
done
|
}
|
||||||
}
|
_sp_multi_pathadd MODULEPATH "$_sp_tcl_roots"
|
||||||
_sp_multi_pathadd MODULEPATH "$_sp_tcl_roots"
|
fi
|
||||||
|
|
||||||
# Add programmable tab completion for Bash
|
# Add programmable tab completion for Bash
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user