Skip to content

Commit 0ff89b0

Browse files
committed
pybind/mgr: Protobuffer file generation for grpc deps.
Fixes: https://tracker.ceph.com/issues/64681 Signed-off-by: Paulo E. Castro <[email protected]>
1 parent b7376b2 commit 0ff89b0

File tree

5 files changed

+34
-4842
lines changed

5 files changed

+34
-4842
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,7 @@ src/pybind/rbd/rbd.egg-info/
9797
src/pybind/rgw/build/
9898
src/pybind/rgw/rgw.c
9999
src/pybind/rgw/rgw.egg-info/
100+
101+
# GRPC protobuff file generation #PR 61089
102+
src/pybind/mgr/dashboard/services/proto/gateway_pb2.py
103+
src/pybind/mgr/dashboard/services/proto/gateway_pb2_grpc.py

src/pybind/mgr/dashboard/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,34 @@ if(WITH_MGR_DASHBOARD_FRONTEND)
1414
add_tox_test(mgr-dashboard-check TOX_ENVS check)
1515
add_tox_test(mgr-dashboard-openapi TOX_ENVS openapi-check)
1616
endif()
17+
18+
# Required for building the dashboard grpc protos at build time
19+
set(CEPH_GRPC_VIRTUALENV ${CEPH_BUILD_VIRTUALENV}/ceph-grpc-virtualenv)
20+
21+
add_custom_command(
22+
OUTPUT ${CEPH_GRPC_VIRTUALENV}/lib/python*/site-packages/grpc_tools
23+
COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python=${Python3_EXECUTABLE} ${CEPH_GRPC_VIRTUALENV}
24+
COMMAND ${CEPH_GRPC_VIRTUALENV}/bin/pip install grpcio-tools
25+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
26+
COMMENT "grpcio-tools is being installed")
27+
28+
# protobuffer files generation
29+
add_custom_command(
30+
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2.py" "${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2_grpc.py"
31+
COMMAND . ${CEPH_GRPC_VIRTUALENV}/bin/activate && ${CEPH_GRPC_VIRTUALENV}/bin/python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. dashboard/services/proto/gateway.proto && deactivate
32+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..
33+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway.proto ${CEPH_GRPC_VIRTUALENV}/lib/python*/site-packages/grpc_tools
34+
COMMENT "proto generation for grpc deps")
35+
add_custom_target(mgr-dashboard-services-deps
36+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2.py ${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2_grpc.py
37+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
38+
39+
add_custom_target(mgr-dashboard-services-build
40+
ALL
41+
DEPENDS mgr-dashboard-services-deps)
42+
43+
add_dependencies(tests mgr-dashboard-services-build)
44+
1745
else()
1846
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/frontend/dist)
1947
# prebuilt

src/pybind/mgr/dashboard/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ pyyaml
1111
natsort
1212
setuptools
1313
jsonpatch
14-
grpcio==1.46.5
15-
grpcio-tools==1.46.5
14+
grpcio
15+
grpcio-tools

0 commit comments

Comments
 (0)