eclipse / tahu

Eclipse Tahu addresses the existence of legacy SCADA/DCS/ICS protocols and infrastructures and provides a much-needed definition of how best to apply MQTT into these existing industrial operational environments.

Home Page:https://eclipse.org/tahu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue while trying to compile sparkplug_b.proto into Python code

mkashwin opened this issue · comments

I was trying to compile the sparkplug_b.proto file to generate the required python files for my project.
The python file generated appears to be incomplete and not compiling. Would appreciate some guidance on what I might be going wrong here

Command Used:

protoc.exe  --python_out=./src/generated  - I ./sparkplug_b sparkplug_b.proto

Environment Details - Windows 10:

  protoc.exe  --version                                                     
  libprotoc 3.21.5
  
  python --version
  Python 3.10.5

Attached is the generated file:
sparkplug_b_pb2.py.txt

Quick update
I realized that the proto file is correctly being compiled by version Protocol Buffers v3.19.4

This issue has come up since v3.20.0
Recommend that the documentation is updated to reflect the dependency or the proto file structure is update to be compatible with the newer version of protobuf

The file that you generated looks the same as what I've generated with protoc 3.21.6, and it is functional for me. Is yours not working?

If you're wondering why it look so different from previous versions, see the following:
https://stackoverflow.com/questions/71960226/protocol-buffers-in-python-no-classes-generated
https://stackoverflow.com/questions/73932985/python-proto-is-not-generating-classes

Thanks
this now works. I needed to add the --pyi_out param
For anyone else who has this problem the complete command template

protoc -I <parent folder for sparkplug_b.proto > --python_out=<location for generated file> --pyi_out=<location for generated file> <location of sparkplug_b.proto>

protoc -I=../../sparkplug_b/ --pyi_out=. --python_out=. ../../sparkplug_b/sparkplug_b.proto 

readme.txt should be updated accordingly.
Will try to register as a contributor and create a pull request for this