From: Mathias Preiner Date: Fri, 2 Aug 2019 20:49:03 +0000 (-0700) Subject: Add better Python detection for contrib scripts. (#3150) X-Git-Tag: cvc5-1.0.0~4049 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=13f6d4b71a194f74001f7a6fbe92bbb2c5c62813;p=cvc5.git Add better Python detection for contrib scripts. (#3150) --- diff --git a/contrib/get-antlr-3.4 b/contrib/get-antlr-3.4 index 6bfa18c46..a3dfb410d 100755 --- a/contrib/get-antlr-3.4 +++ b/contrib/get-antlr-3.4 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # source "$(dirname "$0")/get-script-header.sh" ANTLR_HOME_DIR=antlr-3.4 @@ -46,7 +46,7 @@ cd libantlr3c-3.4 # Use an absolute path for the installation directory to avoid spurious libtool # warnings about the ANTLR library having moved -PREFIX=$(python -c "import os; print(os.path.realpath('$(pwd)/../..'))") +PREFIX=$($PYTHON -c "import os; print(os.path.realpath('$(pwd)/../..'))") # Make antlr3debughandlers.c empty to avoid unreferenced symbols rm -rf src/antlr3debughandlers.c && touch src/antlr3debughandlers.c diff --git a/contrib/get-script-header.sh b/contrib/get-script-header.sh index de4a93587..e5b708042 100644 --- a/contrib/get-script-header.sh +++ b/contrib/get-script-header.sh @@ -1,6 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash # -set -e +set -e -o pipefail cd "$(dirname "$0")/.." @@ -24,3 +24,15 @@ function webget { exit 1 fi } + +for cmd in python python2 python3; do + if [ -x "$(command -v $cmd)" ]; then + PYTHON="$cmd" + break + fi +done + +if [ -z "$PYTHON" ]; then + echo "Error: Couldn't find python, python2, or python3." >&2 + exit 1 +fi