From 596250e4ea9b50881e249518e02bd2b7a5aee7c8 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Tue, 21 Apr 2020 14:55:14 -0400 Subject: [PATCH] xbps-src: remove default python_version Closes: #21209 [via git-merge-pr] --- common/environment/setup/python.sh | 3 --- common/hooks/pre-pkg/03-rewrite-python-shebang.sh | 14 ++++++-------- 2 files changed, 6 insertions(+), 11 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" - fi - - if [ "$python_version" = "3" ]; then + if [ -n "$python_version" ]; then pyver="$python_version" fi - shebang="#!/usr/bin/python${pyver%.*}" + if [ -n "$pyver" ]; then + shebang="#!/usr/bin/python${pyver%.*}" + fi + 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