[OE-core] Why python-native is not available via '#!/usr/bin/env python'?

Kucharczyk, Bartlomiej (Nokia - PL/Wroclaw) bartlomiej.kucharczyk at nokia.com
Tue Jul 28 16:23:35 UTC 2015


During integrating a Python tool (both: native and nativesdk) into a Yocto layer, the following questions came to my mind.

My problem was that [native-sysroot]/usr/bin/python was too long (complete shebang greater than 128 characters). 
Changing it naively to `/usr/bin/env python` caused the tool to use host Python (which was missing required Python modules).
I've found that it is possible to use '#!/usr/bin/env nativepython' for native. But this solution requires ugly sed in do_install, in recipe for my tool:

	do_install_append_class-native() {
		sed -i '1 c\#!/usr/bin/env nativepython' ${D}${bindir}/binary

Q1. What are the reasons behind that `/usr/bin/env python` refer to the host tool instead the native one?

Q2. Is there any plan to automate shebang adjustments for native python so that it is not affected by too-long-shebang issue? distutils.bbclass already has similar logic, but not enabled for native...

 # listing file: "meta/classes/distutils.bbclass"
 52         if test -e ${D}${bindir} ; then
 53             for i in ${D}${bindir}/* ; do \
 54                 if [ ${PN} != "${BPN}-native" ]; then
 55                         sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${bindir}/env\ python:g $i
 56                 fi
 57                 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
 58             done
 59         fi


More information about the Openembedded-core mailing list