py_proto_library rule not using prebuilt protoc
Maintainers usually reply within 1 day
@anandolee is already working on this.
Since Jun 16, 2026.
Assessment
This issue has not been assessed yet.
Description
What version of protobuf and what language are you using?
Version: 35.1
Language: Python
What supported operating system version are you using (e.g. Linux, Windows) ?
macOS 26.5.1
What supported runtime / compiler version are you using (e.g. python version, gcc version)
Bazel 9.1.0
rules_python 2.0.0
Python 3.13 toolchain from rules_python
What did you do?
I have what I think is a pretty vanilla Bazel/Python/Protobuf configuration, and I'm trying to use the recently-released support for prebuilt protobuf compiler binaries. It's not working - trying to build a py_proto_library rule results in the protobuf compiler being built from source.
To debug, I ran bazel cquery 'somepath("//my_project/proto:my_py_proto", "@protobuf//src/google/protobuf")' which gave me the following dependency chain:
//my_project/proto:my_py_proto
@protobuf//python:python_toolchain
@protobuf//python:protobuf_python
@protobuf//python:python_srcs
@protobuf//python:python_src_files
@protobuf//python:google/protobuf/internal/python_edition_defaults.py
@protobuf//python:embedded_python_edition_defaults_generate
@protobuf//editions:internal_defaults_escape
@protobuf//src/google/protobuf:protobuf
My uneducated guess at narrowing down the problem is that @protobuf//python:python_toolchain is mis-resolving such that it depends on @protobuf//python:protobuf_python, which in turn depends on python_edition_defaults.py, in turn generated from C++ stuff. I would expect the dependency chain to stop after python_toolchain. To the extent that Python sources are needed to compile my protos, I'd expect them to be part of the prebuilt compiler distribution, and to the extent they're needed at runtime I'd expect to get them from PyPI. But my convictions aren't very strong here, maybe I'm doing something obviously wrong?
For good measure I also tried
bazel build //my_project/proto:my_py_proto \
--'@protobuf//bazel/flags:prefer_prebuilt_protoc' \
--incompatible_enable_proto_toolchain_resolution
with the same result.
What did you expect to see
Prebuilt compiler used, compiler not built from source
What did you see instead?
Compiler built from source
Anything else we should know about your project / environment
I have some gross workarounds in my BUILD files to relocate the proto Python modules going into the wheel I'm trying to build, but all of that is downstream of the py_proto_library rule and I wouldn't expect it to affect the proto library's upstream dependencies.
- Dominant language
- C++
- Stars
- 72.2k
- Forks
- 16.4k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 342
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from protocolbuffers/protobuf
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
protocolbuffers/protobuf#31768 ·
Maintainers usually reply within 1 day
-
feature request packaging & distribution python
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
protocolbuffers/protobuf#31654 ·
Maintainers usually reply within 1 day
-
google-protobuf 0.36.2-release fails to compile for ARMv7: @progbits rejected in global_asm!Possibly taken @farisbasha claimed this 1 day ago. Openbug help wanted rust
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
protocolbuffers/protobuf#31619 · 3 comments ·
Maintainers usually reply within 1 day
-
Null pointer passed to memcpy in lupb_decode() when the second argument is nilPossibly taken A pull request linked to this issue is open or already merged. Openbug help wanted lua
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
protocolbuffers/protobuf#31392 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
protocolbuffers/protobuf#31032 ·
Maintainers usually reply within 1 day
All issues in protocolbuffers/protobuf
Similar issues
-
agent:Windows bug in progress pri:medium sev:low testing windows
Difficulty 1/5 Under an hour Newbie friendliness 91/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
godotengine/godot#125651 ·
Maintainers usually reply within 1 day
-
Android: with view recycling on, a recycled View keeps its nextFocusLeftPossibly taken A pull request linked to this issue is open or already merged. OpenNeeds: Triage :mag: Platform: Android
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
react/react-native#60167 ·
Maintainers usually reply within 2 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days