From 619f3d13ef89a3bd3cf1e0dc6a8d91040371e980 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Fri, 2 Sep 2016 21:11:38 +0200 Subject: [PATCH] Add detection of python3 to hacking/env-setup (#17357) People can still override the detection using PYTHON_BIN --- hacking/env-setup | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hacking/env-setup b/hacking/env-setup index 25255f13c5..869f3b6551 100644 --- a/hacking/env-setup +++ b/hacking/env-setup @@ -5,6 +5,9 @@ PYTHONPATH=${PYTHONPATH-""} PATH=${PATH-""} MANPATH=${MANPATH-""} +PYTHON=$(which python 2>/dev/null || which python3 2>/dev/null) +PYTHON_BIN=${PYTHON_BIN-$PYTHON} + verbosity=${1-info} # Defaults to `info' if unspecified if [ "$verbosity" = -q ]; then @@ -24,7 +27,7 @@ else fi # The below is an alternative to readlink -fn which doesn't exist on OS X # Source: http://stackoverflow.com/a/1678636 -FULL_PATH=$(python -c "import os; print(os.path.realpath('$HACKING_DIR'))") +FULL_PATH=$($PYTHON_BIN -c "import os; print(os.path.realpath('$HACKING_DIR'))") export ANSIBLE_HOME="$(dirname "$FULL_PATH")" PREFIX_PYTHONPATH="$ANSIBLE_HOME/lib" @@ -45,7 +48,7 @@ gen_egg_info() if [ -e "$PREFIX_PYTHONPATH/ansible.egg-info" ] ; then \rm -rf "$PREFIX_PYTHONPATH/ansible.egg-info" fi - python setup.py egg_info + $PYTHON_BIN setup.py egg_info } if [ "$ANSIBLE_HOME" != "$PWD" ] ; then