@@ -180,65 +180,72 @@ if [[ "${BUILD_ENVIRONMENT}" == *clang* ]]; then
180180 export CXX=clang++
181181fi
182182
183+ if [[ " $BUILD_ENVIRONMENT " == * -bazel-* ]]; then
184+ set -e
183185
184- # check that setup.py would fail with bad arguments
185- echo " The next three invocations are expected to fail with invalid command error messages."
186- ( ! get_exit_code python setup.py bad_argument )
187- ( ! get_exit_code python setup.py clean] )
188- ( ! get_exit_code python setup.py clean bad_argument )
186+ get_bazel
189187
190- if [[ " $BUILD_ENVIRONMENT " != * libtorch* ]]; then
191-
192- # ppc64le build fails when WERROR=1
193- # set only when building other architectures
194- # only use for "python setup.py install" line
195- if [[ " $BUILD_ENVIRONMENT " != * ppc64le* && " $BUILD_ENVIRONMENT " != * clang* ]]; then
196- WERROR=1 python setup.py install
197- else
198- python setup.py install
199- fi
188+ tools/bazel build :torch
189+ else
190+ # check that setup.py would fail with bad arguments
191+ echo " The next three invocations are expected to fail with invalid command error messages."
192+ ( ! get_exit_code python setup.py bad_argument )
193+ ( ! get_exit_code python setup.py clean] )
194+ ( ! get_exit_code python setup.py clean bad_argument )
195+
196+ if [[ " $BUILD_ENVIRONMENT " != * libtorch* ]]; then
197+
198+ # ppc64le build fails when WERROR=1
199+ # set only when building other architectures
200+ # only use for "python setup.py install" line
201+ if [[ " $BUILD_ENVIRONMENT " != * ppc64le* && " $BUILD_ENVIRONMENT " != * clang* ]]; then
202+ WERROR=1 python setup.py install
203+ else
204+ python setup.py install
205+ fi
200206
201- # TODO: I'm not sure why, but somehow we lose verbose commands
202- set -x
207+ # TODO: I'm not sure why, but somehow we lose verbose commands
208+ set -x
203209
204- if which sccache > /dev/null; then
205- echo ' PyTorch Build Statistics'
206- sccache --show-stats
207- fi
210+ if which sccache > /dev/null; then
211+ echo ' PyTorch Build Statistics'
212+ sccache --show-stats
213+ fi
208214
209- assert_git_not_dirty
215+ assert_git_not_dirty
210216
211- # Build custom operator tests.
212- CUSTOM_OP_BUILD=" $PWD /../custom-op-build"
213- CUSTOM_OP_TEST=" $PWD /test/custom_operator"
214- python --version
215- SITE_PACKAGES=" $( python -c ' from distutils.sysconfig import get_python_lib; print(get_python_lib())' ) "
216- mkdir " $CUSTOM_OP_BUILD "
217- pushd " $CUSTOM_OP_BUILD "
218- cmake " $CUSTOM_OP_TEST " -DCMAKE_PREFIX_PATH=" $SITE_PACKAGES /torch" -DPYTHON_EXECUTABLE=" $( which python) "
219- make VERBOSE=1
220- popd
221- assert_git_not_dirty
222- else
223- # Test standalone c10 build
224- if [[ " $BUILD_ENVIRONMENT " == * xenial-cuda10.1-cudnn7-py3* ]]; then
225- mkdir -p c10/build
226- pushd c10/build
227- cmake ..
228- make -j
217+ # Build custom operator tests.
218+ CUSTOM_OP_BUILD=" $PWD /../custom-op-build"
219+ CUSTOM_OP_TEST=" $PWD /test/custom_operator"
220+ python --version
221+ SITE_PACKAGES=" $( python -c ' from distutils.sysconfig import get_python_lib; print(get_python_lib())' ) "
222+ mkdir " $CUSTOM_OP_BUILD "
223+ pushd " $CUSTOM_OP_BUILD "
224+ cmake " $CUSTOM_OP_TEST " -DCMAKE_PREFIX_PATH=" $SITE_PACKAGES /torch" -DPYTHON_EXECUTABLE=" $( which python) "
225+ make VERBOSE=1
229226 popd
230227 assert_git_not_dirty
231- fi
228+ else
229+ # Test standalone c10 build
230+ if [[ " $BUILD_ENVIRONMENT " == * xenial-cuda10.1-cudnn7-py3* ]]; then
231+ mkdir -p c10/build
232+ pushd c10/build
233+ cmake ..
234+ make -j
235+ popd
236+ assert_git_not_dirty
237+ fi
232238
233- # Test no-Python build
234- echo " Building libtorch"
235- # NB: Install outside of source directory (at the same level as the root
236- # pytorch folder) so that it doesn't get cleaned away prior to docker push.
237- BUILD_LIBTORCH_PY=$PWD /tools/build_libtorch.py
238- mkdir -p ../cpp-build/caffe2
239- pushd ../cpp-build/caffe2
240- WERROR=1 VERBOSE=1 DEBUG=1 python $BUILD_LIBTORCH_PY
241- popd
239+ # Test no-Python build
240+ echo " Building libtorch"
241+ # NB: Install outside of source directory (at the same level as the root
242+ # pytorch folder) so that it doesn't get cleaned away prior to docker push.
243+ BUILD_LIBTORCH_PY=$PWD /tools/build_libtorch.py
244+ mkdir -p ../cpp-build/caffe2
245+ pushd ../cpp-build/caffe2
246+ WERROR=1 VERBOSE=1 DEBUG=1 python $BUILD_LIBTORCH_PY
247+ popd
248+ fi
242249fi
243250
244251# Test XLA build
0 commit comments