Python Build grpcio From Source (with OpenSSL)

Nov 21, 2020

By default (at least since v1.33.2), grpc is build with boringssl.

Perform the following to compile grpc with OpenSSL instead.

export REPO_ROOT=grpgit clone -b v1.33.2 https://github.com/grpc/grpc $REPO_ROOTcd $REPO_ROOTgit submodule update --initpip install -rrequirements.txtGRPC_PYTHON_BUILD_WITH_CYTHON=1 GRPC_BUILD_WITH_BORING_SSL_ASM=0 pip install .

The following doesn't work

GRPC_PYTHON_BUILD_WITH_CYTHON=1 GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_BUILD_WITH_BORING_SSL_ASM=0 pip install .
GRPC_PYTHON_BUILD_WITH_CYTHON=1 GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 pip install .

due to

/usr/bin/ld: python_build/temp.linux-x86_64-3.8/third_party/boringssl-with-bazel/linux-x86_64/crypto/chacha/chacha-x86_64.o: in function `ChaCha20_ctr32':
  /tmp/pip-req-build-i1hyvo8u/third_party/boringssl-with-bazel/linux-x86_64/crypto/chacha/chacha-x86_64.S:56: undefined reference to `OPENSSL_ia32cap_P'
  /usr/bin/ld: python_build/temp.linux-x86_64-3.8/third_party/boringssl-with-bazel/linux-x86_64/crypto/chacha/chacha-x86_64.o: relocation R_X86_64_PC32 against undefined hidden symbol `OPENSSL_ia32cap_P' can not be used when making a shared object
  /usr/bin/ld: final link failed: bad value

If you bump into gcc: fatal error: Killed signal terminated program cc1plus, it is probably due to out of memory.

References:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.