Skip to contentSkip to conversation

meta-python: outrageously long cython shebang with pyro

PATCH Superseded S. Lockwood-Childs 2 participants 5 messages May 13, 2017 – May 20, 2017

lore
Share & tools
lore
#0 lore raw

The recipe-specific sysroots in pyro are a wonderful thing for uncovering missing dependencies, but they also make it easier than ever to break the cython scripts by exceeding the measly 128-byte limit on shebang lines.

The cython recipe builds fine -- this is runtime breakage from recipes that depend on cython. This was always a danger when using lengthy toplevel directory names (e.g. as tends to happen in jenkins auto-builds), but now I managed to get the dreaded "bad interpreter: No such file or directory" failure from cython despite a not-ridiculously-long toplevel path:

#!/var/data/sjl/poky/build/tmp/work/armv7a-neon-oe-linux-gnueabi/libplist/git-r0/recipe-sysroot-native/usr/bin/python-native/python

Does anybody know of a recommended strategy for solving the shebang problem, now that it has been exacerbated by the sysroot move? I'll be happy to submit a corresponding cython patch if so.

#1 lore raw
Quoted 7 lines · S. Lockwood-Childs

The cython recipe builds fine -- this is runtime breakage from recipes that depend on cython. This was always a danger when using lengthy toplevel directory names (e.g. as tends to happen in jenkins auto-builds), but now I managed to get the dreaded "bad interpreter: No such file or directory" failure from cython despite a not-ridiculously-long toplevel path:

#!/var/data/sjl/poky/build/tmp/work/armv7a-neon-oe-linux-gnueabi/libplist/git-r0/recipe-sysroot-native/usr/bin/python-native/python

We typically patch the upstream code to use

#!/usr/bin/env python

There is some PATH environment variable magic that will ensure that the correct version of python will come first in the PATH, so it should be safe to do. There's a ton of examples in oe-core.

Alex

#2 lore raw

PATCH 1/1 python-cython: mangle scripts to use /usr/bin/env python

In reply to S. Lockwood-Childs

This prevents runtime failure "bad interpreter: No such file or directory" from running native cython when the native python is installed at a long path, exceeding the 128-character limit for shebang lines on linux. Exceeding the limit was already possible when using a long path for topdir, but it got easier to exceed after the switch to per-recipe sysroots.

---
 meta-python/recipes-devtools/python/python-cython.inc | 7 +++++++
 1 file changed, 7 insertions(+)
meta-python/recipes-devtools/python/python-cython.inc +7 -0
index 1ecdcc9..66383bf 100644
@@ -17,3 +17,10 @@ RDEPENDS_${PN}_class-target += "\
     ${PYTHON_PN}-subprocess \
     ${PYTHON_PN}-shell \
 "
+
+do_install_append() {
+	# Make sure we use /usr/bin/env python
+	for PYTHSCRIPT in `grep -rIl '^!#.*python' ${D}${bindir}`; do
+		sed -i -e '1s|^#!.*|#!/usr/bin/env ${PYTHON_PN}|' $PYTHSCRIPT
+	done
+}
Signature · 1 line
1.9.4
#3 lore raw

PATCH v2 1/1 python-cython: mangle scripts to use /usr/bin/env python

This prevents runtime failure "bad interpreter: No such file or directory" from running native cython when the native python is installed at a long path, exceeding the 128-character limit for shebang lines on linux. Exceeding the limit was already possible when using a long path for topdir, but it got easier to exceed after the switch to per-recipe sysroots.

---
 meta-python/recipes-devtools/python/python-cython.inc | 7 +++++++
 1 file changed, 7 insertions(+)
meta-python/recipes-devtools/python/python-cython.inc +7 -0
index 1ecdcc9..22b49f3 100644
@@ -17,3 +17,10 @@ RDEPENDS_${PN}_class-target += "\
     ${PYTHON_PN}-subprocess \
     ${PYTHON_PN}-shell \
 "
+
+do_install_append() {
+	# Make sure we use /usr/bin/env python
+	for PYTHSCRIPT in `grep -rIl '^!#.*python' ${D}`; do
+		sed -i -e '1s|^#!.*|#!/usr/bin/env ${PYTHON_PN}|' $PYTHSCRIPT
+	done
+}
Signature · 1 line
1.9.4
#4 lore raw

PATCH v3 1/1 python-cython: mangle scripts to use /usr/bin/env python

In reply to S. Lockwood-Childs

This prevents runtime failure "bad interpreter: No such file or directory" from running native cython when the native python is installed at a long path, exceeding the 128-character limit for shebang lines on linux. Exceeding the limit was already possible when using a long path for topdir, but it got easier to exceed after the switch to per-recipe sysroots.

---
 meta-python/recipes-devtools/python/python-cython.inc | 7 +++++++
 1 file changed, 7 insertions(+)
meta-python/recipes-devtools/python/python-cython.inc +7 -0
index 1ecdcc9..da39d14 100644
@@ -17,3 +17,10 @@ RDEPENDS_${PN}_class-target += "\
     ${PYTHON_PN}-subprocess \
     ${PYTHON_PN}-shell \
 "
+
+do_install_append() {
+	# Make sure we use /usr/bin/env python
+	for PYTHSCRIPT in `grep -rIl '^#!.*python' ${D}`; do
+		sed -i -e '1s|^#!.*|#!/usr/bin/env ${PYTHON_PN}|' $PYTHSCRIPT
+	done
+}
Signature · 1 line
1.9.4