Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc > 3.19 support #2

Closed
caniko opened this issue Jan 30, 2023 · 4 comments · Fixed by #8
Closed

protoc > 3.19 support #2

caniko opened this issue Jan 30, 2023 · 4 comments · Fixed by #8

Comments

@caniko
Copy link

caniko commented Jan 30, 2023

Is your feature request related to a problem? Please describe.
I got an error when using the plugin, I was on latest protoc at the time:

TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

Describe the solution you'd like
protoc > 3.19 support

Describe alternatives you've considered
Downgrade.

@so1n
Copy link
Owner

so1n commented Feb 1, 2023

Is your feature request related to a problem? Please describe. I got an error when using the plugin, I was on latest protoc at the time:

TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

Describe the solution you'd like protoc > 3.19 support

Describe alternatives you've considered Downgrade.

Is the error caused by protoc or by some other circumstances? Please attach details(For example, the command to execute protoc and the protobuf file, or code)

@pppwaw
Copy link

pppwaw commented Mar 30, 2023

Is your feature request related to a problem? Please describe. I got an error when using the plugin, I was on latest protoc at the time:

TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

Describe the solution you'd like protoc > 3.19 support
Describe alternatives you've considered Downgrade.

Is the error caused by protoc or by some other circumstances? Please attach details(For example, the command to execute protoc and the protobuf file, or code)

Traceback (most recent call last):
File "/usr/local/bin/protoc-gen-protobuf-to-pydantic", line 5, in
from protobuf_to_pydantic.plugin.main import main
File "/usr/local/lib/python3.9/dist-packages/protobuf_to_pydantic/plugin/main.py", line 19, in
from protobuf_to_pydantic.protos import p2p_validate_pb2 # isort:skip
File "/usr/local/lib/python3.9/dist-packages/protobuf_to_pydantic/protos/p2p_validate_pb2.py", line 31, in
ignored = _descriptor.FieldDescriptor(
File "/usr/local/lib/python3.9/dist-packages/google/protobuf/descriptor.py", line 560, in new
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:

  1. Downgrade the protobuf package to 3.20.x or lower.
  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
--protobuf-to-pydantic_out: protoc-gen-protobuf-to-pydantic: Plugin failed with status code 1.

seems like that you need to generate protos in protobuf_to_pydantic/protobuf_to_pydantic/protos/ ?

@so1n
Copy link
Owner

so1n commented Mar 30, 2023

protobuf_to_pydantic/protobuf_to_pydantic/protos/

Thanks for your feedback, I realized it was a problem with different protobuf versions reading files protobuf_to_pydantic/protobuf_to_pydantic/protos/

@so1n so1n closed this as completed Mar 30, 2023
@so1n so1n reopened this Mar 30, 2023
@so1n so1n closed this as completed in #8 Mar 30, 2023
@so1n
Copy link
Owner

so1n commented Mar 30, 2023

This issue has been fixed and merged into Master, and will be merged into version 0.1.7 later @pppwaw @caniko

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants