Python bindings for `ign-msgs` and `ign-transport`

Overview

Python Ignition

This project aims to provide Python bindings for ignition-msgs and ignition-transport. It is a work in progress...

C++ and Python libraries for ignition-msgs are generated using Protobuf and gRPC rules for Bazel.

The objective is to generate Python bindings for ignition-transport using pybind11. Interoperability between native Python protobuf libraries and the C++ protobuf library used in the pybind11 extension module is provided by pybind11_protobuf.

Status

  • Working bindings for a selection of ignition-msgs are available using the protocol buffers native Python implementation. The build rules for the C++ implementation are also available however there is an open issue in pybind11_protobuf that prevents full interoperability in this case (see Notes below).
  • Bindings for ignition-transport are in development. A mock-up of the main interfaces is provided that illustrates the proposed approach.

Install: macOS

Install Bazel and the Google protocol buffers compiler using brew:

$ brew install bazel protobuf

Check the installed versions (protobuf must be version 3.19):

$ protoc --version
libprotoc 3.19.1

$ bazel --version
bazel 4.2.2-homebrew

Build everything

$ bazel build //...

Usage

The Bazel build file ign-msgs8=9.BUILD defines targets for a selection of messages. For example the targets for proto/ignition/msgs/time.proto are:

# proto_library
@ign-msgs9//:time_proto

# cpp_proto_library
@ign-msgs9//:time_cc_proto

# python_proto_library
@ign-msgs9//:time_py_pb2

C++

To use the bindings in C++:

// main.cc
#include "ignition/msgs/time.pb.h"
#include <iostream>

int main(int argc, const char* argv[])
{
  ignition::msgs::Time msg;
  msg.set_sec(11);
  msg.set_nsec(25);
  std::cout << msg.DebugString();
  
  return 0;
}
# BUILD.bazel
cc_binary(
  name = "main",
  srcs = ["main.cc"],
  deps = [
      "@ign-msgs9//:time_cc_proto",
  ],
)

Python

To use the bindings in Python:

# example.py
from ignition.msgs.time_pb2 import Time

msg = Time()
msg.sec = 15
msg.nsec = 21
print(msg)
# BUILD.bazel

py_binary(
  name = "example",
  srcs = ["example.py"],
  data = [
    "@com_google_protobuf//:proto_api",
  ],
  deps = [
    "@ign-msgs9//:time_py_pb2",
  ],
)

Examples

There are C++ and Python examples:

  • src/main.cc an example using the C++ protobuf library.
  • python/ign_proto_example an example using the Python protobuf library.
  • python/ign_msgs_example an example using the Python protobuf library and a simple extenson module with functions that accept and return ignition-msgs.
  • python/ign_transport_example an example using the Python protobuf library and an extenson module with a mock-up of the ignition.transport::Node interface.

Notes and Issues

protoc version

This version uses protoc version 3.19.1. You must ensure that the version of protoc installed by brew matches (otherwise the examples will segfault).

$ protoc --version
libprotoc 3.19.1

Protobuf generated Python libraries

There are some issues when using the C++ implementation of the generated Python protobuf library. The brew installation of protobuf will default to use the C++ implementation, to enable the Python implementation set the environment variable

export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python

before building the project.

Owner
Rhys Mainwaring
Rhys Mainwaring
End-to-End text sumarization, QAs generation using flask.

Help-Me-Read A web application created with Flask + BootStrap + HuggingFace 🤗 to generate summary and question-answer from given input text. It uses

Ankush Kuwar 12 Nov 13, 2022
Tucan Discord Token Generator - Remastered

TucanGEN-SRC Tucan Discord Token Generator - Remastered Tucan source made better by me. -- idk if it works anymore Includes: hCaptcha Bypass Automatic

Vast 8 Nov 04, 2022
Simple dotfile pre-processor with a per-file configuration

ix (eeks) Simple dotfile pre-processor with a per-file configuration Summary (TL;DR) ix.py is all you need config is an ini file. files to be processe

Poly 12 Dec 16, 2021
A country information finder module

A country information finder module

Fayas Noushad 3 Nov 28, 2021
A place where the most basic, basic of python coding exists

python-basics A place where the most basic, basic of python coding exists As you can see, there are four folders and the best order to read is: appeti

Chuqin 2 Oct 05, 2022
An Airdrop alternative for cross-platform users only for desktop with Python

PyDrop An Airdrop alternative for cross-platform users only for desktop with Python, -version 1.0 with less effort, just as a practice. ##############

Bernardo Olisan 6 Mar 25, 2022
Zeus is an open source flight intellingence tool which supports more than 13,000+ airlines and 250+ countries.

Zeus Zeus is an open source flight intellingence tool which supports more than 13,000+ airlines and 250+ countries. Any flight worldwide, at your fing

DeVickey 1 Oct 22, 2021
A continuation Of Project Glow By @glowstik-yt

Project Glow Greetings, I see you have stumbled upon project glow. Project glow is an open source bot worked on by many people to create a good and sa

1 Nov 17, 2021
Decentralized intelligent voting application.

DiVA Decentralized intelligent voting application. Hack the North 2021. Inspiration Following the previous US election, many voters were fearful that

Ali Shariatmadari 4 Jun 05, 2022
RELATE is an Environment for Learning And TEaching

RELATE Relate is an Environment for Learning And TEaching RELATE is a web-based courseware package. It is set apart by the following features: Focus o

Andreas Klöckner 311 Dec 25, 2022
emoji-math computes the given python expression and returns either the value or the nearest 5 emojis as measured by cosine similarity.

emoji-math computes the given python expression and returns either the value or the nearest 5 emojis as measured by cosine similarity.

Andrew White 13 Dec 11, 2022
BlueBorne Dockerized

BlueBorne Dockerized This is the repo to reproduce the BlueBorne kill-chain on Dockerized Android as described here, to fully understand the code you

SecSI 5 Sep 14, 2022
CaskDB is a disk-based, embedded, persistent, key-value store based on the Riak's bitcask paper, written in Python.

CaskDB - Disk based Log Structured Hash Table Store CaskDB is a disk-based, embedded, persistent, key-value store based on the Riak's bitcask paper, w

886 Dec 27, 2022
Basic cryptography done in Python for study purposes

criptografia Criptografia básica feita em Python para fins de estudo Converte letras em numeros partindo do indice 0 e vice-versa A criptografia é fei

Carlos Eduardo 2 Dec 05, 2021
A basic python project which replicates the functionalities on an 8 Ball.

Magic-8-Ball To the people who wish to make decisions using a Magic 8 Ball but can't get one? I gotchu. This is a basic python project which replicate

3 Jun 24, 2021
SiliconCompiler is an open source compiler framework that automates translation from source code to silicon.

SiliconCompiler is an open source compiler framework that aims to automate translation from source code to silicon.

siliconcompiler 539 Jan 04, 2023
A price calculator for multiple things

Price Calculator A price calculator for multiple things Example I have 0.0567kg diamond. The price of diamond in kg is: $4500. Then it says: The price

Abel 1 Nov 26, 2021
Keep your company's passwords behind the firewall

TeamVault TeamVault is an open-source web-based shared password manager for behind-the-firewall installation. It requires Python 3.3+ and Postgres (wi

//SEIBERT/MEDIA GmbH 38 Feb 20, 2022
Macros in Python: quasiquotes, case classes, LINQ and more!

MacroPy3 1.1.0b2 MacroPy is an implementation of Syntactic Macros in the Python Programming Language. MacroPy provides a mechanism for user-defined fu

Li Haoyi 3.2k Jan 06, 2023
Checks for Vaccine Availability at your district and notifies you using E-mail, subscribe to our website.

Vaccine Availability Notifier Project Description Checks for Vaccine Availability at your district and notifies you using E-mail every 10 mins. Kindly

Farhan Hai Khan 19 Jun 03, 2021