[OE-core] [PATCH] distutils: Run python from the PATH in the -native case as well

Richard Purdie richard.purdie at linuxfoundation.org
Tue Apr 30 08:37:01 UTC 2019


On Tue, 2019-04-30 at 14:34 +1200, Douglas Royds via Openembedded-core wrote:
> The python distutils generate a python wrapper script for each package.
> These python scripts have shebang lines pointing to the python executable.
> In our case, this is a fully-qualified path to python-native in the
> recipe-sysroot-native.
> 
> Ubuntu 18.04 restricts the useful length of the shebang line to 125
> characters, and Ubuntu 16.04 restricts it to 77. In both cases, the
> staged python script fails to run due to the length of the path to
> the python-native executable.
> 
> Replace the shebang line with:
> 
>     #!/usr/bin/env python
> 
> We were already doing this for on-target distutils components.
> This change applies the sed-line to -native distutils components as
> well.
> 
> The python executable must be in the PATH.
> Client components must inherit pythonnative.
> 
> Signed-off-by: Douglas Royds <douglas.royds at taitradio.com>
> ---
>  meta/classes/distutils.bbclass | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/meta/classes/distutils.bbclass b/meta/classes/distutils.bbclass
> index 9862731493..e7d79271e3 100644
> --- a/meta/classes/distutils.bbclass
> +++ b/meta/classes/distutils.bbclass
> @@ -53,18 +53,14 @@ distutils_do_install() {
>  
>          if test -e ${D}${bindir} ; then	
>              for i in ${D}${bindir}/* ; do \
> -                if [ ${PN} != "${BPN}-native" ]; then
> -			sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${USRBINPATH}/env\ python:g $i
> -		fi
> +                sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${USRBINPATH}/env\ python:g $i
>                  sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
>              done
>          fi
>  
>          if [ -e ${D}${sbindir} ]; then
>              for i in ${D}${sbindir}/* ; do \
> -                if [ ${PN} != "${BPN}-native" ]; then
> -			sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${USRBINPATH}/env\ python:g $i
> -		fi
> +                sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${USRBINPATH}/env\ python:g $i
>                  sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
>              done
>          fi

I have a bad feeling that there is a reason we use the full path. I
have memories of cases where the "python-native" component isn't in
PATH but we obviously still want it to use our python since that is
what its been built against.

One fix would be to apply this, then ensure all those locations inherit
the pythonnative bbclass however I think that becomes annoying as
anything using the recipe as a dependency also has to inherit the
class.

I *think* we might have therefore created a nativepython symlink of
some kind to ./python-native/python. The right fix might therefore be
to use "${USRBINPATH}/env\ nativepython"?

You'll have to check the code for the correct names as I'm going from
memory.

Cheers,

Richard





More information about the Openembedded-core mailing list