summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorChuck Atkins <chuck.atkins@kitware.com>2021-02-12 13:52:44 -0500
committerGitHub <noreply@github.com>2021-02-12 10:52:44 -0800
commit5a771bc8ad3ddb1b3f550f1685c451cc6cb49e64 (patch)
tree67216810f4f0f0d94d805110f1ffe4e5fb757a99 /bin
parent7add9de2e531e7a498cff85c20ff474d6d4eddec (diff)
downloadspack-5a771bc8ad3ddb1b3f550f1685c451cc6cb49e64.tar.gz
spack-5a771bc8ad3ddb1b3f550f1685c451cc6cb49e64.tar.bz2
spack-5a771bc8ad3ddb1b3f550f1685c451cc6cb49e64.tar.xz
spack-5a771bc8ad3ddb1b3f550f1685c451cc6cb49e64.zip
Introduce a SPACK_PYTHON environment variable (#21222)
The SPACK_PYTHON environment variable can be set to a python interpreter to be used by the spack command. This allows the spack command itself to use a consistent and separate interpreter from whatever python might be used for package building.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/spack9
1 files changed, 6 insertions, 3 deletions
diff --git a/bin/spack b/bin/spack
index e979e2af64..24db0be9b1 100755
--- a/bin/spack
+++ b/bin/spack
@@ -10,9 +10,12 @@
# Following line is a shell no-op, and starts a multi-line Python comment.
# See https://stackoverflow.com/a/47886254
""":"
-# prefer python3, then python, then python2
-for cmd in python3 python python2; do
- command -v > /dev/null $cmd && exec $cmd $0 "$@"
+# prefer SPACK_PYTHON environment variable, python3, python, then python2
+for cmd in "${SPACK_PYTHON:-}" python3 python python2; do
+ if command -v > /dev/null "$cmd"; then
+ export SPACK_PYTHON="$(command -v "$cmd")"
+ exec "${SPACK_PYTHON}" "$0" "$@"
+ fi
done
echo "==> Error: spack could not find a python interpreter!" >&2