summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rwxr-xr-xshare/spack/setup-env.csh12
-rwxr-xr-xshare/spack/setup-env.fish15
-rwxr-xr-xshare/spack/setup-env.sh8
3 files changed, 34 insertions, 1 deletions
diff --git a/share/spack/setup-env.csh b/share/spack/setup-env.csh
index 8368274912..4ac0503947 100755
--- a/share/spack/setup-env.csh
+++ b/share/spack/setup-env.csh
@@ -58,6 +58,18 @@ alias spack 'set _sp_args = (\!*); source $_spack_share_dir/csh/spack.c
alias spacktivate 'spack env activate'
alias _spack_pathadd 'set _pa_args = (\!*) && source $_spack_share_dir/csh/pathadd.csh'
+# Identify and lock the python interpreter
+if (! $?SPACK_PYTHON) then
+ setenv SPACK_PYTHON ""
+endif
+foreach cmd ("$SPACK_PYTHON" python3 python python2)
+ command -v "$cmd" >& /dev/null
+ if ($status == 0) then
+ setenv SPACK_PYTHON `command -v "$cmd"`
+ break
+ endif
+end
+
# Set variables needed by this script
_spack_pathadd PATH "$SPACK_ROOT/bin"
eval `spack --print-shell-vars csh`
diff --git a/share/spack/setup-env.fish b/share/spack/setup-env.fish
index 15eff90dd2..190934531d 100755
--- a/share/spack/setup-env.fish
+++ b/share/spack/setup-env.fish
@@ -253,7 +253,7 @@ function match_flag -d "checks all combinations of flags ocurring inside of a st
set -l _a (string sub -s 2 (string trim "x$argv[1]"))
set -l _b (string sub -s 2 (string trim "x$argv[2]"))
- if test -z "$_a" || test -z "$_b"
+ if test -z "$_a" or test -z "$_b"
return 0
end
@@ -668,6 +668,19 @@ set -l sp_source_file (status -f) # name of current file
#
+# Identify and lock the python interpreter
+#
+for cmd in "$SPACK_PYTHON" python3 python python2
+ set -l _sp_python (command -s "$cmd")
+ if test $status -eq 0
+ set -x SPACK_PYTHON $_sp_python
+ break
+ end
+end
+
+
+
+#
# Find root directory and add bin to path.
#
set -l sp_share_dir (realpath (dirname $sp_source_file))
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index c4c7af4b0a..cbee4428d0 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -326,6 +326,14 @@ if [ "$_sp_shell" = bash ]; then
export -f _spack_shell_wrapper
fi
+# Identify and lock the python interpreter
+for cmd in "${SPACK_PYTHON:-}" python3 python python2; do
+ if command -v > /dev/null "$cmd"; then
+ export SPACK_PYTHON="$(command -v "$cmd")"
+ break
+ fi
+done
+
#
# make available environment-modules
#