From 77e2686a2958eb76e0164828d5d536b86c72464b Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Thu, 27 Sep 2018 06:19:58 -0700 Subject: Reduce the size of //tensorflow/tools/pip_package:simple_console_windows This change reduce the size of //tensorflow/tools/pip_package:simple_console_windows's zip file from 1000027677 bytes to 47690474 bytes for a CPU build. For GPU build, it will avoid going over 4GB when multiple CUDA compatibility are specified. To fix #22390 PiperOrigin-RevId: 214764423 --- tensorflow/tensorflow.bzl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tensorflow/tensorflow.bzl') diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index d6c75d675c..8f8bfadf78 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -1693,6 +1693,29 @@ register_extension_info( label_regex_for_dep = "{extension_name}", ) +# Similar to py_test above, this macro is used to exclude dependencies for some py_binary +# targets in order to reduce the size of //tensorflow/tools/pip_package:simple_console_windows. +# See https://github.com/tensorflow/tensorflow/issues/22390 +def py_binary(name, deps = [], **kwargs): + # Add an extra target for dependencies to avoid nested select statement. + native.py_library( + name = name + "_deps", + deps = deps, + ) + native.py_binary( + name = name, + deps = select({ + "//conditions:default": [":" + name + "_deps"], + clean_dep("//tensorflow:no_tensorflow_py_deps"): [], + }), + **kwargs + ) + +register_extension_info( + extension_name = "py_binary", + label_regex_for_dep = "{extension_name}", +) + def tf_py_test( name, srcs, -- cgit v1.2.3