Skip to content
Snippets Groups Projects
Commit 59994bcc authored by Masood Malekghassemi's avatar Masood Malekghassemi
Browse files

Warn on Python proto module build failure

parent df97aecb
No related branches found
No related tags found
No related merge requests found
...@@ -51,6 +51,10 @@ html_theme = 'sphinx_rtd_theme' ...@@ -51,6 +51,10 @@ html_theme = 'sphinx_rtd_theme'
""" """
class CommandError(Exception):
"""Simple exception class for GRPC custom commands."""
class SphinxDocumentation(setuptools.Command): class SphinxDocumentation(setuptools.Command):
"""Command to generate documentation via sphinx.""" """Command to generate documentation via sphinx."""
...@@ -104,10 +108,10 @@ class BuildProtoModules(setuptools.Command): ...@@ -104,10 +108,10 @@ class BuildProtoModules(setuptools.Command):
def run(self): def run(self):
if not self.protoc_command: if not self.protoc_command:
raise Exception('could not find protoc') raise CommandError('could not find protoc')
if not self.grpc_python_plugin_command: if not self.grpc_python_plugin_command:
raise Exception('could not find grpc_python_plugin ' raise CommandError('could not find grpc_python_plugin '
'(protoc plugin for GRPC Python)') '(protoc plugin for GRPC Python)')
include_regex = re.compile(self.include) include_regex = re.compile(self.include)
exclude_regex = re.compile(self.exclude) if self.exclude else None exclude_regex = re.compile(self.exclude) if self.exclude else None
paths = [] paths = []
...@@ -130,7 +134,7 @@ class BuildProtoModules(setuptools.Command): ...@@ -130,7 +134,7 @@ class BuildProtoModules(setuptools.Command):
subprocess.check_output(' '.join(command), cwd=root_directory, shell=True, subprocess.check_output(' '.join(command), cwd=root_directory, shell=True,
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
raise Exception('Command:\n{}\nMessage:\n{}\nOutput:\n{}'.format( raise CommandError('Command:\n{}\nMessage:\n{}\nOutput:\n{}'.format(
command, e.message, e.output)) command, e.message, e.output))
...@@ -156,9 +160,10 @@ class BuildPy(build_py.build_py): ...@@ -156,9 +160,10 @@ class BuildPy(build_py.build_py):
"""Custom project build command.""" """Custom project build command."""
def run(self): def run(self):
# TODO(atash): make this warn if the proto modules couldn't be built rather try:
# than cause build failure self.run_command('build_proto_modules')
self.run_command('build_proto_modules') except CommandError as error:
sys.stderr.write('warning: %s\n' % error.message)
self.run_command('build_project_metadata') self.run_command('build_project_metadata')
build_py.build_py.run(self) build_py.build_py.run(self)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment