cpcloud / protoletariat

Protocol Buffers for the rest of us
Apache License 2.0
162 stars 8 forks source link

Usage with protobuf 5.* #1032

Closed heggi closed 1 week ago

heggi commented 5 months ago

Hello!

This library requires protobuf<5. Are there any known issues using it with protobuf 5.*?

Jazzinghen commented 3 months ago

I was trying to run the tests of the project but they expect protoc to be in the PATH. And even then all the tests fail with

/usr/lib/python3.12/subprocess.py:413: CalledProcessError

None: program not found or is not executable

Are the tests expecting some specific environment variables to be set?

BaxHugh commented 3 months ago

Yes, I get this same subprocess problem too, I didn't try to solve it, but I also have the same problem on main branch.

pdonorio commented 2 months ago

This would be helpful indeed 🙏 any option to upgrade support to latest?

ericbuehl commented 2 months ago

there's a PR open here https://github.com/cpcloud/protoletariat/pull/1033

technusm1 commented 2 months ago

I faced similar issues as @Jazzinghen, and I solved this issue by creating a protoc wrapper script in my makefile:

VENV_PATH := .venv
PROTOC_WRAPPER := $(VENV_PATH)/bin/protoc

.PHONY: all dep build clean test coverage coverhtml lint protoc

# Step to create the protoc script
create_protoc_script:
    @echo '#!/bin/sh' > protoc && \
    echo 'python -m grpc_tools.protoc "$$@"' >> protoc && \
    chmod +x protoc && \
    mkdir -p $(VENV_PATH)/bin && \
    cp protoc $(PROTOC_WRAPPER)

# Clean up the script after copying (optional)
clean_protoc_script:
    @rm -f protoc

protoletariat expects protoc to be in the PATH, so this approach works for a virtualenv. In other cases, installing protoc via system package managers can also work. brew install protobuf seems to resolve this on macOS for me.

Jazzinghen commented 2 months ago

@technusm1 that sounds cool. I'll try to do something like this to run the tests.

brew install protobuf seems to resolve this on macOS for me.

Sadly on Linux the protobuf/protoc packets are pretty outdated, so there needs to be a way to handle this test without protoc in the system path

cpcloud commented 1 week ago

Closed by #1035