Skip to content

Commit b512c89

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
tox.ini: add new environments for generating grpc related files
Add a new tox environment that is to be used for regenerated python source files from .proto files. Currently, it is up to the contributor to make sure these are up-to-date. A second env is provided for use on centos/fedora with packaged versions for grpc and protobuf in order to make sure the generated files match what the planned deployment containers will support. Signed-off-by: John Mulligan <[email protected]>
1 parent ddfd71e commit b512c89

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tox.ini

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,47 @@ deps =
9090
gitlint==0.19.1
9191
commands =
9292
gitlint -C .gitlint --commits origin/master.. lint
93+
94+
95+
# IMPORTANT: note that there are two environments provided here for generating
96+
# the grpc/protobuf files. One uses a typical tox environment with versions
97+
# and the other uses system packages (sitepackages=True).
98+
# The former is what developers are expected to use HOWEVER because we must
99+
# deliver on enterprise linux platforms we provide a way to generate
100+
# the code using system packages for comparison purposes.
101+
102+
# Generate grpc/protobuf code from .proto files.
103+
# Includes a generator for .pyi files.
104+
# Uses sed to fix the foolish import behavior of the grpc generator.
105+
[testenv:grpc-generate]
106+
description = Generate gRPC files
107+
deps =
108+
grpcio-tools ~= 1.48.0
109+
protobuf ~= 3.19.0
110+
mypy-protobuf
111+
allowlist_externals = sed
112+
commands =
113+
python -m grpc_tools.protoc \
114+
-I sambacc/grpc/protobufs \
115+
--python_out=sambacc/grpc/generated \
116+
--grpc_python_out=sambacc/grpc/generated \
117+
--mypy_out=sambacc/grpc/generated \
118+
sambacc/grpc/protobufs/control.proto
119+
sed -i -E 's/^import.*_pb2/from . \0/' \
120+
sambacc/grpc/generated/control_pb2_grpc.py
121+
122+
# Generate grpc/protobuf code from .proto files using system packages.
123+
# Does NOT include a generator for .pyi files.
124+
# Uses sed to fix the foolish import behavior of the grpc generator.
125+
[testenv:grpc-sys-generate]
126+
description = Generate gRPC files using system python packages
127+
sitepackages = True
128+
allowlist_externals = sed
129+
commands =
130+
python -m grpc_tools.protoc \
131+
-I sambacc/grpc/protobufs \
132+
--python_out=sambacc/grpc/generated \
133+
--grpc_python_out=sambacc/grpc/generated \
134+
sambacc/grpc/protobufs/control.proto
135+
sed -i -E 's/^import.*_pb2/from . \0/' \
136+
sambacc/grpc/generated/control_pb2_grpc.py

0 commit comments

Comments
 (0)