[yocto] How to add a module to python-native

Burton, Ross ross.burton at intel.com
Tue Mar 27 02:11:03 PDT 2018


Please remember to send to the list.

On 26 March 2018 at 22:16, Ulf Samuelsson <yocto at emagii.com> wrote:
> I do not see however why "inherit pythonnative" would make python-restkit
> importable. Why is that?
>
> My python script start with
> #!/usr/bin/python
>
> Does that mean that I use host python, instead of native python?
> $bindir_native is "/usr/bin", so what is the difference?

python-restkit-native installs the modules into
/whatever/your/tmp/dir/is/sysroot/usr/lib/python/site-packages/restkit.
The host Python doesn't know to look in there, and if the module was
built from C sources the chances are the ABI doesn't match anyway.
You need to run the nativepython in the sysroot which 1) matches API
2) knows to look in the sysroot for modules.

This is why 1) you need to either inherit pythonnative (in a recipe)
or 2) run the right Python explicitly.  *Any* python code using
/usr/bin/python explicitly is broken, the best practise everywhere
(not just in Yocto) is to use #! /usr/bin/env python as you can't
assume the one in /usr/bin is the right one.

Ross



More information about the yocto mailing list