protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Missing instructions for building Python wheel with upb

Open ajasmin opened this issue 3 years ago • 3 comments

What version of protobuf and what language are you using? Version: 21.7 Language: Python OS: Linux

What did you do? I'm trying to build a wheel of protobuf 21.7 with support for PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=upb This is the same as the pre-compiled wheels available on PyPI.

The existing documentation only shows how to build with the legacy c++ implementation: https://github.com/protocolbuffers/protobuf/blob/main/python/README.md

I can produce the upb module with bazel build @upb//python:_message but python/setup.py doesn't seem to have a way to install or package it with the Python code.

ajasmin avatar Oct 04 '22 20:10 ajasmin

I think you want:

$ bazel build -c opt @upb//python/dist:binary_wheel

That will build a wheel for whatever Python you have installed on your system.

For release we cross-compile this for all the different verisons/OS's using bazel build --crosstool_top=//toolchain:clang_suite --host_crosstool_top=@bazel_tools//tools/cpp:toolchain -c opt @upb//python/dist, but that requires our Docker image that has all the cross-compilers installed.

haberman avatar Oct 05 '22 20:10 haberman

$ bazel build -c opt @upb//python/dist:binary_wheel

That works, Thank You! I must confess I have minimal knowledge of bazel.

It may be instructive to have the deployment scripts on github (Docker and all) if they're not already there.

Would that be somewhere under kokoro?

ajasmin avatar Oct 05 '22 21:10 ajasmin

Our docker files are not currently open sourceable in their current form, sadly. They contain some proprietary libraries we cannot release, yet.

perezd avatar Oct 05 '22 22:10 perezd

python/README still doesn't cover building a wheel that bundles the upb extension.

The bazel command above can be documented without having to share any proprietary code.

ajasmin avatar Feb 27 '23 23:02 ajasmin