diff options
author | Derek Murray <mrry@google.com> | 2017-10-02 13:38:53 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-10-02 13:43:29 -0700 |
commit | a8444b7c19d971e3f109adf4f1295f37d439af6c (patch) | |
tree | d4f3d3318ad6b759ccde4eb5511ffbdd5c967e28 /tensorflow/tools/build_info | |
parent | 7b098f62f983738bbf048873b6ecac3b26d40d68 (diff) |
[Windows] Improve import self-check with tests for GPU-related DLLs.
This change incorporates the full logic of the [Windows self-check
script](https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c)
into core TensorFlow.
Fixes #9170.
PiperOrigin-RevId: 170746452
Diffstat (limited to 'tensorflow/tools/build_info')
-rwxr-xr-x | tensorflow/tools/build_info/gen_build_info.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/tensorflow/tools/build_info/gen_build_info.py b/tensorflow/tools/build_info/gen_build_info.py index f59cdb0e1e..690214abfb 100755 --- a/tensorflow/tools/build_info/gen_build_info.py +++ b/tensorflow/tools/build_info/gen_build_info.py @@ -20,12 +20,19 @@ from __future__ import print_function import argparse -def write_build_info(filename, build_config): +def write_build_info(filename, build_config, key_value_list): """Writes a Python that describes the build. Args: filename: filename to write to. - build_config: A string containinggit_version: the result of a git describe. + build_config: A string that represents the config used in this build (e.g. + "cuda"). + key_value_list: A list of "key=value" strings that will be added to the + module as additional fields. + + Raises: + ValueError: If `key_value_list` includes the key "is_cuda_build", which + would clash with one of the default fields. """ module_docstring = "\"\"\"Generates a Python module containing information " module_docstring += "about the build.\"\"\"" @@ -34,6 +41,16 @@ def write_build_info(filename, build_config): else: build_config_bool = "False" + key_value_pair_stmts = [] + if key_value_list: + for arg in key_value_list: + key, value = arg.split("=") + if key == "is_cuda_build": + raise ValueError("The key \"is_cuda_build\" cannot be passed as one of " + "the --key_value arguments.") + key_value_pair_stmts.append("%s = %r" % (key, value)) + key_value_pair_content = "\n".join(key_value_pair_stmts) + contents = """ # Copyright 2017 The TensorFlow Authors. All Rights Reserved. # @@ -55,7 +72,9 @@ from __future__ import division from __future__ import print_function is_cuda_build = %s -""" % (module_docstring, build_config_bool) + +%s +""" % (module_docstring, build_config_bool, key_value_pair_content) open(filename, "w").write(contents) @@ -69,9 +88,12 @@ parser.add_argument( parser.add_argument("--raw_generate", type=str, help="Generate build_info.py") +parser.add_argument("--key_value", type=str, nargs="*", + help="List of key=value pairs.") + args = parser.parse_args() if args.raw_generate is not None and args.build_config is not None: - write_build_info(args.raw_generate, args.build_config) + write_build_info(args.raw_generate, args.build_config, args.key_value) else: raise RuntimeError("--raw_generate and --build_config must be used") |