Provide a more informative error message when the bazel version check fails
Currently, if the version check fails, the error message is:
```
subprocess.CalledProcessError: Command '['bazel', '--batch', '--bazelrc=/dev/null', 'version']' returned non-zero exit status 1.
```
After this patch, it becomes:
```
Error checking bazel version: ERROR: The project you're trying to build requires Bazel 3.0.0 (specified in /usr/local/google/home/cheshire/code/opensource/docker_tf/tensorflow/.bazelversion), but it wasn't found in /usr/bin.
You can install the required Bazel version via apt:
sudo apt update && sudo apt install bazel-3.0.0
```
PiperOrigin-RevId: 312520687
Change-Id: I41523f7defa3db10aa34b6b313d6b65c792b2020
diff --git a/configure.py b/configure.py
index 9154000..0a5b8717 100644
--- a/configure.py
+++ b/configure.py
@@ -1368,8 +1368,13 @@
# environment variables.
environ_cp = dict(os.environ)
- current_bazel_version = check_bazel_version(_TF_MIN_BAZEL_VERSION,
- _TF_MAX_BAZEL_VERSION)
+ try:
+ current_bazel_version = check_bazel_version(_TF_MIN_BAZEL_VERSION,
+ _TF_MAX_BAZEL_VERSION)
+ except subprocess.CalledProcessError as e:
+ print("Error checking bazel version: ", e.output.decode('UTF-8').strip())
+ raise e
+
_TF_CURRENT_BAZEL_VERSION = convert_version_to_int(current_bazel_version)
reset_tf_configure_bazelrc()