From 2ce9d4421daa7e6f254c265bd754b503fdfc7570 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 17 Jan 2018 18:52:47 +0000 Subject: [PATCH 1/3] Fix issue of branch switching not working with bazel This fix tries to address the issue raised in 15957 where bazel stops working after switching git branch, and reconfigure with `./configure` will not work as well. This fix adds a quick fix as was suggested, by having export TF_CONFIG_TIME="$(date)" in configure.py and add it to the environ list in git_configure.bzl. This fix fixes 15957. Signed-off-by: Yong Tang --- configure.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.py b/configure.py index cf16ef48376..88dedae5c6e 100644 --- a/configure.py +++ b/configure.py @@ -18,6 +18,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +import datetime import errno import os import platform @@ -1233,6 +1234,7 @@ def main(): reset_tf_configure_bazelrc() cleanup_makefile() + write_action_env_to_bazelrc("TF_CONFIG_TIME", str(datetime.datetime.now())) setup_python(environ_cp) if is_windows(): From e2a2194cd746a0f11e97d315ee870fd7e10fd62d Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 17 Jan 2018 18:58:01 +0000 Subject: [PATCH 2/3] Add TF_CONFIG_TIME to environ list in git_configure.bzl Signed-off-by: Yong Tang --- third_party/git/git_configure.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/third_party/git/git_configure.bzl b/third_party/git/git_configure.bzl index 47e21258541..fdf1c0c36ab 100644 --- a/third_party/git/git_configure.bzl +++ b/third_party/git/git_configure.bzl @@ -5,6 +5,7 @@ * `PYTHON_BIN_PATH`: location of python binary. """ +_TF_CONFIG_TIME = "TF_CONFIG_TIME" _PYTHON_BIN_PATH = "PYTHON_BIN_PATH" def _fail(msg): @@ -50,6 +51,7 @@ def _git_conf_impl(repository_ctx): git_configure = repository_rule( implementation = _git_conf_impl, environ = [ + _TF_CONFIG_TIME, _PYTHON_BIN_PATH, ], ) From 5410ef84e7cb6a7a666d0c5b2fc65bee301d4da6 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 19 Jan 2018 19:06:49 +0000 Subject: [PATCH 3/3] Update dependency rules in Bazel Signed-off-by: Yong Tang --- configure.py | 2 -- third_party/git/git_configure.bzl | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/configure.py b/configure.py index 88dedae5c6e..cf16ef48376 100644 --- a/configure.py +++ b/configure.py @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import datetime import errno import os import platform @@ -1234,7 +1233,6 @@ def main(): reset_tf_configure_bazelrc() cleanup_makefile() - write_action_env_to_bazelrc("TF_CONFIG_TIME", str(datetime.datetime.now())) setup_python(environ_cp) if is_windows(): diff --git a/third_party/git/git_configure.bzl b/third_party/git/git_configure.bzl index fdf1c0c36ab..8e2839bdc25 100644 --- a/third_party/git/git_configure.bzl +++ b/third_party/git/git_configure.bzl @@ -5,7 +5,6 @@ * `PYTHON_BIN_PATH`: location of python binary. """ -_TF_CONFIG_TIME = "TF_CONFIG_TIME" _PYTHON_BIN_PATH = "PYTHON_BIN_PATH" def _fail(msg): @@ -39,6 +38,11 @@ def _git_conf_impl(repository_ctx): Label("@org_tensorflow//tensorflow/tools/git:gen_git_source.py")) generated_files_path = repository_ctx.path("gen") + r = repository_ctx.execute( + ["test", "-f", "%s/.git/logs/HEAD" % tensorflow_root_path]) + if r.return_code == 0: + unused_var = repository_ctx.path(Label("//:.git/HEAD")) # pylint: disable=unused-variable + result = repository_ctx.execute([ _get_python_bin(repository_ctx), python_script_path, "--configure", tensorflow_root_path, @@ -51,7 +55,6 @@ def _git_conf_impl(repository_ctx): git_configure = repository_rule( implementation = _git_conf_impl, environ = [ - _TF_CONFIG_TIME, _PYTHON_BIN_PATH, ], )