mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Reland "cros: switch CrOS programs to python3"
This is a reland of 35b70cac56.
With the recent vpython3 PATH fixes, hopefully this should pass now.
Original change's description:
> cros: switch CrOS programs to python3
>
> We start warning if people have outdated systems.
>
> Bug: 997354
> Test: `cros --help` uses python3 now
> Change-Id: I1491f1c0eea4d544cc508b461153c54c8072699d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2052243
> Commit-Queue: Mike Frysinger <vapier@chromium.org>
> Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Bug: 997354
Change-Id: Ic7e040af6a34d112cd0a1c1421cdd25bc557ee19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2052625
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
This commit is contained in:
29
cros
29
cros
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
@@ -16,6 +16,13 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
# Min version of Python that we *want*. We warn for older versions.
|
||||||
|
MIN_PYTHON_VER_SOFT = (3, 6)
|
||||||
|
# Min version of Python that we *require*. We abort for older versions.
|
||||||
|
# TODO(vapier): Hard require Python 3.6 by end of 2020.
|
||||||
|
MIN_PYTHON_VER_HARD = (3, 4)
|
||||||
|
|
||||||
|
|
||||||
def _FindChromite(path):
|
def _FindChromite(path):
|
||||||
"""Find the chromite dir in a repo, gclient, or submodule checkout."""
|
"""Find the chromite dir in a repo, gclient, or submodule checkout."""
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
@@ -46,7 +53,27 @@ and retry. If you need to setup a Chromium OS source tree, see
|
|||||||
return 127
|
return 127
|
||||||
|
|
||||||
|
|
||||||
|
def _CheckPythonVersion():
|
||||||
|
"""Verify active Python is new enough."""
|
||||||
|
if sys.version_info >= MIN_PYTHON_VER_SOFT:
|
||||||
|
return
|
||||||
|
|
||||||
|
progname = os.path.basename(sys.argv[0])
|
||||||
|
print('%s: Chrome OS requires Python-%s+, but found "%s"' %
|
||||||
|
(progname, '.'.join(str(x) for x in MIN_PYTHON_VER_SOFT),
|
||||||
|
sys.version.replace('\n', ' ')), file=sys.stderr)
|
||||||
|
if sys.version_info < MIN_PYTHON_VER_HARD:
|
||||||
|
print('%s: fatal: giving up since Python is too old.' % (progname,),
|
||||||
|
file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
print('warning: temporarily continuing anyways; you must upgrade soon to '
|
||||||
|
'maintain support.', file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
_CheckPythonVersion()
|
||||||
|
|
||||||
chromite_dir = _FindChromite(os.getcwd())
|
chromite_dir = _FindChromite(os.getcwd())
|
||||||
target = os.path.basename(sys.argv[0])
|
target = os.path.basename(sys.argv[0])
|
||||||
if chromite_dir is None:
|
if chromite_dir is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user