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>
changes/45/1825945/10
Bruce Dawson 6 years ago committed by Commit Bot
parent a19d35307b
commit f1b21e4633

@ -118,6 +118,12 @@ import setup_color
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:

@ -38,6 +38,8 @@ class GClientSmokeBase(fake_repos.FakeReposTestBase):
self.env = os.environ.copy()
self.env['DEPOT_TOOLS_UPDATE'] = '0'
self.env['DEPOT_TOOLS_METRICS'] = '0'
# Suppress Python 3 warnings and other test undesirables.
self.env['GCLIENT_TEST'] = '1'
def gclient(self, cmd, cwd=None):
if not cwd:

Loading…
Cancel
Save