Search code examples
grpcyoctobitbakerecipe

How to invoke a python module in Yocto bitbake recipe?


I am working on a linux open-embedded project (Yocto), and I need to use gRPC.

Below are my recipes that try to invoke the gRPC python module. (grpcio-tools)

In local.conf

TOOLCHAIN_HOST_TASK_append = " nativesdk-python3-grpcio-tools"
TOOLCHAIN_TARGET_TASK_append = " python3-grpcio-tools"

Then is my .bb file, I try to add it as Depends.

 DEPENDS += " python3-grpcio-tools"
 do_compile(){
   python3 -m grpc_tools.protoc -I ${S} --python_out=. --grpc_python_out=. ${S}/tests/rcu_ser.proto
 }

But it fails to find the python module during bitbake. Below is the failure code: enter image description here

Please teach me how to invoke the python module during bitbake. Thank you very much.


Solution

  • If you want to use dependency on the host during compile time you must always depend to native version of a recipe. Modify your recipe as following:

    inherit python3native    
    DEPENDS += "python3-grpcio-tools-native"
    RDEPENDS_${PN} += "python3 python3-grpcio-tools"