diff options
-rw-r--r-- | common/environment/setup/python.sh | 3 | ||||
-rw-r--r-- | common/hooks/pre-pkg/03-rewrite-python-shebang.sh | 12 |
2 files changed, 5 insertions, 10 deletions
diff --git a/common/environment/setup/python.sh b/common/environment/setup/python.sh index ba181d45361..eca368dbf0d 100644 --- a/common/environment/setup/python.sh +++ b/common/environment/setup/python.sh @@ -2,9 +2,6 @@ # Useful variables for determining Python version and paths. # -# set version 2 as the default Python -python_version="2" - py2_ver="2.7" py2_lib="/usr/lib/python${py2_ver}" py2_sitelib="${py2_lib}/site-packages" diff --git a/common/hooks/pre-pkg/03-rewrite-python-shebang.sh b/common/hooks/pre-pkg/03-rewrite-python-shebang.sh index 4de75da2a76..3450c3a3a8f 100644 --- a/common/hooks/pre-pkg/03-rewrite-python-shebang.sh +++ b/common/hooks/pre-pkg/03-rewrite-python-shebang.sh @@ -4,25 +4,23 @@ hook() { local pyver= shebang= off= - : ${pyver:=2} - if [ -d ${PKGDESTDIR}/usr/lib/python* ]; then pyver="$(find ${PKGDESTDIR}/usr/lib/python* -prune -type d | grep -o '[[:digit:]]\.[[:digit:]]$')" fi - if [ -n "$pycompile_version" ]; then - pyver="$pycompile_version" + if [ -n "$python_version" ]; then + pyver="$python_version" fi - if [ "$python_version" = "3" ]; then - pyver="$python_version" + if [ -n "$pyver" ]; then + shebang="#!/usr/bin/python${pyver%.*}" fi - shebang="#!/usr/bin/python${pyver%.*}" find "${PKGDESTDIR}" -type f -print0 | \ while IFS= read -r -d '' file; do [ ! -s "$file" ] && continue [ -z "$(sed -n -E -e 2q -e '/^#!.*([[:space:]]|\/)python([0-9]\.[0-9])?([[:space:]]+|$)/p' "$file")" ] && continue + [ -n "$shebang" ] || msg_error "cannot convert shebang, set python_version\n" echo " Shebang converted to '$shebang': ${file#$PKGDESTDIR}" sed -i "1s@.*python.*@${shebang}@" -- "$file" done |