From c729378bd5ffd4aea4d5d77230a18c2cc2545af4 Mon Sep 17 00:00:00 2001 From: Dean Wampler Date: Mon, 10 Feb 2020 12:32:23 -0600 Subject: [PATCH] Check that the user's python version is supported (#7003) --- build.sh | 68 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/build.sh b/build.sh index 746f5df7b..a838cd650 100755 --- a/build.sh +++ b/build.sh @@ -5,20 +5,24 @@ set -x # Cause the script to exit if a single command fails. set -e +# As the supported Python versions change, edit this array: +SUPPORTED_PYTHONS=( "3.5" "3.6" "3.7" ) + ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd) function usage() { - echo "Usage: build.sh []" - echo - echo "Options:" - echo " -h|--help print the help info" - echo " -l|--language language1[,language2]" - echo " a list of languages to build native libraries." - echo " Supported languages include \"python\" and \"java\"." - echo " If not specified, only python library will be built." - echo " -p|--python which python executable (default from which python)" - echo + cat <] + +Options: + -h|--help print the help info + -l|--language language1[,language2] + a list of languages to build native libraries. + Supported languages include "python" and "java". + If not specified, only python library will be built. + -p|--python mypython which python executable (default: result of "which python") +EOF } # Determine how many parallel jobs to use for make based on the number of cores @@ -45,7 +49,7 @@ while [[ $# -gt 0 ]]; do usage exit 0 ;; - -l|--languags) + -l|--language) LANGUAGE="$2" RAY_BUILD_PYTHON="NO" RAY_BUILD_JAVA="NO" @@ -78,6 +82,26 @@ done if [[ -z "$PYTHON_EXECUTABLE" ]]; then PYTHON_EXECUTABLE=$(which python) fi + +PYTHON_VERSION=`"$PYTHON_EXECUTABLE" -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}".format(*version))'` +found= +for allowed in ${SUPPORTED_PYTHONS[@]} +do + if [[ "$PYTHON_VERSION" == $allowed ]] + then + found=$allowed + break + fi +done +if [[ -z $found ]] +then + cat <