diff --git a/vpython b/vpython index e57873cdb..63dbf5441 100755 --- a/vpython +++ b/vpython @@ -39,4 +39,17 @@ base_dir=$(dirname "$0") source "$base_dir/cipd_bin_setup.sh" cipd_bin_setup &> /dev/null -exec "$base_dir/.cipd_bin/vpython" "$@" +# If Python bootstrapping is not disabled, make sure Python has been +# bootstrapped and add it to the front of PATH. +if [[ $(uname -s) = MINGW* || $(uname -s) = CYGWIN* ]]; then + cmd.exe //c $0.bat "$@" +elif [[ $DEPOT_TOOLS_BOOTSTRAP_PYTHON3 != 0 ]]; then + if [[ ! -e "$base_dir/python_bin_reldir.txt" ]]; then + source "$base_dir/bootstrap_python3" + bootstrap_python3 + fi + PYTHON_BIN_RELDIR="$base_dir/$(cat "$base_dir/python_bin_reldir.txt" | xargs echo)" + exec "$base_dir/.cipd_bin/vpython" -vpython-interpreter "$PYTHON_BIN_RELDIR/python" "$@" +else + exec "$base_dir/.cipd_bin/vpython" "$@" +fi