From: Nathan Cutler Date: Fri, 13 Sep 2019 14:12:52 +0000 (+0200) Subject: tools/setup-virtualenv.sh: do not default to python2.7 X-Git-Tag: v14.2.8~20^2~51^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=028ac37de6a15645cfd159cc1abe4e9ae9daa078;p=ceph.git tools/setup-virtualenv.sh: do not default to python2.7 This commit changes the script's behavior when run without a --python option. Before, we were running virtualenv with "--python python2.7" in that case. That is not a reasonable default in September 2019, given that Python 2 EOL is coming on January 1, 2020. Also, it breaks setup-virtualenv.sh in py3-only environments. With this patch, the script will not pass any "--python" option to virtualenv (i.e., it will let virtualenv do whatever it thinks is best) in this case. Fixes: https://tracker.ceph.com/issues/41821 Signed-off-by: Nathan Cutler (cherry picked from commit 78468e49ab2110d69bc34333c0ce90acb832de1a) --- diff --git a/src/tools/setup-virtualenv.sh b/src/tools/setup-virtualenv.sh index 89e50b744ff97..f0fa1e4345ebe 100755 --- a/src/tools/setup-virtualenv.sh +++ b/src/tools/setup-virtualenv.sh @@ -16,7 +16,6 @@ # SCRIPTNAME="$(basename $0)" -PYTHON_BINARY="python2.7" if [ `uname` == FreeBSD ]; then GETOPT="/usr/local/bin/getopt" else @@ -31,7 +30,6 @@ function usage { echo "Usage:" echo " $SCRIPTNAME [--python=PYTHON_BINARY] TARGET_DIRECTORY" echo - echo " PYTHON_BINARY defaults to \"$PYTHON_BINARY\"" echo " TARGET_DIRECTORY will be created if it doesn't exist," echo " and completely destroyed and re-created if it does!" echo @@ -42,10 +40,11 @@ TEMP=$($GETOPT --options "h" --long "help,python:" --name "$SCRIPTNAME" -- "$@") test $? != 0 && usage eval set -- "$TEMP" +PYTHON_OPTION="" while true ; do case "$1" in -h|--help) usage ;; # does not return - --python) PYTHON_BINARY="$2" ; shift ; shift ;; + --python) PYTHON_OPTION="--python=$2" ; shift ; shift ;; --) shift ; break ;; *) echo "Internal error" ; exit 1 ;; esac @@ -58,7 +57,7 @@ if [ -z "$DIR" ] ; then fi rm -fr $DIR mkdir -p $DIR -virtualenv --python $PYTHON_BINARY $DIR +virtualenv $PYTHON_OPTION $DIR . $DIR/bin/activate if pip --help | grep -q disable-pip-version-check; then