Skip to content

Conversation

@stefanvanburen
Copy link
Member

@stefanvanburen stefanvanburen commented Oct 7, 2025

We currently set a minimum version of the runtime protobuf package for protocolbuffers/python based on the documented "new gencode + old runtime = never allowed" rule that generally applies to the protocolbuffers plugins - that the runtime versions are free to add runtime APIs in any release and it's expected that the gencode must be updated to run with the new runtime version.

However, Python has a separate carve-out behavior for its gencode, documented now as:

Since the 3.20.0 release, the Protobuf Python generated code became a
thin wrapper around an embedded FileDescriptorProto. Because these
protos are supported on extremely long timeframes, our usual major
version compatibility windows aren’t typically necessary.

Python may break generated code compatibility in specific future major
version releases, but it will be coupled with poison pill warnings and
errors in advance. As of 6.32.0, all generated code since 3.20.0 will be
supported until at least 8.x.y.

This means that we don't need to pin the protocolbuffers/python version to the matching runtime version; we can loosen the minimum to 3.20.0 (and will need to reevaluate this in the future v8 major release).

This commit pins the latest minor release in each major version to a minimum of 3.20.

An alternative is to just specify protobuf without any version specifiers, and allow consumers to pick the version of protobuf they want to supply. But since the minimum is pretty clearly documented, I think supplying it is reasonable.


  • The first commit applies the above on the latest minor release of each major version of protocolbuffers/python (and protocolbuffers/pyi, which protocolbuffers/python depends on).
  • The second commit does the rest of the versions. We can revert this commit if we'd like, but I think it would be better to update all of these in one shot to avoid confusion.
  • The third commit is optional, but in the same vein: we currently set a fairly strict lower bound on the types-protobuf dependency of protocolbuffers/pyi, but we don't have any real guarantees about how those versions map to the runtime version. I think we ought to loosen them to just allow the user to figure out the version they want. Again, we can revert this, but I figure we ought to do this update in one-shot.

We currently set a minimum version of the runtime `protobuf` package for
protocolbuffers/python based on the documented ["new gencode + old
runtime = never allowed"][1] rule that generally applies to the
protocolbuffers plugins - that the runtime versions are free to add
runtime APIs in any release and it's expected that the gencode must be
updated to run with the new runtime version.

However, [Python has a separate carve-out behavior for it's gencode][2],
documented now as:

> Since the 3.20.0 release, the Protobuf Python generated code became a
> thin wrapper around an embedded FileDescriptorProto. Because these
> protos are supported on extremely long timeframes, our usual major
> version compatibility windows aren’t typically necessary.

> Python may break generated code compatibility in specific future major
> version releases, but it will be coupled with poison pill warnings and
> errors in advance. As of 6.32.0, all generated code since 3.20.0 will be
> supported until at least 8.x.y.

This means that we don't need to pin the protocolbuffers/python version
to the matching runtime version; we can loosen the minimum to `3.20.0`
(and will need to reevaluate this in the future v8 major release).

This commit pins the latest minor release in each major version to a
minimum of 3.20.

An alternative is to _just_ specify `protobuf` without any version
specifiers, and allow consumers to pick the version of `protobuf` they
want to supply. But since the minimum is pretty clearly documented, I
think supplying it is reasonable.

[1]: https://protobuf.dev/support/cross-version-runtime-guarantee/#backwards
[2]: https://protobuf.dev/support/cross-version-runtime-guarantee/#python
I think we ought to just do this in one-shot, but if this is too many
plugins we can revert this commit.
These types are maintained separately from the protobuf team in the
typeshed repo; they are incomplete and not always correct. We ought to
loosen our dependency so as to not conflict with a types-protobuf that a
consumer may want to use.
@mfridman
Copy link
Member

mfridman commented Oct 7, 2025

I don't think it's worth backporting this to all versions. We should pick the last ~3 and update those, and have it be the default moving forward. This is going to bump a lot of revisions, for potentially little gain.

@stefanvanburen stefanvanburen enabled auto-merge (squash) October 7, 2025 14:51
Copy link
Member

@pkwarren pkwarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may at some point just want to remove all version constraints and let downstream projects choose their versions (especially since version selection is so expensive).

Happy to start with this though.

@stefanvanburen stefanvanburen merged commit 55739b0 into main Oct 7, 2025
3 checks passed
@stefanvanburen stefanvanburen deleted the svanburen/backport-python-loosen-protobuf-dep branch October 7, 2025 14:53
@mfridman
Copy link
Member

mfridman commented Oct 7, 2025

I think we may at some point just want to remove all version constraints and let downstream projects choose their versions (especially since version selection is so expensive).

Happy to start with this though.

Agreed. Thanks for the updates @stefanvanburen 🎉

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 this pull request may close these issues.

4 participants