How to add a python module into SDK for both Aarch64 & X86_64

Hello,

I am developing an Yocto Linux OpenEmbedded application by using Apalis.

I am facing an issue for build SDK. (software development kit)

I want to include “grpcio-tools” python module into my SDK, so I added this in my recipe.

[upload|+pAH3A2Md9vcKVvaw1z+IFxZD40=]

The SDK is bitbake successfully.

Below are my findings:

After SDK is installed, and there are two folders, “aarch64-tdx-linux” , “x86_64-tdxsdk-linux”
[upload|xvI+2RhyX6AXMwh0em9o7ssTXMw=]

I realized that the grpc_tools only installed in aarch64-tdx-linux/usr/lib/python3.8/site-packages

[upload|YmQ12lDfYdVx6h7eFNTOl5zWUHU=]

And it doesn’t install in x86_64-tdx-linux/usr/lib/python3.8/site-packages

[upload|Bz6g0n5dUZVRFlcTaQSzQBWUBJs=]

And it cause a problem, “ModuleNotFoundError” when I try to execute it in my SDK.
[upload|pOdBkgm+rcZ+cvteuvV0S+9VLGs=]

Question :

What should I do in recipe to make it installed inside both folders ?

“aarch64-tdx-linux” , “x86_64-tdxsdk-linux”

My application is Aarch64. So my recipe is set to Aarch64.
Now I use same recipe to build image and SDK.

For SDK, I am running on x86_64 Ubuntu machine.

Hi @tanchunhau , you can also add TOOLCHAIN_TARGET_TASK_append = " python3-grpcio-tools" to local.conf.

HI @benjamin.tx

after added TOOLCHAIN_TARGET_TASK_append = " python3-grpcio-tools".

and in my another .bb file,
I want to invoke it:

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

And the module is not found in my OE-Build environment.

Do you know how to invoke the grpc_tools.protoc module for my do_compile ?

Hi @tanchunhau , it seems to me that gRPC is not installed on your PC. Do you install it according to this page?

Hi @benjamin.tx ,
I din’t install it in my pc, I am trying to make it exists in my OE-Build toolchain (so it is independent from my PC), do I need to install it in my PC ?

Hi @tanchunhau , then you may try to add HOSTTOOLS += ' python3-grpcio-tools' to local.conf.

hi @benjamin.tx , it show me this message after bitbake:

ERROR : The follwoing required tools (as speficied by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:
python3-grpcio-tools

I will try to debug later, thank you very much

Hi @tanchunhau , I just modify HOSTTOOLS` and get the same error. You can try to install grpcio-tools directly on your PC.

Hi @benjamin.tx

I added

inherit python3native

DEPENDS += " python3-grpcio-tools-native"

and it works !

@tanchunhau . Thanks for your sharing.