-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
Compatibility of generated Python code with protoc >= 3.19.0 #11123
Comments
Historically protobuf has been very bad about providing a crisp definition here. The good news is that I have something in progress that should define this more carefully and I will try to publish it in the next month or so (holidays may interfere) |
@fowles that's great to hear, looking forward to it. In the shorter term, could I get some clarity on if code generated with latest protoc version 3.21 is backward compatible with protobuf 3.x python API? I am aware of the API breaking changes, just wondering about the generated code. Based on some experiments, things seem to work fine. The context here is that many libraries authors would like to support both 3.x and 4.x for some time to avoid creating dependency conflicts for library users in their transitive dependencies. |
The code generated by 4.21.x happens to be backwards compatible with 3.20.x and (I think) 3.19.x. The eventual criteria we are aiming for will not guarantee that code generated from a newer compiler supports an older runtime. |
Anecdotally, protoc 3.19.4 works with |
I have to say I am truly puzzled. How is a Python project using protobuf supposed to cleanly manage its dependency? I would really appreciate any documentation, best practices, or at least sanctioned reference projects. Our thoughts were this:
What we came up with is to sort of hardcode a minor->major map in our
But this means hardcoding these major version jumps. Also when a major jump happens, let's say to 5.25.0 and we want to support the latest |
Protobuf has changed their versioning scheme to language-specific one. For Golang, the first version applied the scheme would be 4.21.0 which followed the preceding version,3.20.1. Basically the major part is language-specific and no longer important. Check more: https://protobuf.dev/news/2022-05-06/ protocolbuffers/protobuf#11440 protocolbuffers/protobuf#11123
Would it be possible to include the compiler version as a comment in the generated code?
While this won't help for "ancient" code, where the compatibility issues hurt the most, it could at least help future generations to put the puzzle pieces together. |
We have work under way to add explicit compatibility checks to our various codegen targets. |
Protobuf has changed their versioning scheme to language-specific one. For Golang, the first version applied the scheme would be 4.21.0 which followed the preceding version,3.20.1. Basically the major part is language-specific and no longer important. Check more: https://protobuf.dev/news/2022-05-06/ protocolbuffers/protobuf#11440 protocolbuffers/protobuf#11123
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
Has there been any progress here? |
Yes we're making progress to have "poison pills" that enforces https://protobuf.dev/support/cross-version-runtime-guarantee/ firstly in Java, C++ and Python.
I think we now have the version info for debugging in the comments like this since 25.x. We're going to have code to validate that compatible runtime version is linked. |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
Commenting for activity. This unsynced versioning system w/o an easy way to run protoc from python affects typeshed as well where we have to download protobuf & protoc from different sources and duplicate version requirements, where different stubs may have different proto requirements. Edit: as for running protoc from python, I just found that https://pypi.org/project/grpcio-tools/ is a thing. |
Slightly related, but is there any reason why apt-get only has an old version of protobuf? I'm a bit surprised the latest releases aren't released as apt packages too. https://tracker.debian.org/pkg/protobuf |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it. This issue was closed and archived because there has been no new activity in the 14 days since the |
Late comment for activity |
I have some questions regarding the compatibility guarantees of generated code with individual language APIs, specifically Python. According to https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates:
As everyone is aware from #10051
That makes sense going forward when trying to use upb with protobuf 4.x. Some questions:
I found #4945 referencing compatibility tests, but they were deleted in #8570. Apologies if this Is this documented somewhere and I missed it.
Additional context
open-telemetry/opentelemetry-python#2880 (comment)
The text was updated successfully, but these errors were encountered: