Skip to content

Instantly share code, notes, and snippets.

@jednano
Last active January 27, 2024 04:36
Show Gist options
  • Save jednano/5d8d99a70fa839e2798a4980449a86f7 to your computer and use it in GitHub Desktop.
Save jednano/5d8d99a70fa839e2798a4980449a86f7 to your computer and use it in GitHub Desktop.
Protobuf types in Python
name: Python Test
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install dependencies
run: pip3 install -r requirements.txt
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "25.2"
- name: Compile Protobuf
run: ./compile_proto
- name: Run tests
run: ./test

Installation

Install the latest version of Protobuf using these instructions.

pip3 install -r requirements.txt
sudo chmod +x compile_proto
./compile_proto
#!/bin/bash
plugin=$(which protoc-gen-mypy)
compile_proto() {
protoc --experimental_allow_proto3_optional --plugin=protoc-gen-mypy=$plugin --python_out=. --mypy_out=. $@
}
compile_proto *.proto
compile_proto **/*.proto
mypy
mypy-protobuf
protobuf
pyzmq
types-protobuf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment