Patchwork distutils: Replacing path to native python by path to python in the image to support python packages with console-script setup

login
register
mail settings
Submitter Lukas Bulwahn
Date Dec. 6, 2012, 9:49 a.m.
Message ID <1354787367-18543-2-git-send-email-lukas.bulwahn@oss.bmw-carit.de>
Download mbox | patch
Permalink /patch/40559/
State New
Headers show

Comments

Lukas Bulwahn - Dec. 6, 2012, 9:49 a.m.
From: Lukas Bulwahn <lukas.bulwahn@bmw-carit.de>

When using distutils for a python package based on a python-setuptools
installation script that sets up a console script, the header
of the console script created by setuptools points to the
python-native path.

The console scripts are commonly executed in the image, but not
in the sysroot environment. Therefore, the header of the
console scripts should point to the python interpreter in the
image.

Setuptools does not allow to set the path of the python
interpreter via some command-line argument.
Hence after the installation script ran, the distutils
class replaces the path in the console script files created by
the installation.

Signed-off-by: Lukas Bulwahn <Lukas.Bulwahn@oss.bmw-carit.de>
---
 meta/classes/distutils.bbclass |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Saul Wold - Dec. 10, 2012, 11:18 p.m.
On 12/06/2012 01:49 AM, Lukas Bulwahn wrote:
> From: Lukas Bulwahn <lukas.bulwahn@bmw-carit.de>
>
> When using distutils for a python package based on a python-setuptools
> installation script that sets up a console script, the header
> of the console script created by setuptools points to the
> python-native path.
>
> The console scripts are commonly executed in the image, but not
> in the sysroot environment. Therefore, the header of the
> console scripts should point to the python interpreter in the
> image.
>
> Setuptools does not allow to set the path of the python
> interpreter via some command-line argument.
> Hence after the installation script ran, the distutils
> class replaces the path in the console script files created by
> the installation.
>
> Signed-off-by: Lukas Bulwahn <Lukas.Bulwahn@oss.bmw-carit.de>
> ---
>   meta/classes/distutils.bbclass |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
Thanks for the patch, good catch, but need a slight tweak.

Sau!


> diff --git a/meta/classes/distutils.bbclass b/meta/classes/distutils.bbclass
> index 552e5f3..f67297e 100644
> --- a/meta/classes/distutils.bbclass
> +++ b/meta/classes/distutils.bbclass
> @@ -47,12 +47,14 @@ distutils_do_install() {
>
>           if test -e ${D}${bindir} ; then	
>               for i in ${D}${bindir}/* ; do \
> +                sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${bindir}/python:g $i
I think this should really end up being #!/usr/bin/env python as that's 
how I see all other scripts do it.

>                   sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
>               done
>           fi
>
>           if test -e ${D}${sbindir}; then
>               for i in ${D}${sbindir}/* ; do \
> +                sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${bindir}/python:g $i
Same here.
>                   sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
>               done
>           fi
> @@ -64,7 +66,6 @@ distutils_do_install() {
>           #
>           if test -e ${D}${datadir}/share; then
>               mv -f ${D}${datadir}/share/* ${D}${datadir}/
> -            rmdir ${D}${datadir}/share
>           fi
>   }
>
>
Lukas Bulwahn - Dec. 13, 2012, 4:43 p.m.
On 12/11/2012 12:18 AM, Saul Wold wrote:
> Thanks for the patch, good catch, but need a slight tweak.
>
> Sau!
>
Thanks for the hint. I refined the patch.

Lukas

Patch

diff --git a/meta/classes/distutils.bbclass b/meta/classes/distutils.bbclass
index 552e5f3..f67297e 100644
--- a/meta/classes/distutils.bbclass
+++ b/meta/classes/distutils.bbclass
@@ -47,12 +47,14 @@  distutils_do_install() {
 
         if test -e ${D}${bindir} ; then	
             for i in ${D}${bindir}/* ; do \
+                sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${bindir}/python:g $i
                 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
             done
         fi
 
         if test -e ${D}${sbindir}; then
             for i in ${D}${sbindir}/* ; do \
+                sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${bindir}/python:g $i
                 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
             done
         fi
@@ -64,7 +66,6 @@  distutils_do_install() {
         #
         if test -e ${D}${datadir}/share; then
             mv -f ${D}${datadir}/share/* ${D}${datadir}/
-            rmdir ${D}${datadir}/share
         fi
 }