From b41761c499a5081870b9da4a8ae73adc45df269a Mon Sep 17 00:00:00 2001 From: Jason Zaman Date: Sun, 14 Oct 2018 11:28:53 +0800 Subject: [PATCH] Update to bazel-0.18.0 and use try-import Bazel-0.18.0 adds a try-import option that will non-fatally try and import a file. Use this for the configure options so that .bazelrc does not need to change. ./configure rewriting .bazelrc makes using the git repo annoying because the file is changed. The allowed bazel range is now 0.18.0-0.20.0 inclusive. The env var TF_IGNORE_MAX_BAZEL_VERSION can be set to skip the max bazel version check. Also optionally import a /.bazelrc.user file that is gitignored so user-specific options can go in there. Fixes: https://github.com/tensorflow/tensorflow/issues/22762 Fixes: https://github.com/tensorflow/tensorflow/pull/22906 Signed-off-by: Jason Zaman --- tools/bazel.rc => .bazelrc | 8 +++++++ .gitignore | 2 +- WORKSPACE | 2 +- configure.py | 22 ++++--------------- .../tools/ci_build/install/install_bazel.sh | 2 +- .../install/install_bazel_from_source.sh | 2 +- tensorflow/tools/docker/Dockerfile.devel | 2 +- tensorflow/tools/docker/Dockerfile.devel-gpu | 2 +- tensorflow/tools/docker/Dockerfile.devel-mkl | 2 +- .../tools/docker/Dockerfile.devel-mkl-horovod | 2 +- 10 files changed, 20 insertions(+), 26 deletions(-) rename tools/bazel.rc => .bazelrc (95%) diff --git a/tools/bazel.rc b/.bazelrc similarity index 95% rename from tools/bazel.rc rename to .bazelrc index 1fdf51f53e29c7..8d9834f59a655d 100644 --- a/tools/bazel.rc +++ b/.bazelrc @@ -93,3 +93,11 @@ build:dynamic_kernels --copt=-DAUTOLOAD_DYNAMIC_KERNELS build --define=PREFIX=/usr build --define=LIBDIR=$(PREFIX)/lib build --define=INCLUDEDIR=$(PREFIX)/include + +# Default options should come above this line + +# Options from ./configure +try-import %workspace%/.tf_configure.bazelrc + +# Put user-specific options in .bazelrc.user +try-import %workspace%/.bazelrc.user diff --git a/.gitignore b/.gitignore index 90324058600bee..e1d352c238a1b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .DS_Store .ipynb_checkpoints node_modules -/.bazelrc +/.bazelrc.user /.tf_configure.bazelrc /bazel-* /bazel_pip diff --git a/WORKSPACE b/WORKSPACE index 7cc08e0164a202..0f59c44e391369 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -47,7 +47,7 @@ remote_config_workspace() # files, in case the parsing of those build files depends on the bazel # version we require here. load("//tensorflow:version_check.bzl", "check_bazel_version_at_least") -check_bazel_version_at_least("0.15.0") +check_bazel_version_at_least("0.18.0") load("//tensorflow:workspace.bzl", "tf_workspace") diff --git a/configure.py b/configure.py index 6c905a0be3d685..d19607af6c2554 100644 --- a/configure.py +++ b/configure.py @@ -255,18 +255,6 @@ def setup_python(environ_cp): def reset_tf_configure_bazelrc(): """Reset file that contains customized config settings.""" open(_TF_BAZELRC, 'w').close() - bazelrc_path = os.path.join(_TF_WORKSPACE_ROOT, '.bazelrc') - - data = [] - if os.path.exists(bazelrc_path): - with open(bazelrc_path, 'r') as f: - data = f.read().splitlines() - with open(bazelrc_path, 'w') as f: - for l in data: - if _TF_BAZELRC_FILENAME in l: - continue - f.write('%s\n' % l) - f.write('import %%workspace%%/%s\n' % _TF_BAZELRC_FILENAME) def cleanup_makefile(): """Delete any leftover BUILD files from the Makefile build. @@ -488,11 +476,11 @@ def check_bazel_version(min_version, max_version): if curr_version_int < min_version_int: print('Please upgrade your bazel installation to version %s or higher to ' 'build TensorFlow!' % min_version) - sys.exit(0) - if curr_version_int > max_version_int: + sys.exit(1) + if curr_version_int > max_version_int and not 'TF_IGNORE_MAX_BAZEL_VERSION' in os.environ: print('Please downgrade your bazel installation to version %s or lower to ' 'build TensorFlow!' % max_version) - sys.exit(0) + sys.exit(1) return curr_version @@ -1565,11 +1553,9 @@ def main(): # environment variables. environ_cp = dict(os.environ) - check_bazel_version('0.15.0', '0.20.0') + check_bazel_version('0.18.0', '0.20.0') reset_tf_configure_bazelrc() - # Explicitly import tools/bazel.rc, this is needed for Bazel 0.19.0 or later - write_to_bazelrc('import %workspace%/tools/bazel.rc') cleanup_makefile() setup_python(environ_cp) diff --git a/tensorflow/tools/ci_build/install/install_bazel.sh b/tensorflow/tools/ci_build/install/install_bazel.sh index e284401b8aa469..7472053209cae9 100755 --- a/tensorflow/tools/ci_build/install/install_bazel.sh +++ b/tensorflow/tools/ci_build/install/install_bazel.sh @@ -15,7 +15,7 @@ # ============================================================================== # Select bazel version. -BAZEL_VERSION="0.15.0" +BAZEL_VERSION="0.18.0" set +e local_bazel_ver=$(bazel version 2>&1 | grep -i label | awk '{print $3}') diff --git a/tensorflow/tools/ci_build/install/install_bazel_from_source.sh b/tensorflow/tools/ci_build/install/install_bazel_from_source.sh index 87be81577d0efb..4f83815d77f81d 100755 --- a/tensorflow/tools/ci_build/install/install_bazel_from_source.sh +++ b/tensorflow/tools/ci_build/install/install_bazel_from_source.sh @@ -18,7 +18,7 @@ # It will compile bazel from source and install it in /usr/local/bin # Select bazel version. -BAZEL_VERSION="0.15.0" +BAZEL_VERSION="0.18.0" set +e local_bazel_ver=$(bazel version 2>&1 | grep -i label | awk '{print $3}') diff --git a/tensorflow/tools/docker/Dockerfile.devel b/tensorflow/tools/docker/Dockerfile.devel index c256dd364ef5a2..5ddcd3a2fdea8f 100644 --- a/tensorflow/tools/docker/Dockerfile.devel +++ b/tensorflow/tools/docker/Dockerfile.devel @@ -65,7 +65,7 @@ RUN echo "startup --batch" >>/etc/bazel.bazelrc RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \ >>/etc/bazel.bazelrc # Install the most recent bazel release. -ENV BAZEL_VERSION 0.15.0 +ENV BAZEL_VERSION 0.18.0 WORKDIR / RUN mkdir /bazel && \ cd /bazel && \ diff --git a/tensorflow/tools/docker/Dockerfile.devel-gpu b/tensorflow/tools/docker/Dockerfile.devel-gpu index 7f9b55b45595bc..767e5f4a4f1451 100644 --- a/tensorflow/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow/tools/docker/Dockerfile.devel-gpu @@ -87,7 +87,7 @@ RUN echo "startup --batch" >>/etc/bazel.bazelrc RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \ >>/etc/bazel.bazelrc # Install the most recent bazel release. -ENV BAZEL_VERSION 0.15.0 +ENV BAZEL_VERSION 0.18.0 WORKDIR / RUN mkdir /bazel && \ cd /bazel && \ diff --git a/tensorflow/tools/docker/Dockerfile.devel-mkl b/tensorflow/tools/docker/Dockerfile.devel-mkl index 2341c0e8ccfc5f..0980502bcc774b 100755 --- a/tensorflow/tools/docker/Dockerfile.devel-mkl +++ b/tensorflow/tools/docker/Dockerfile.devel-mkl @@ -88,7 +88,7 @@ RUN echo "startup --batch" >>/etc/bazel.bazelrc RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \ >>/etc/bazel.bazelrc # Install the most recent bazel release. -ENV BAZEL_VERSION 0.15.0 +ENV BAZEL_VERSION 0.18.0 WORKDIR / RUN mkdir /bazel && \ cd /bazel && \ diff --git a/tensorflow/tools/docker/Dockerfile.devel-mkl-horovod b/tensorflow/tools/docker/Dockerfile.devel-mkl-horovod index 5e24617b2190f1..90db249e3dd96f 100755 --- a/tensorflow/tools/docker/Dockerfile.devel-mkl-horovod +++ b/tensorflow/tools/docker/Dockerfile.devel-mkl-horovod @@ -79,7 +79,7 @@ RUN echo "startup --batch" >>/etc/bazel.bazelrc RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \ >>/etc/bazel.bazelrc # Install the most recent bazel release. -ENV BAZEL_VERSION 0.15.0 +ENV BAZEL_VERSION 0.18.0 WORKDIR / RUN mkdir /bazel && \ cd /bazel && \