[yocto] Yocto Python Issue

Darcy Watkins darcy.watkins at inmotiontechnology.com
Thu Mar 6 15:42:16 PST 2014


Hi,

This is followup to...

https://lists.yoctoproject.org/pipermail/yocto/2014-February/018209.html

...for others dealing with 'cross-python' like issues.

This is the python equivalent to cross compiling.  I found a number of
resources related to python cross-compiling and even a pycon talk where
the presenter covers the hurdles involved to get distutil to “cross”
build as well.

http://stackoverflow.com/questions/19120938/cross-compiling-python-2-7-4
http://www.droboports.com/app-repository/python-2-7-5
http://www.youtube.com/watch?v=nhr-YErfW8k
http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html

Fortunately the Yocto/OpenEmbedded folk have these sorted out - you just
have to look in the right place.

My resolution was to ensure that the correct native python is used.
There is the host's native python that is used to run the tools of the
build system (including 'bitbake' itself).

Then there is a python-native that gets symlinked as 'nativepython' into
the native sysroot.  This 'nativepython' is setup sort of as a
crosscompiler python if you want to compile .py to .pyo/.pyc and put the
compiled files on your target.

Finally, there is the python that runs on the target system.

---

My headache was due to using the host's native python (actually ADT
bundled python on CentOS) when I needed to use 'nativepython'.  With a
small amount of shoehorn work, I was readily able to get make rules and
recipes to swig wrap some libraries as python extensions and to build
using nativepython.

There are a couple of variables you have to ensure get passed/exported
through your make to be available to 'nativepython' to point it to the
right sysroot locations of your target.

BUILD_SYS=${BUILD_SYS}
HOST_SYS=${HOST_SYS}
STAGING_LIBDIR=${STAGING_LIBDIR}
STAGING_INCDIR=${STAGING_INCDIR}

If you are using swig-native, you also need to use "-I" to get your
target sysroot include directories to it as well.


-- 

Regards,

Darcy

---

Darcy Watkins
Senior Software Developer
In Motion Technology, Inc.
350-625 Agnes St. New Westminster, BC
Canada, V3M 5Y4
[P1]




More information about the yocto mailing list