summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/spack18
1 files changed, 17 insertions, 1 deletions
diff --git a/bin/spack b/bin/spack
index 7c911ce9f2..a7ebb8d161 100755
--- a/bin/spack
+++ b/bin/spack
@@ -1,10 +1,26 @@
-#!/usr/bin/env python
+#!/bin/sh
+# -*- python -*-
#
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+# This file is bilingual. The following shell code finds our preferred python.
+# 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 "$@"
+done
+
+echo "==> Error: spack could not find a python interpreter!" >&2
+exit 1
+":"""
+# Line above is a shell no-op, and ends a python multi-line comment.
+# The code above runs this file with our preferred python interpreter.
+
from __future__ import print_function
import os