From 780e6bf8d43870389e6eba66611c7f25c8e0f6f3 Mon Sep 17 00:00:00 2001 From: Edward Lemur Date: Fri, 28 Feb 2020 00:32:05 +0000 Subject: [PATCH] gclient: Allow setting GCLIENT_PY3 to 0 to run on Python 2. As we update scripts to run Python 3 by default, we want to provide developers a way to execute scripts on Python 2 if they encounter any problems. This change only affects Linux/Mac and not Windows developers. Bug: 984182 Change-Id: I7c7bd2a45ef50e340f6f2b85e9bc8b63f22d8678 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2079701 Reviewed-by: Josip Sokcevic Commit-Queue: Edward Lesmes --- fetch | 5 +++++ gclient | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fetch b/fetch index fd28305258..96e984a3ef 100755 --- a/fetch +++ b/fetch @@ -10,7 +10,12 @@ base_dir=$(dirname "$0") PATH=$PATH:$base_dir if [[ $GCLIENT_PY3 == 1 ]]; then + # Explicitly run on Python 3 PYTHONDONTWRITEBYTECODE=1 exec vpython3 "$base_dir/fetch.py" "$@" +elif [[ $GCLIENT_PY3 == 0 ]]; then + # Explicitly run on Python 2 + PYTHONDONTWRITEBYTECODE=1 exec vpython "$base_dir/fetch.py" "$@" else + # Run on Python 2 for now, allows default to be flipped. PYTHONDONTWRITEBYTECODE=1 exec vpython "$base_dir/fetch.py" "$@" fi diff --git a/gclient b/gclient index 453e06562b..1dfb7f6c19 100755 --- a/gclient +++ b/gclient @@ -27,7 +27,12 @@ fi PATH=$PATH:$base_dir if [[ $GCLIENT_PY3 == 1 ]]; then + # Explicitly run on Python 3 PYTHONDONTWRITEBYTECODE=1 exec vpython3 "$base_dir/gclient.py" "$@" +elif [[ $GCLIENT_PY3 == 0 ]]; then + # Explicitly run on Python 2 + PYTHONDONTWRITEBYTECODE=1 exec vpython "$base_dir/gclient.py" "$@" else - PYTHONDONTWRITEBYTECODE=1 exec python "$base_dir/gclient.py" "$@" + # Run on Python 2 for now, allows default to be flipped. + PYTHONDONTWRITEBYTECODE=1 exec vpython "$base_dir/gclient.py" "$@" fi