Convert protobuf specification to MeTTa.
- python (tested with Python 3.9.2)
- grpcio-tools (tested with 1.19.0)
- wheel (tested with 0.42.0)
To build the library enter the following command
python setup.py bdist_wheel
To build the library enter the following command
pip install dist/protobuf_metta-0.1.0-py3-none-any.whl
Optionally, you may run the tests by entering the following command
python setup.py pytest
This library works in tandem with protoc
.
First, the protobuf specification must be compiled to Python via
protoc
, using a command such as
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. example.proto
Second, the resulting Python protobuf files, such as
example_pb2_grpc.py
example_pb2.py
can be imported alongside protobuf-metta to be parsed and converted to MeTTa, such as
import example_pb2
from protobuf_metta import parser
proto_parser = parser.ProtobufParser(example_pb2.DESCRIPTOR)
metta_desc = proto_parser.description_to_metta()
print(metta_desc)
A complete example can be found under the examples
folder.
TODO
- Support outputting MeTTa code as Python data structure, as opposed to just a string in MeTTa format.
- Upgrade installation procedure, using pip instead of setuptools directly. See the following tutorial https://spike.sh/blog/how-to-create-a-pip-package-for-python/.