danielgtaylor / python-betterproto

Clean, modern, Python 3.6+ code generator & library for Protobuf 3 and async gRPC
MIT License
1.5k stars 210 forks source link

Relative imports #470

Open morganics opened 1 year ago

morganics commented 1 year ago

Certainly I had the same issue with the original protoc compiler, but generated relative imports are complaining. I have a bunch of protos in the same directory.

I'm using the cmd line to generate the dataclasses:

python -m grpc_tools.protoc -I C:\dir\libroot --python_betterproto_out=src\libs C:\dir\libroot\Protos\myproto.proto

This generates the proto files in the expected location src\libs\packagename\myproto.py, with the following imports, which don't work:

from .packagename import common

However (in my use case) this needs to be:

from . import common

But perhaps I've got the wrong end of the stick!

Thanks.

a-khabarov commented 1 year ago

I also had this problem. Using the latest commit from the master branch of this repository instead of the version on PyPI appears to fix everything.