【问题标题】:How do I build WHL packages after changing the code?更改代码后如何构建 WHL 包?
【发布时间】:2022-01-13 03:06:50
【问题描述】:

我在 grpc/third_party/protobuf/src/google/protobuf 代码中添加了一些日志代码,为了帮助定位问题,我从源代码安装了 grpc python,但是更改没有生效。请给我一些建议,谢谢。

支持的 Python 版本

Python 3.7.9

什么操作系统(Linux、Windows...)和版本?

Ubuntu 18.04.5 LTS

你做了什么?

我在 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

我修改了 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)

然后我运行:

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

我很困惑,为什么对 Protobuf 的更改不起作用?可能是我的安装方法有问题,请给我一些建议,谢谢。

【问题讨论】:

    标签: python grpc grpc-python


    【解决方案1】:

    回复于the grpc-io thread

    grpcio 包实际上并不依赖于 protobuf。只有生成的代码(即 _pb2.py 和 _pb2_grpc.py)具有这种依赖关系。相反,您需要从 protobuf 存储库构建 protobuf 轮并将其与现成的 grpcio 轮一起使用。

    另外,要回答明显的后续问题:“为什么我们的存储库中有一个供应商的 protobuf 目录呢?”。 grpcio-tools 轮确实内置了 libprotobuf 本机代码以生成上述 _pb2.py 和 _pb2_grpc.py 文件。

    【讨论】:

      猜你喜欢
      • 2020-03-31
      • 1970-01-01
      • 2021-01-23
      • 2017-03-04
      • 1970-01-01
      • 2018-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多