python3-docutils: Fix shebang path to point at python3

Submitted by Alex Kiernan on Dec. 4, 2018, 10:48 a.m. | Patch ID: 156886

Details

Message ID 1543920528-21433-1-git-send-email-alex.kiernan@gmail.com
State New
Headers show

Commit Message

Alex Kiernan Dec. 4, 2018, 10:48 a.m.
By default we get a shebang path pointing at python; when building the
python3 version, ensure we use python3.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---

 meta/recipes-devtools/python/python3-docutils_0.14.bb | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/meta/recipes-devtools/python/python3-docutils_0.14.bb b/meta/recipes-devtools/python/python3-docutils_0.14.bb
index 81a449d64604..a2880a9601d7 100644
--- a/meta/recipes-devtools/python/python3-docutils_0.14.bb
+++ b/meta/recipes-devtools/python/python3-docutils_0.14.bb
@@ -14,5 +14,8 @@  S = "${WORKDIR}/docutils-${PV}"
 
 inherit distutils3
 
-BBCLASSEXTEND = "native"
+do_install_append() {
+    sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' ${D}${bindir}/*
+}
 
+BBCLASSEXTEND = "native"

Comments

Ross Burton Dec. 4, 2018, 11:43 a.m.
Interestingly if you build docutils outside of bitbake, the hashbangs
get rewritten automatically as part of the build...
On Tue, 4 Dec 2018 at 10:49, Alex Kiernan <alex.kiernan@gmail.com> wrote:
>
> By default we get a shebang path pointing at python; when building the
> python3 version, ensure we use python3.
>
> Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
> ---
>
>  meta/recipes-devtools/python/python3-docutils_0.14.bb | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-devtools/python/python3-docutils_0.14.bb b/meta/recipes-devtools/python/python3-docutils_0.14.bb
> index 81a449d64604..a2880a9601d7 100644
> --- a/meta/recipes-devtools/python/python3-docutils_0.14.bb
> +++ b/meta/recipes-devtools/python/python3-docutils_0.14.bb
> @@ -14,5 +14,8 @@ S = "${WORKDIR}/docutils-${PV}"
>
>  inherit distutils3
>
> -BBCLASSEXTEND = "native"
> +do_install_append() {
> +    sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' ${D}${bindir}/*
> +}
>
> +BBCLASSEXTEND = "native"
> --
> 2.7.4
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
Ross Burton Dec. 4, 2018, 12:02 p.m.
Turns out we disable this functionality in distutils.  That patch
should be fixed to do the right thing instead.

Ross
On Tue, 4 Dec 2018 at 11:43, Burton, Ross <ross.burton@intel.com> wrote:
>
> Interestingly if you build docutils outside of bitbake, the hashbangs
> get rewritten automatically as part of the build...
> On Tue, 4 Dec 2018 at 10:49, Alex Kiernan <alex.kiernan@gmail.com> wrote:
> >
> > By default we get a shebang path pointing at python; when building the
> > python3 version, ensure we use python3.
> >
> > Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
> > ---
> >
> >  meta/recipes-devtools/python/python3-docutils_0.14.bb | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/meta/recipes-devtools/python/python3-docutils_0.14.bb b/meta/recipes-devtools/python/python3-docutils_0.14.bb
> > index 81a449d64604..a2880a9601d7 100644
> > --- a/meta/recipes-devtools/python/python3-docutils_0.14.bb
> > +++ b/meta/recipes-devtools/python/python3-docutils_0.14.bb
> > @@ -14,5 +14,8 @@ S = "${WORKDIR}/docutils-${PV}"
> >
> >  inherit distutils3
> >
> > -BBCLASSEXTEND = "native"
> > +do_install_append() {
> > +    sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' ${D}${bindir}/*
> > +}
> >
> > +BBCLASSEXTEND = "native"
> > --
> > 2.7.4
> >
> > --
> > _______________________________________________
> > Openembedded-core mailing list
> > Openembedded-core@lists.openembedded.org
> > http://lists.openembedded.org/mailman/listinfo/openembedded-core
Alex Kiernan Dec. 4, 2018, 2:27 p.m.
On Tue, Dec 4, 2018 at 12:02 PM Burton, Ross <ross.burton@intel.com> wrote:
>
> Turns out we disable this functionality in distutils.  That patch
> should be fixed to do the right thing instead.
>

Well that explains a lot of things... I've a small bag of those
fixups, it never occurred to me it was local to bitbake.

I see that patch, but I dug into the into the distutils class too, we
have this bit for py2 in 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}:${bindir}:g $i
            done
        fi

And this for py3:

        if test -e ${D}${bindir} ; then
            for i in ${D}${bindir}/* ; do \
                sed -i -e
s:${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN}:${USRBINPATH}/env\
${PYTHON_PN}:g $i
                sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
            done
        fi

Which look like it's trying to do this fixup, but fails for the
'/usr/bin/env python' case (and isn't constrained to the first shebang
line).

The extra "if" in py2 is this:

c54076ed8ae5 ("distutils: Replacing path to native path only to be
done to non-native python packages")

Which is in py2, but not py3 - assuming I read the commit right, it's
to handle of the case of coreutils-native not being in the dependency
chain, but I guess that's no longer true.

I'm wondering if the right fix is to delete both the patch and the
do_install fixups and start again?
> Ross
> On Tue, 4 Dec 2018 at 11:43, Burton, Ross <ross.burton@intel.com> wrote:
> >
> > Interestingly if you build docutils outside of bitbake, the hashbangs
> > get rewritten automatically as part of the build...
> > On Tue, 4 Dec 2018 at 10:49, Alex Kiernan <alex.kiernan@gmail.com> wrote:
> > >
> > > By default we get a shebang path pointing at python; when building the
> > > python3 version, ensure we use python3.
> > >
> > > Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
> > > ---
> > >
> > >  meta/recipes-devtools/python/python3-docutils_0.14.bb | 5 ++++-
> > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/meta/recipes-devtools/python/python3-docutils_0.14.bb b/meta/recipes-devtools/python/python3-docutils_0.14.bb
> > > index 81a449d64604..a2880a9601d7 100644
> > > --- a/meta/recipes-devtools/python/python3-docutils_0.14.bb
> > > +++ b/meta/recipes-devtools/python/python3-docutils_0.14.bb
> > > @@ -14,5 +14,8 @@ S = "${WORKDIR}/docutils-${PV}"
> > >
> > >  inherit distutils3
> > >
> > > -BBCLASSEXTEND = "native"
> > > +do_install_append() {
> > > +    sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' ${D}${bindir}/*
> > > +}
> > >
> > > +BBCLASSEXTEND = "native"
> > > --
> > > 2.7.4
> > >
> > > --
> > > _______________________________________________
> > > Openembedded-core mailing list
> > > Openembedded-core@lists.openembedded.org
> > > http://lists.openembedded.org/mailman/listinfo/openembedded-core



--
Alex Kiernan
Ross Burton Dec. 4, 2018, 2:33 p.m.
On Tue, 4 Dec 2018 at 14:27, Alex Kiernan <alex.kiernan@gmail.com> wrote:
> I'm wondering if the right fix is to delete both the patch and the
> do_install fixups and start again?

Probably.

I've just verified that simply disabling that patch for python3-native
(shouldn't be applied to python3, as we definitely don't want this
on-target) results in sysroot paths going into the files written by
distutils, but then the class correctly fixes them.

Ross