From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 759121381F3 for ; Fri, 13 Sep 2013 18:58:34 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 113B4E0AB3; Fri, 13 Sep 2013 18:58:34 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8C2A4E0AB3 for ; Fri, 13 Sep 2013 18:58:33 +0000 (UTC) Received: from pomiot.lan (host-81.219.110.26.devs.futuro.pl [81.219.110.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id B64E433ECAB; Fri, 13 Sep 2013 18:58:31 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-python@lists.gentoo.org Cc: python@gentoo.org, =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-python] [PATCH 4/8] distutils-r1: rework script install/wrapping. Date: Fri, 13 Sep 2013 20:58:45 +0200 Message-Id: <1379098729-2801-5-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1379098729-2801-1-git-send-email-mgorny@gentoo.org> References: <1379098729-2801-1-git-send-email-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Discussions centering around the Python ecosystem in Gentoo Linux X-BeenThere: gentoo-python@gentoo.org X-BeenThere: gentoo-python@lists.gentoo.org X-Archives-Salt: feb4bafd-0729-4a24-b736-c643c9dae3c1 X-Archives-Hash: 3057412f2d44e92b8c75d46f9cabd368 Now scripts are installed to ${PYTHON_SCRIPTDIR} initially, and then are moved to /usr/bin. --- gx86/eclass/distutils-r1.eclass | 47 +++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass index c2872b3..7102c58 100644 --- a/gx86/eclass/distutils-r1.eclass +++ b/gx86/eclass/distutils-r1.eclass @@ -409,39 +409,43 @@ distutils-r1_python_test() { : } -# @FUNCTION: _distutils-r1_rename_scripts +# @FUNCTION: _distutils-r1_wrap_scripts # @USAGE: # @INTERNAL # @DESCRIPTION: -# Renames installed Python scripts to be implementation-suffixed. -# ${EPYTHON} needs to be set to the implementation name. -# -# All executable scripts having shebang referencing ${EPYTHON} -# in given path will be renamed. -_distutils-r1_rename_scripts() { +# Moves and wraps all Python scripts installed to PYTHON_SCRIPTDIR +# as necessary. +_distutils-r1_wrap_scripts() { debug-print-function ${FUNCNAME} "${@}" local path=${1} [[ ${path} ]] || die "${FUNCNAME}: no path given" + mkdir -p "${path}/usr/bin" || die local f while IFS= read -r -d '' f; do - debug-print "${FUNCNAME}: found executable at ${f#${D}/}" + local basename=${f##*/} + debug-print "${FUNCNAME}: found executable at ${f#${path}/}" local shebang read -r shebang < "${f}" - if [[ ${shebang} == '#!'*${EPYTHON}* ]] - then + if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then debug-print "${FUNCNAME}: matching shebang: ${shebang}" - local newf=${f}-${EPYTHON} - debug-print "${FUNCNAME}: renaming to ${newf#${D}/}" - mv "${f}" "${newf}" || die + local newfn=${basename}-${EPYTHON} + debug-print "${FUNCNAME}: renaming to /usr/bin/${newfn}" + mv "${f}" "${ED%/}/usr/bin/${newfn}" || die + + debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}" + _python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec \ + "${path}${EPREFIX}/usr/bin/${basename}" || die + else + debug-print "${FUNCNAME}: non-matching shebang: ${shebang}" - debug-print "${FUNCNAME}: installing wrapper at ${f#${D}/}" - _python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec "${f}" || die + debug-print "${FUNCNAME}: moving to /usr/bin/${basename}" + mv "${f}" "${ED%/}/usr/bin/${basename}" || die fi - done < <(find "${path}" -type f -executable -print0) + done < <(find "${path}/${PYTHON_SCRIPTDIR}" -type f -print0) } # @FUNCTION: distutils-r1_python_install @@ -474,15 +478,22 @@ distutils-r1_python_install() { local root=${D}/_${EPYTHON} [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D} + flags+=( --root="${root}" ) + + if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then + local PYTHON_SCRIPTDIR + python_export PYTHON_SCRIPTDIR + flags+=( --install-scripts="${PYTHON_SCRIPTDIR}" ) + fi - esetup.py install "${flags[@]}" --root="${root}" "${@}" + esetup.py install "${flags[@]}" "${@}" if [[ -d ${root}$(python_get_sitedir)/tests ]]; then die "Package installs 'tests' package, file collisions likely." fi if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then - _distutils-r1_rename_scripts "${root}" + _distutils-r1_wrap_scripts "${root}" multibuild_merge_root "${root}" "${D}" fi } -- 1.8.3.2