summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-03-15 07:49:07 +0100
committerJürg Billeter <j@bitron.ch>2018-05-31 10:34:26 +0200
commitea6eca289402cc6bb9ca0468ceeb5a5f9e596dab (patch)
treecbd7367264c4fb46e135f3f8e312cde6551f5d21
parentf1b27bea882d867253d1dd37799c0fb9d8b3b09c (diff)
downloadbuildstream-ea6eca289402cc6bb9ca0468ceeb5a5f9e596dab.tar.gz
setup.py: Add grpcio dependency and support for code generation
This allows code generation with ./setup.py build_grpc
-rw-r--r--.pylintrc4
-rw-r--r--setup.cfg2
-rwxr-xr-xsetup.py40
3 files changed, 42 insertions, 4 deletions
diff --git a/.pylintrc b/.pylintrc
index c38309372..5ec6210aa 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -11,7 +11,7 @@ ignore=CVS,tests,doc
# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
-ignore-patterns=
+ignore-patterns=.*_pb2.py,.*_pb2_grpc.py
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
@@ -190,7 +190,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local,contextlib.closing,
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
-ignored-modules=pkg_resources,gi.repository
+ignored-modules=pkg_resources,gi.repository,grpc
# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
diff --git a/setup.cfg b/setup.cfg
index e0b3c9970..d37db7839 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -23,5 +23,7 @@ pep8ignore =
*/bin/* ALL
buildstream/_fuse/fuse.py ALL
.eggs/* ALL
+ *_pb2.py ALL
+ *_pb2_grpc.py ALL
env =
D:BST_TEST_SUITE=True
diff --git a/setup.py b/setup.py
index 03a2bda3d..13f00b969 100755
--- a/setup.py
+++ b/setup.py
@@ -29,7 +29,7 @@ if sys.version_info[0] != 3 or sys.version_info[1] < 4:
sys.exit(1)
try:
- from setuptools import setup, find_packages
+ from setuptools import setup, find_packages, Command
from setuptools.command.easy_install import ScriptWriter
except ImportError:
print("BuildStream requires setuptools in order to build. Install it using"
@@ -206,12 +206,46 @@ ScriptWriter.get_args = get_args
#####################################################
+# gRPC command for code generation #
+#####################################################
+class BuildGRPC(Command):
+ """Command to generate project *_pb2.py modules from proto files."""
+
+ description = 'build gRPC protobuf modules'
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ try:
+ import grpc_tools.command
+ except ImportError:
+ print("BuildStream requires grpc_tools in order to build gRPC modules.\n"
+ "Install it via pip (pip3 install grpcio-tools).")
+ exit(1)
+
+ grpc_tools.command.build_package_protos('.')
+
+
+def get_cmdclass():
+ cmdclass = {
+ 'build_grpc': BuildGRPC,
+ }
+ cmdclass.update(versioneer.get_cmdclass())
+ return cmdclass
+
+
+#####################################################
# Main setup() Invocation #
#####################################################
setup(name='BuildStream',
# Use versioneer
version=versioneer.get_version(),
- cmdclass=versioneer.get_cmdclass(),
+ cmdclass=get_cmdclass(),
description='A framework for modelling build pipelines in YAML',
license='LGPL',
@@ -243,6 +277,8 @@ setup(name='BuildStream',
'Click',
'blessings',
'jinja2 >= 2.10',
+ 'protobuf >= 3.5',
+ 'grpcio',
],
entry_points=bst_install_entry_points,
setup_requires=['pytest-runner'],