[yocto] Crosscompiling python extensions with yocto generated toolchains!?

Daniel. danielhilst at gmail.com
Mon Jun 20 13:43:16 PDT 2016


My first doubt was how to trully cross-compile python extensions. Since I
can't find anything usefull on internet I ask my self: How OE does it? It
seems that OE uses an patched distutils to get bits build. This
"assumption" comes from what I see at distutils/sysconfig.py that lives at
build/tmp/sysroot/.. folder. After more digging I found this patch:
http://git.yoctoproject.org/cgit.cgi/poky/tree/meta/recipes-devtools/python/python-native/12-distutils-prefix-is-inside-staging-area.patch?h=daisy

The variables are aplied by this patch to the python-native (since I'm
still in Daisy, shame on me). At the top of the patch we see:

The proper prefix is inside our staging area.

So I'll try to contact these people to track the "proper fix". Since
crosscompiling python extensions is lacking of

documentation reading the source and talking to the gurus is the only
option avaible right now :) .


Regards,



2016-06-20 16:23 GMT-03:00 Khem Raj <raj.khem at gmail.com>:

> On Mon, Jun 20, 2016 at 12:08 PM, Daniel. <danielhilst at gmail.com> wrote:
> > I've found this recipe "python-pycurl" with exports libcurl to python.
> What
> > I did was build it and take a look at temp folder to stalk what line is
> used
> > to compile that stuff. Here it is:
> >
> > distutils_do_compile() {
> >
> >
> STAGING_INCDIR=/home/geckos/yocto/yocto-daisy/build_x11/tmp/sysroots/pharosserver-imx6/usr/include
> > \
> >
> >
> STAGING_LIBDIR=/home/geckos/yocto/yocto-daisy/build_x11/tmp/sysroots/pharosserver-imx6/usr/lib
> > \
> >          BUILD_SYS=x86_64-linux HOST_SYS=arm-poky-linux-gnueabi \
> >
> >
> /home/geckos/yocto/yocto-daisy/build_x11/tmp/sysroots/x86_64-linux/usr/bin/python-native/python
> > setup.py build  || \
> >          bbfatal "python setup.py build_ext execution failed."
> >
> > }
> >
> >
> > So I go to my extension's source folder and paste
> >
> STAGING_INCDIR=/home/geckos/yocto/yocto-daisy/build_x11/tmp/sysroots/pharosserver-imx6/usr/include
> > \
> >
> STAGING_LIBDIR=/home/geckos/yocto/yocto-daisy/build_x11/tmp/sysroots/pharosserver-imx6/usr/lib
> > \
> > BUILD_SYS=x86_64-linux HOST_SYS=arm-poky-linux-gnueabi \
> >
> /home/geckos/yocto/yocto-daisy/build_x11/tmp/sysroots/x86_64-linux/usr/bin/python-native/python
> > setup.py build
> >
> > and everything works fine, I got my extension compiled. So, in what magic
> > are these enviroment variables envolved? STAGING_INCDIR
> > and STAGING_LIBDIR are OE stuff, what are these BUILD_SYS and HOST_SYS
> > related?! I'm still searching, anyway thanks Khen for
> > pointing me meta-python sources. It helped me a lot.
>
>
> OE has several classes where common operations are abstracted out and
> you can see that in recipes
> e.g. inherit setuptools etc. you should copy the recipe which is
> closest to your package and modify it
> to use your package source etc. and make other needed tweaks.
>
> >
> > Regards,
> >
> >
> > 2016-06-20 15:29 GMT-03:00 Daniel. <danielhilst at gmail.com>:
> >>
> >> Thank you Khem!!
> >>
> >> Regards,
> >>
> >> 2016-06-20 15:02 GMT-03:00 Khem Raj <raj.khem at gmail.com>:
> >>>
> >>> On Mon, Jun 20, 2016 at 10:44 AM, Daniel. <danielhilst at gmail.com>
> wrote:
> >>> > Hi everybody..
> >>> >
> >>> > I've been playing with python extensions. Now I want to compile a
> >>> > simple
> >>> > hello world extension
> >>> > to my Yocto's target, but I really can't find any good resource about
> >>> > doing
> >>> > it. So what is the teory behind it?
> >>> >
> >>> > I know that I need python headers "Python.h and others" and that I
> need
> >>> > distutils installed. After that everything is done by distutils and
> >>> > setup.py
> >>> > script, but what is done is a mistery. I found distutilscross on
> >>> > internet
> >>> > but no documentation about it!?
> >>> >
> >>> > How are python extensions cross-compiled by Yocto? Can somebody point
> >>> > me an
> >>> > example?!
> >>>
> >>> take a look at meta-python.
> >>>
> >>> http://cgit.openembedded.org/meta-openembedded/tree/meta-python
> >>>
> >>> You might find some examples close to what you are looking for.
> >>>
> >>> >
> >>> > Regards,
> >>> >
> >>> > --
> >>> > "Do or do not. There is no try"
> >>> >   Yoda Master
> >>> >
> >>> > --
> >>> > _______________________________________________
> >>> > yocto mailing list
> >>> > yocto at yoctoproject.org
> >>> > https://lists.yoctoproject.org/listinfo/yocto
> >>> >
> >>
> >>
> >>
> >>
> >> --
> >> "Do or do not. There is no try"
> >>   Yoda Master
> >
> >
> >
> >
> > --
> > "Do or do not. There is no try"
> >   Yoda Master
>



-- 
*"Do or do not. There is no try"*
  *Yoda Master*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20160620/9e300a7e/attachment.html>


More information about the yocto mailing list