Merge changes from github.
PiperOrigin-RevId: 181494416
diff --git a/configure.py b/configure.py
index 7537e30..cf16ef4 100644
--- a/configure.py
+++ b/configure.py
@@ -302,6 +302,12 @@
Returns:
boolean value of the variable.
+
+ Raises:
+ UserInputError: if an environment variable is set, but it cannot be
+ interpreted as a boolean indicator, assume that the user has made a
+ scripting error, and will continue to provide invalid input.
+ Raise the error to avoid infinitely looping.
"""
if not question:
question = 'Do you wish to build TensorFlow with %s support?' % query_item
@@ -319,6 +325,23 @@
question += ' [y/N]: '
var = environ_cp.get(var_name)
+ if var is not None:
+ var_content = var.strip().lower()
+ true_strings = ('1', 't', 'true', 'y', 'yes')
+ false_strings = ('0', 'f', 'false', 'n', 'no')
+ if var_content in true_strings:
+ var = True
+ elif var_content in false_strings:
+ var = False
+ else:
+ raise UserInputError(
+ 'Environment variable %s must be set as a boolean indicator.\n'
+ 'The following are accepted as TRUE : %s.\n'
+ 'The following are accepted as FALSE: %s.\n'
+ 'Current value is %s.' % (
+ var_name, ', '.join(true_strings), ', '.join(false_strings),
+ var))
+
while var is None:
user_input_origin = get_input(question)
user_input = user_input_origin.strip().lower()
@@ -605,8 +628,9 @@
Raises:
UserInputError: if a query has been attempted n_ask_attempts times without
- success, assume that the user has made a scripting error, and will continue
- to provide invalid input. Raise the error to avoid infinitely looping.
+ success, assume that the user has made a scripting error, and will
+ continue to provide invalid input. Raise the error to avoid infinitely
+ looping.
"""
default = environ_cp.get(var_name) or var_default
full_query = '%s [Default is %s]: ' % (
@@ -1101,11 +1125,13 @@
def set_trisycl_include_dir(environ_cp):
"""Set TRISYCL_INCLUDE_DIR."""
+
ask_trisycl_include_dir = ('Please specify the location of the triSYCL '
'include directory. (Use --config=sycl_trisycl '
'when building with Bazel) '
'[Default is %s]: '
) % (_DEFAULT_TRISYCL_INCLUDE_DIR)
+
while True:
trisycl_include_dir = get_from_env_or_user_or_default(
environ_cp, 'TRISYCL_INCLUDE_DIR', ask_trisycl_include_dir,