Skip to content

Commit b41761c

Browse files
committed
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: tensorflow#22762 Fixes: tensorflow#22906 Signed-off-by: Jason Zaman <[email protected]>
1 parent 43a1df9 commit b41761c

10 files changed

+20
-26
lines changed

tools/bazel.rc .bazelrc

+8
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,11 @@ build:dynamic_kernels --copt=-DAUTOLOAD_DYNAMIC_KERNELS
9393
build --define=PREFIX=/usr
9494
build --define=LIBDIR=$(PREFIX)/lib
9595
build --define=INCLUDEDIR=$(PREFIX)/include
96+
97+
# Default options should come above this line
98+
99+
# Options from ./configure
100+
try-import %workspace%/.tf_configure.bazelrc
101+
102+
# Put user-specific options in .bazelrc.user
103+
try-import %workspace%/.bazelrc.user

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.DS_Store
22
.ipynb_checkpoints
33
node_modules
4-
/.bazelrc
4+
/.bazelrc.user
55
/.tf_configure.bazelrc
66
/bazel-*
77
/bazel_pip

WORKSPACE

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ remote_config_workspace()
4747
# files, in case the parsing of those build files depends on the bazel
4848
# version we require here.
4949
load("//tensorflow:version_check.bzl", "check_bazel_version_at_least")
50-
check_bazel_version_at_least("0.15.0")
50+
check_bazel_version_at_least("0.18.0")
5151

5252
load("//tensorflow:workspace.bzl", "tf_workspace")
5353

configure.py

+4-18
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,6 @@ def setup_python(environ_cp):
255255
def reset_tf_configure_bazelrc():
256256
"""Reset file that contains customized config settings."""
257257
open(_TF_BAZELRC, 'w').close()
258-
bazelrc_path = os.path.join(_TF_WORKSPACE_ROOT, '.bazelrc')
259-
260-
data = []
261-
if os.path.exists(bazelrc_path):
262-
with open(bazelrc_path, 'r') as f:
263-
data = f.read().splitlines()
264-
with open(bazelrc_path, 'w') as f:
265-
for l in data:
266-
if _TF_BAZELRC_FILENAME in l:
267-
continue
268-
f.write('%s\n' % l)
269-
f.write('import %%workspace%%/%s\n' % _TF_BAZELRC_FILENAME)
270258

271259
def cleanup_makefile():
272260
"""Delete any leftover BUILD files from the Makefile build.
@@ -488,11 +476,11 @@ def check_bazel_version(min_version, max_version):
488476
if curr_version_int < min_version_int:
489477
print('Please upgrade your bazel installation to version %s or higher to '
490478
'build TensorFlow!' % min_version)
491-
sys.exit(0)
492-
if curr_version_int > max_version_int:
479+
sys.exit(1)
480+
if curr_version_int > max_version_int and not 'TF_IGNORE_MAX_BAZEL_VERSION' in os.environ:
493481
print('Please downgrade your bazel installation to version %s or lower to '
494482
'build TensorFlow!' % max_version)
495-
sys.exit(0)
483+
sys.exit(1)
496484
return curr_version
497485

498486

@@ -1565,11 +1553,9 @@ def main():
15651553
# environment variables.
15661554
environ_cp = dict(os.environ)
15671555

1568-
check_bazel_version('0.15.0', '0.20.0')
1556+
check_bazel_version('0.18.0', '0.20.0')
15691557

15701558
reset_tf_configure_bazelrc()
1571-
# Explicitly import tools/bazel.rc, this is needed for Bazel 0.19.0 or later
1572-
write_to_bazelrc('import %workspace%/tools/bazel.rc')
15731559

15741560
cleanup_makefile()
15751561
setup_python(environ_cp)

tensorflow/tools/ci_build/install/install_bazel.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# ==============================================================================
1616

1717
# Select bazel version.
18-
BAZEL_VERSION="0.15.0"
18+
BAZEL_VERSION="0.18.0"
1919

2020
set +e
2121
local_bazel_ver=$(bazel version 2>&1 | grep -i label | awk '{print $3}')

tensorflow/tools/ci_build/install/install_bazel_from_source.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# It will compile bazel from source and install it in /usr/local/bin
1919

2020
# Select bazel version.
21-
BAZEL_VERSION="0.15.0"
21+
BAZEL_VERSION="0.18.0"
2222

2323
set +e
2424
local_bazel_ver=$(bazel version 2>&1 | grep -i label | awk '{print $3}')

tensorflow/tools/docker/Dockerfile.devel

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ RUN echo "startup --batch" >>/etc/bazel.bazelrc
6565
RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
6666
>>/etc/bazel.bazelrc
6767
# Install the most recent bazel release.
68-
ENV BAZEL_VERSION 0.15.0
68+
ENV BAZEL_VERSION 0.18.0
6969
WORKDIR /
7070
RUN mkdir /bazel && \
7171
cd /bazel && \

tensorflow/tools/docker/Dockerfile.devel-gpu

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ RUN echo "startup --batch" >>/etc/bazel.bazelrc
8787
RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
8888
>>/etc/bazel.bazelrc
8989
# Install the most recent bazel release.
90-
ENV BAZEL_VERSION 0.15.0
90+
ENV BAZEL_VERSION 0.18.0
9191
WORKDIR /
9292
RUN mkdir /bazel && \
9393
cd /bazel && \

tensorflow/tools/docker/Dockerfile.devel-mkl

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ RUN echo "startup --batch" >>/etc/bazel.bazelrc
8888
RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
8989
>>/etc/bazel.bazelrc
9090
# Install the most recent bazel release.
91-
ENV BAZEL_VERSION 0.15.0
91+
ENV BAZEL_VERSION 0.18.0
9292
WORKDIR /
9393
RUN mkdir /bazel && \
9494
cd /bazel && \

tensorflow/tools/docker/Dockerfile.devel-mkl-horovod

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ RUN echo "startup --batch" >>/etc/bazel.bazelrc
7979
RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
8080
>>/etc/bazel.bazelrc
8181
# Install the most recent bazel release.
82-
ENV BAZEL_VERSION 0.15.0
82+
ENV BAZEL_VERSION 0.18.0
8383
WORKDIR /
8484
RUN mkdir /bazel && \
8585
cd /bazel && \

0 commit comments

Comments
 (0)