[tools] scons: wrap python invocations with helper script that attempts to find a...
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 15 May 2012 20:04:07 +0000 (20:04 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 15 May 2012 20:04:07 +0000 (20:04 +0000)
SVN-Revision: 31742

tools/scons/Makefile
tools/scons/files/pywrap.sh [new file with mode: 0755]

index aadeb289a25952f48e00c35091c48f4e444acd63..83c1c584a5143d205e4957b8cd4d85787895bf9b 100644 (file)
@@ -23,7 +23,12 @@ define Host/Compile
 endef
 
 define Host/Install
-       python $(HOST_BUILD_DIR)/setup.py install --prefix=$(STAGING_DIR_HOST)
+       ./files/pywrap.sh $(HOST_BUILD_DIR)/setup.py install --prefix=$(STAGING_DIR_HOST)
+       rm -f $(STAGING_DIR_HOST)/bin/scons*.py
+       for bin in $(STAGING_DIR_HOST)/bin/scons*; do \
+               mv "$$$$bin" "$$$$bin.py";                \
+               cp ./files/pywrap.sh "$$$$bin";           \
+       done
 endef
 
 $(eval $(call HostBuild))
diff --git a/tools/scons/files/pywrap.sh b/tools/scons/files/pywrap.sh
new file mode 100755 (executable)
index 0000000..336ea21
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+case "${0##*/}" in
+       pywrap.sh) arg1="";;
+       *) arg1="$0.py" ;;
+esac
+
+for bin in python2.7 python2.6 python2.5 python2.4 python2 python; do
+    case "$($bin -V 2>&1)" in
+        "Python 2"*) exec $bin $arg1 "$@" ;;
+    esac
+done
+
+echo "Unable to find a Python 2.x interpreter for executing ${arg1:+$arg1 }$@ !" >&2
+exit 1