简体   繁体   English

更改代码后如何构建 WHL 包?

[英]How do I build WHL packages after changing the code?

I added some log codes in grpc/third_party/protobuf/src/google/protobuf code, to help locate the problem, i install grpc python from source, but The change did not take effect.我在 grpc/third_party/protobuf/src/google/protobuf 代码中添加了一些日志代码,为了帮助定位问题,我从源代码安装了 grpc python,但更改没有生效。 Please give me some advice, thanks.请给我一些建议,谢谢。

Supported Python Versions支持的 Python 版本

Python 3.7.9 Python 3.7.9

What operating system (Linux, Windows,...) and version?什么操作系统(Linux,Windows,...)和版本?

Ubuntu 18.04.5 LTS Ubuntu 18.04.5 LTS

What did you do?你做了什么?

I added some log codes in grpc/third_party/protobuf/src/google/protobuf code, then i compiled protobuf, compiled grpc and install grpc python from source我在 grpc/third_party/protobuf/src/google/protobuf 代码中添加了一些日志代码,然后我编译了 protobuf,编译了 grpc 并从源代码安装了 grpc python

mkdir -p "third_party/protobuf/cmake/build"
cd  "third_party/protobuf/cmake/build"
cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ..
make -j14 install
popd
make -j14

i modified setup.py, add this code:我修改了 setup.py,添加以下代码:

CORE_C_FILES = filter(lambda x: 'third_party/protobuf' not in x, CORE_C_FILES)
PROTOBUF_INCLUDE = (os.path.join('/usr', 'include', 'protobuf'),)
EXTENSION_INCLUDE_DIRECTORIES = ((PYTHON_STEM,) + CORE_INCLUDE + ABSL_INCLUDE +
                                 ADDRESS_SORTING_INCLUDE + CARES_INCLUDE +
                                 RE2_INCLUDE + PROTOBUF_INCLUDE + SSL_INCLUDE + UPB_INCLUDE +
                                 UPB_GRPC_GENERATED_INCLUDE +
                                 UPBDEFS_GRPC_GENERATED_INCLUDE +
                                 XXHASH_INCLUDE + ZLIB_INCLUDE)

then i run:然后我运行:

pip install -rrequirements.txt
GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .

I'm confused, why aren't the changes to Protobuf working?我很困惑,为什么对 Protobuf 的更改不起作用? Maybe there is something wrong with my installation method, please give me some suggestions,thanks.可能是我的安装方法有问题,请给我一些建议,谢谢。

Answered in the grpc-io thread :grpc-io 线程中回答:

The grpcio package doesn't actually depend on protobuf. grpcio package 实际上并不依赖于 protobuf。 Only generated code (ie _pb2.py and _pb2_grpc.py) have this dependency.只有生成的代码(即 _pb2.py 和 _pb2_grpc.py)有这种依赖关系。 Instead, you'll want to build the protobuf wheel from the protobuf repository and use that alongside an off-the-shelf grpcio wheel.相反,您需要从 protobuf 存储库构建 protobuf 轮并将其与现成的 grpcio 轮一起使用。

Also, to answer the obvious follow-up question: "Why do we have a vendored protobuf directory in our repo at all then?".另外,要回答明显的后续问题:“为什么我们的 repo 中有一个 vendored protobuf 目录呢?”。 The grpcio-tools wheel does build in the libprotobuf native code to generate the aforementioned _pb2.py and _pb2_grpc.py files. grpcio-tools 轮确实内置了 libprotobuf 本机代码以生成上述 _pb2.py 和 _pb2_grpc.py 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM