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

Link in UPB by default for Bazel's python build rules. #19836

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

Link in UPB by default for Bazel's python build rules.

In v21.x, we announced our intent to flip the default implementation of
protobuf python from pure python to upb.

We also documented in docs and readme that
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION env var can be set to override the
python implementation used.

In practice, we only use upb if it can successfully be imported:

Otherwise, we fall back to pure python, even if the env var is set to upb.
Since we don't currently link in upb for Bazel, this means the default is
still pure python in practice and the environment variable is not respected.

This change links in UPB by default and ensures that default python builds and
unit tests using Bazel will enable running with python-UPB.

#test-continuous

In v21.x, we announced our intent to flip the default implementation of
protobuf python from pure python to upb.
- https://github.com/protocolbuffers/protobuf/releases/tag/v21.0

We also documented in docs and readme that
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION env var can be set to override the
python implementation used.
- https://protobuf.dev/reference/python/python-generated/#sharing-messages

In practice, we only use upb if it can successfully be imported:
- https://github.com/protocolbuffers/protobuf/blob/1c29f34b24eafe4a362ce075c12c62c614fad199/python/google/protobuf/internal/api_implementation.py#L54
- https://github.com/protocolbuffers/protobuf/blob/1c29f34b24eafe4a362ce075c12c62c614fad199/python/google/protobuf/internal/api_implementation.py#L100

Otherwise, we fall back to pure python, even if the env var is set to upb.
Since we don't currently link in upb for Bazel, this means the default is
still pure python in practice and the environment variable is not respected.

This change links in UPB by default and ensures that default python builds and
unit tests using Bazel will enable running with python-UPB.

#test-continuous

PiperOrigin-RevId: 711436307
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.

1 participant