The above script can also be founded here: https://gist.github.com/gkos/2fa8dd54712d0b92a3db52e472d9fc09
Regards, 2016-06-22 11:57 GMT-03:00 Daniel. <[email protected]>: > Well, I've create a little script to create the needed variables used > by Yocto's python. > > Here it is: > > . $1 > export BUILD_SYS=$(echo $CONFIGURE_FLAGS | tr -s ' ' '\n' | grep host > | cut -f2 -d=) > export HOST_SYS=$(echo $CONFIGURE_FLAGS | tr -s ' ' '\n' | grep build > | cut -f2 -d=) > export STAGING_INCDIR=${OECORE_TARGET_SYSROOT}/usr/include > export STAGING_LIBDIR=${OECORE_TARGET_SYSROOT}/usr/lib > export PATH=${OECORE_NATIVE_SYSROOT}/usr/bin/python-native:${PATH} > > I save it to a file and source it passing the environment-setup-* > scritp that lives at my ${TMPDIR} folder. > > After that I can crosscompile python extension to my target as usual > with `python setup.py build' > > > Regards, > > > 2016-06-20 17:43 GMT-03:00 Daniel. <[email protected]>: >> 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 <[email protected]>: >>> >>> On Mon, Jun 20, 2016 at 12:08 PM, Daniel. <[email protected]> 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. <[email protected]>: >>> >> >>> >> Thank you Khem!! >>> >> >>> >> Regards, >>> >> >>> >> 2016-06-20 15:02 GMT-03:00 Khem Raj <[email protected]>: >>> >>> >>> >>> On Mon, Jun 20, 2016 at 10:44 AM, Daniel. <[email protected]> >>> >>> 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 >>> >>> > [email protected] >>> >>> > 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 > > > > -- > "Do or do not. There is no try" > Yoda Master -- "Do or do not. There is no try" Yoda Master -- _______________________________________________ yocto mailing list [email protected] https://lists.yoctoproject.org/listinfo/yocto
