You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However the generated file mypackage.py is expecting a relative dir called google.protobuf which couldn’t be found, it has only the api.py not protobuf. from .google import protobuf
Expected Results
The imported packages are properly handled. In the normal protoc way of generation, google.protobuf is a package and is imported directly like this: from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
Actual Results
A relative import which doesn't exist: from .google import protobuf
I'm not able to use normal command line to generate this:
protoc -I . --python_betterproto_out=lib mypackage.proto
google/api/annotations.proto: File not found.
google/api/client.proto: File not found.
google/api/field_behavior.proto: File not found.
google/api/resource.proto: File not found.
protoc-gen-openapiv2/options/annotations.proto: File not found.
mypackage.proto:5:1: Import "google/api/annotations.proto" was not found or had errors.
mypackage.proto:6:1: Import "google/api/client.proto" was not found or had errors.
mypackage.proto:7:1: Import "google/api/field_behavior.proto" was not found or had errors.
mypackage.proto:9:1: Import "google/api/resource.proto" was not found or had errors.
mypackage.proto:13:1: Import "protoc-gen-openapiv2/options/annotations.proto" was not found or had errors.
Checklist
I have searched the issues for duplicates.
I have shown the entire traceback, if possible.
[] I have verified this issue occurs on the latest prelease of betterproto which can be installed using pip install -U --pre betterproto, if possible.
The text was updated successfully, but these errors were encountered:
Try generating against the latest commit of this repository, I read somewhere that the latest commit doesn't have this issue but I haven't had time yet to try this.
If it does solve the issue:
I do wonder what we can do to about pushing a new version to pip, to include those improvements without having to anchor my dependencies against a specific git hash.
Upon reviewing the output, I see the dependency referenced using from .depproto.package import v1 when depproto is in the parent directory and would only work if it was from ..depproto.package import v1.
I've confirmed that my poetry.lock shows:
[package.source]
type = "git"url = "https://github.com/danielgtaylor/python-betterproto.git"reference = "1f88b67"resolved_reference = "1f88b67eeb9871d33da154fd2c859b9d1aed62c1"
And the file protoc-gen-python_betterproto in my path was touched at the same timestamp as when I ran the poetry add command. I could not figure out how to get the binary to spit out its own version, but I'm pretty confident I'm using the latest SHA (at the time of this post).
Summary
from .google import protobuf which doesn't exist
Reproduction Steps
I’m facing an issue with the imported packages, my protofile has some import like this:
I’m running the code generation with buf:
and the command to run it is:
buf generate --template buf.gen.additional.yaml --include-imports
The generated files are like this:
tree mypackage/api/proto/_gen/pythonbproto2
However the generated file mypackage.py is expecting a relative dir called google.protobuf which couldn’t be found, it has only the api.py not protobuf.
from .google import protobuf
Expected Results
The imported packages are properly handled. In the normal protoc way of generation, google.protobuf is a package and is imported directly like this:
from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
Actual Results
A relative import which doesn't exist:
from .google import protobuf
System Information
protoc --version
libprotoc 24.3
buf --version
1.21.0
I'm not able to use normal command line to generate this:
Checklist
pip install -U --pre betterproto
, if possible.The text was updated successfully, but these errors were encountered: