More robust gen_protos on jenkins. Don't use the globally shared build directory, which pip may refuse to use if there's a failed install.
Project: http://git-wip-us.apache.org/repos/asf/beam/repo Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/6b21ea66 Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/6b21ea66 Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/6b21ea66 Branch: refs/heads/master Commit: 6b21ea660eb82c486d17c5d8041c90c6479a54dc Parents: 3643676 Author: Robert Bradshaw <rober...@gmail.com> Authored: Thu May 25 10:30:44 2017 -0700 Committer: Robert Bradshaw <rober...@gmail.com> Committed: Thu May 25 12:33:58 2017 -0700 ---------------------------------------------------------------------- sdks/python/gen_protos.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/beam/blob/6b21ea66/sdks/python/gen_protos.py ---------------------------------------------------------------------- diff --git a/sdks/python/gen_protos.py b/sdks/python/gen_protos.py index edaaff4..bb8592d 100644 --- a/sdks/python/gen_protos.py +++ b/sdks/python/gen_protos.py @@ -22,6 +22,7 @@ import logging import multiprocessing import os import pkg_resources +import shutil import subprocess import sys import warnings @@ -55,10 +56,11 @@ def generate_proto_files(): if out_files and not proto_files: # We have out_files but no protos; assume they're up to date. # This is actually the common case (e.g. installation from an sdist). + logging.info('No proto files; using existing generated files.') return elif not out_files and not proto_files: - if not common: + if not os.path.exists(common): raise RuntimeError( 'Not in apache git tree; unable to find proto definitions.') else: @@ -105,9 +107,13 @@ def generate_proto_files(): def _install_grpcio_tools_and_generate_proto_files(): install_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), '.eggs', 'grpcio-wheels') - logging.warning('Downloading a grpcio-tools to %s' % install_path) + build_path = install_path + '-build' + if os.path.exists(build_path): + shutil.rmtree(build_path) + logging.warning('Installing grpcio-tools into %s' % install_path) subprocess.check_call( - ['pip', 'install', '-t', install_path, '--upgrade', GRPC_TOOLS]) + ['pip', 'install', '--target', install_path, '--build', build_path, + '--upgrade', GRPC_TOOLS]) sys.path.append(install_path) generate_proto_files()