Make gclient.py warn on Python 3
An increasing number of Windows developers are "accidentally" ending up
with Python 3 installed on their machine through the Windows Store. If
this version is first in the path then gclient may fail in non-obvious
ways. This adds a python version check to give a clear warning message.
R=vapier@chromium.org
Change-Id: I7a292fba2ab7d059a6149644d0b1fd92d2371dce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1825945
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/gclient.py b/gclient.py
index 6bfe151..9bc33fd 100755
--- a/gclient.py
+++ b/gclient.py
@@ -118,6 +118,12 @@
from third_party import six
+# Check for people accidentally running this script with Python3 - an
+# increasingly common error on Windows 10 due to the store version of Python.
+if sys.version_info.major >= 3 and not 'GCLIENT_TEST' in os.environ:
+ print("Warning: gclient doesn't yet support Python 3 and may not work "
+ "correctly.", file=sys.stderr)
+
# TODO(crbug.com/953884): Remove this when python3 migration is done.
if six.PY3: