distutils: Run python from the PATH in the -native case as well

The python distutils generate a python wrapper script for each package,
containing 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 nativepython or nativepython3 as appropriate.
The nativepython symlink is installed by the python-native recipe:

    #!/usr/bin/env nativepython

We were already doing this for on-target distutils components.
This change applies the sed-line to -native distutils components as well.
In this way, -native clients of these components can invoke the wrapper scripts
directly, without themselves needing to inherit pythonnative.

This works around a known setuptools issue:
https://github.com/pypa/setuptools/issues/494
Even once this issue has been resolved upstream,
we will still need to replace `python` with `nativepython`

(From OE-Core rev: 0a5bd4f30182a3d55153e5ade76f1dfd5b52b482)

Signed-off-by: Douglas Royds <douglas.royds@taitradio.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Douglas Royds 2019-05-06 18:47:25 +12:00 committed by Richard Purdie
parent 568f0ab886
commit a839671f6e
2 changed files with 10 additions and 8 deletions

View File

@ -9,6 +9,9 @@ DISTUTILS_INSTALL_ARGS ?= "--root=${D} \
--install-lib=${PYTHON_SITEPACKAGES_DIR} \ --install-lib=${PYTHON_SITEPACKAGES_DIR} \
--install-data=${datadir}" --install-data=${datadir}"
DISTUTILS_PYTHON = "python"
DISTUTILS_PYTHON_class-native = "nativepython"
distutils_do_configure() { distutils_do_configure() {
if [ "${CLEANBROKEN}" != "1" ] ; then if [ "${CLEANBROKEN}" != "1" ] ; then
NO_FETCH_BUILD=1 \ NO_FETCH_BUILD=1 \
@ -53,18 +56,14 @@ distutils_do_install() {
if test -e ${D}${bindir} ; then if test -e ${D}${bindir} ; then
for i in ${D}${bindir}/* ; do \ for i in ${D}${bindir}/* ; do \
if [ ${PN} != "${BPN}-native" ]; then sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${USRBINPATH}/env\ ${DISTUTILS_PYTHON}:g $i
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 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
done done
fi fi
if [ -e ${D}${sbindir} ]; then if [ -e ${D}${sbindir} ]; then
for i in ${D}${sbindir}/* ; do \ for i in ${D}${sbindir}/* ; do \
if [ ${PN} != "${BPN}-native" ]; then sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${USRBINPATH}/env\ ${DISTUTILS_PYTHON}:g $i
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 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
done done
fi fi

View File

@ -10,6 +10,9 @@ DISTUTILS_INSTALL_ARGS ?= "--root=${D} \
--install-lib=${PYTHON_SITEPACKAGES_DIR} \ --install-lib=${PYTHON_SITEPACKAGES_DIR} \
--install-data=${datadir}" --install-data=${datadir}"
DISTUTILS_PYTHON = "python3"
DISTUTILS_PYTHON_class-native = "nativepython3"
distutils3_do_configure() { distutils3_do_configure() {
if [ "${CLEANBROKEN}" != "1" ] ; then if [ "${CLEANBROKEN}" != "1" ] ; then
NO_FETCH_BUILD=1 \ NO_FETCH_BUILD=1 \
@ -57,14 +60,14 @@ distutils3_do_install() {
if test -e ${D}${bindir} ; then if test -e ${D}${bindir} ; then
for i in ${D}${bindir}/* ; do \ 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}/${PYTHON_PN}-native/${PYTHON_PN}:${USRBINPATH}/env\ ${DISTUTILS_PYTHON}:g $i
sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
done done
fi fi
if test -e ${D}${sbindir}; then if test -e ${D}${sbindir}; then
for i in ${D}${sbindir}/* ; do \ for i in ${D}${sbindir}/* ; do \
sed -i -e s:${STAGING_BINDIR_NATIVE}/python-${PYTHON_PN}/${PYTHON_PN}:${USRBINPATH}/env\ ${PYTHON_PN}:g $i sed -i -e s:${STAGING_BINDIR_NATIVE}/python-${PYTHON_PN}/${PYTHON_PN}:${USRBINPATH}/env\ ${DISTUTILS_PYTHON}:g $i
sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
done done
fi fi