Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions sdks/python/gen_protos.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import multiprocessing
import os
import pkg_resources
import shutil
import subprocess
import sys
import warnings
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()

Expand Down