Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CMake build to generate Python protobuf bindings #7

Merged
merged 2 commits into from Jan 11, 2022

Conversation

srmainwaring
Copy link
Owner

This PR adds a step to compile the ign-msgs protobufs for Python.

The CMake rule for generating the Python bindings is adapted from https://github.com/ignitionrobotics/ign-msgs/blob/main/src/CMakeLists.txt. An option is added to call protoc --python_out and custom targets are introduced to ensure the custom command is called.

The Python bindings are output to the build directory ${PROJECT_BINARY_DIR}/python/ignition/msgs/<type>_pb2.py

To use them include ${PROJECT_BINARY_DIR}/python in the PYTHONPATH

export PYTHONPATH=$PYTHONPATH:${PROJECT_BINARY_DIR}/python

The bindings may then be imported in Python as:

from ignition/msgs/<type>_pb2 import <Type>

- Initial version

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
- Modify the protobuf generation from ign-mgs
- Add a section for Python
- Add custom targets to force the custom commands to run
- Remove unused CMakeLists

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
@srmainwaring srmainwaring merged commit 2cf2851 into main Jan 11, 2022
@srmainwaring
Copy link
Owner Author

Closes #5

@srmainwaring srmainwaring linked an issue Jan 11, 2022 that may be closed by this pull request
@srmainwaring srmainwaring deleted the pr/cmake-proto branch March 24, 2022 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CMake build to generate Python bindings for ign-msgs
1 participant