diff --git a/.gitignore b/.gitignore index 9dcfd38..ab8c0da 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ compile_commands.json **/*.swo **/*.swp .vscode/ +.venv +*.pyc diff --git a/CMakeLists.txt b/CMakeLists.txt index baeebfe..02c577a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,9 @@ add_library(mnode-proto proto/service.proto) target_link_libraries(mnode-proto PUBLIC protobuf::libprotobuf) target_include_directories(mnode-proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) protobuf_generate(TARGET mnode-proto) +#protobuf_generate(TARGET mnode-proto-py LANGUAGE python PROTOS proto/service.proto) +protobuf_generate_python(PROTO_PY proto/service.proto) +add_custom_target(mnode-proto-py ALL DEPENDS ${PROTO_PY}) add_subdirectory(external) add_subdirectory(src) diff --git a/python/main.py b/python/main.py new file mode 100644 index 0000000..12706b8 --- /dev/null +++ b/python/main.py @@ -0,0 +1,19 @@ +import sys, os +sys.path.append(os.path.join(os.path.dirname(sys.path[0]), 'build')) +import service_pb2 as pb + +from typing import Union + +from fastapi import FastAPI + +app = FastAPI() + + +@app.get("/") +def read_root(): + return dir(pb) + + +@app.get("/items/{item_id}") +def read_item(item_id: int, q: Union[str, None] = None): + return {"item_id": item_id, "q": q} diff --git a/python/requirements.txt b/python/requirements.txt new file mode 100644 index 0000000..d4e15d9 --- /dev/null +++ b/python/requirements.txt @@ -0,0 +1,2 @@ +protobuf +fastapi[standard] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 77235a2..7777ec0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,5 +63,8 @@ target_compile_options(mesy_nng_sub_consumer PRIVATE ${MVLC_NNG_NODE_WARN_FLAGS} add_executable(mnode-proto-test1 mnode_proto_test1.cc thread_name.cc) target_link_libraries(mnode-proto-test1 PRIVATE mnode-proto PRIVATE mesytec-mvlc PRIVATE nng) +#add_subdirectory(nng) +#add_subdirectory(qt) + #unset(CMAKE_C_CLANG_TIDY) #unset(CMAKE_CXX_CLANG_TIDY)