gyp: default to python3 if available
Python2 was sunsetted in 2020. Google3 gyp fork already defaults to
python3, this patch brings it closer to upstream.
Bug: 227327945
Change-Id: Ia7f5c856355fa4d012dfc5b03ec0bc3f605ea407
Reviewed-on: https://chromium-review.googlesource.com/c/external/gyp/+/3562924
Reviewed-by: Mark Mentovai <mark@chromium.org>
diff --git a/gyp b/gyp
index 1b8b9bd..1c6e2d2 100755
--- a/gyp
+++ b/gyp
@@ -3,6 +3,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-set -e
+set -eu
base=$(dirname "$0")
-exec python "${base}/gyp_main.py" "$@"
+if type python3 >& /dev/null; then
+ python=python3
+else
+ python=python
+fi
+exec "${python}" "${base}/gyp_main.py" "$@"
diff --git a/gyp_main.py b/gyp_main.py
index 25a6eba..a7a0066 100755
--- a/gyp_main.py
+++ b/gyp_main.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (c) 2009 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be