summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@googlemail.com>2017-11-15 17:38:40 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2017-11-15 17:38:40 -0700
commit9bffa967546a061022f4d8bcae3cb4f63874b614 (patch)
treec00d75c33053dcecfbc7fcd192b45e584851b7f4
parent9d1224e5d8e40d88f5f60149aee4b4ab0e9c6d58 (diff)
downloadspack-9bffa967546a061022f4d8bcae3cb4f63874b614.tar.gz
spack-9bffa967546a061022f4d8bcae3cb4f63874b614.tar.bz2
spack-9bffa967546a061022f4d8bcae3cb4f63874b614.tar.xz
spack-9bffa967546a061022f4d8bcae3cb4f63874b614.zip
Reduce the calls to the python interpreter during initialization (#6312)
* Reduce the calls to the python interpreter during initialization This should reduce the delay the users experience when sourcing the setup file to activate shell support. It works by generating at once all the commands that needs to evaluated (they are stored in a string and later `eval`ed by the shell). * setup_env.sh: changed `read` with an equivalent magic For some reason `read` breaks when sourced from a running script. Change the incantation we use to construct the unique python command that will be evaluated. * setup_env.sh: python command now constructed with `printf` for portability This recovers the support for `zsh` that was broken in previous commits.
-rwxr-xr-xshare/spack/setup-env.sh13
1 files changed, 10 insertions, 3 deletions
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index 21a7e00345..38bcac03a9 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -236,9 +236,16 @@ fi;
#
# Set up modules and dotkit search paths in the user environment
#
-_sp_sys_type=$(spack-python -c 'print(spack.architecture.sys_type())')
-_sp_dotkit_root=$(spack-python -c "print(spack.util.path.canonicalize_path(spack.config.get_config('config').get('module_roots', {}).get('dotkit')))")
-_sp_tcl_root=$(spack-python -c "print(spack.util.path.canonicalize_path(spack.config.get_config('config').get('module_roots', {}).get('tcl')))")
+
+_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(\'config\').get(\'module_roots\', {}).get(\'dotkit\'))))" \
+"print(\'_sp_tcl_root={0}\'.format(spack.util.path.canonicalize_path(spack.config.get_config(\'config\').get(\'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"