/buf-protos

Prototype/experiment of a protobuf wrapper for buf

Primary LanguagePython

buf-protos

Prototype/experiment of a protobuf wrapper for buf

File layout

The folder ./protos/ contains the protobuf files, initially taken from published java jar build.buf:protovalidate:0.1.8

The folder ./src/ contains the generated code, as well as a copy of .proto files next to the generated _pb2-s.

The python package bundles:

  • The _pb2.py files generated by protoc
  • The _pb2.pyi files generated by protoc (stub files for mypy)
  • The .proto files that were used

This is similar to how Google packages things, for example: googleapis-common-protos

Inspect package locally

To get a handy package locally for inspection, run:

  • Run ./package.sh
  • Check contents of dist/ folder: ls -l dist/
  • Check contents of wheel: unzip -t dist/buf_protos-*.whl

You should observe that the .proto files are included in the wheel, along the _pb2.* files:

    testing: buf/validate/expression.proto   OK
    testing: buf/validate/expression_pb2.py   OK
    testing: buf/validate/expression_pb2.pyi   OK
    testing: buf/validate/validate.proto   OK
    testing: buf/validate/validate_pb2.py   OK
    testing: buf/validate/validate_pb2.pyi   OK
    ...

Regenerating

In order to regenerate the _pb2 files, proceed as follows:

  • Update and commit files in protos/ folder
  • Bump version in setup.py
  • Run ./regenerate.sh, inspect git diff