From 56a99d6c28fd0ff238bd834bd32c2d3fc894b86c Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 8 May 2020 09:28:28 -0700 Subject: [PATCH] configure.py: Simplify bazel version check Use `bazel --version` instead of `bazel --batch version`. `bazel --batch` fails on Windows with a "command line too long" error, if user's environment variable is too large. Example: https://buildkite.com/bazel/bazelisk-plus-incompatible-flags/builds/496#f5fbd8db-7421-43f4-a018-555af9856be4 `bazel --version` can also print the Bazel version without starting Bazel server, it's even faster than `bazel --batch version`. PiperOrigin-RevId: 310570885 Change-Id: Iafc4c90f0ff57610e5f77bee230e81e78d9f1289 --- configure.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/configure.py b/configure.py index ac9ed0c4d88..a003265f3c9 100644 --- a/configure.py +++ b/configure.py @@ -479,13 +479,13 @@ def check_bazel_version(min_version, max_version): if which('bazel') is None: print('Cannot find bazel. Please install bazel.') sys.exit(0) - curr_version = run_shell( - ['bazel', '--batch', '--bazelrc=/dev/null', 'version']) - for line in curr_version.split('\n'): - if 'Build label: ' in line: - curr_version = line.split('Build label: ')[1] - break + stderr = open(os.devnull, 'wb') + curr_version = run_shell(['bazel', '--version'], + allow_non_zero = True, + stderr = stderr) + if curr_version.startswith('bazel '): + curr_version = curr_version.split('bazel ')[1] min_version_int = convert_version_to_int(min_version) curr_version_int = convert_version_to_int(curr_version)