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
This commit is contained in:
parent
3345a4083e
commit
56a99d6c28
12
configure.py
12
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)
|
||||
|
Loading…
Reference in New Issue
Block a user