Skip to content

Commit

Permalink
Make python grpc-bindings module aware
Browse files Browse the repository at this point in the history
We are generating/compiling python bindings from `.proto`-files.

Before this commit the generated protobuf-files did not understand they
were a part of the `glclient`-module.

This resulted in broken impors which se fixed using `sed` in our
Makefile.

This commit improves the configuration and voids the need for hacks in
our `Makefile`.

For more info: See protocolbuffers/protobuf#4176
  • Loading branch information
ErikDeSmedt committed Feb 28, 2024
1 parent 937d038 commit 9a8b274
Show file tree
Hide file tree
Showing 10 changed files with 355 additions and 360 deletions.
19 changes: 7 additions & 12 deletions libs/gl-client-py/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ PROTODIR=${REPO}/libs/proto

PYPROTOC_OPTS = \
-I ${PROTODIR} \
--python_out=${PYDIR}/glclient \
--grpc_python_out=${PYDIR}/glclient \
--mypy_out=${PYDIR}/glclient \
--python_out=${PYDIR} \
--grpc_python_out=${PYDIR} \
--mypy_out=${PYDIR} \
--experimental_allow_proto3_optional

PYPROTOS = \
Expand All @@ -24,19 +24,14 @@ PYPROTOS = \
${PYDIR}/glclient/scheduler_pb2_grpc.py

PROTOSRC = \
${PROTODIR}/scheduler.proto \
${PROTODIR}/greenlight.proto \
${PROTODIR}/node.proto
${PROTODIR}/glclient/scheduler.proto \
${PROTODIR}/glclient/greenlight.proto \

GENALL += ${PYPROTOS}

pygrpc: ${PROTOSRC}
python -m grpc_tools.protoc ${PYPROTOC_OPTS} scheduler.proto
python -m grpc_tools.protoc ${PYPROTOC_OPTS} greenlight.proto
sed -i 's/import scheduler_pb2 as scheduler__pb2/from . import scheduler_pb2 as scheduler__pb2/g' ${PYDIR}/glclient/scheduler_pb2_grpc.py
sed -i 's/import greenlight_pb2 as greenlight__pb2/from . import greenlight_pb2 as greenlight__pb2/g' ${PYDIR}/glclient/scheduler_pb2_grpc.py
sed -i 's/import greenlight_pb2 as greenlight__pb2/from . import greenlight_pb2 as greenlight__pb2/g' ${PYDIR}/glclient/scheduler_pb2.py
sed -i 's/import greenlight_pb2 as greenlight__pb2/from . import greenlight_pb2 as greenlight__pb2/g' ${PYDIR}/glclient/greenlight_pb2_grpc.py
python -m grpc_tools.protoc ${PYPROTOC_OPTS} glclient/scheduler.proto
python -m grpc_tools.protoc ${PYPROTOC_OPTS} glclient/greenlight.proto

check-py:
cd ${PYDIR}; mypy glclient
Expand Down
296 changes: 148 additions & 148 deletions libs/gl-client-py/glclient/greenlight_pb2.py

Large diffs are not rendered by default.

98 changes: 49 additions & 49 deletions libs/gl-client-py/glclient/greenlight_pb2_grpc.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9a8b274

Please sign in to comment.