public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-python@lists.gentoo.org
Cc: python@gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-python] [PATCH 4/8] distutils-r1: rework script install/wrapping.
Date: Fri, 13 Sep 2013 20:58:45 +0200	[thread overview]
Message-ID: <1379098729-2801-5-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <1379098729-2801-1-git-send-email-mgorny@gentoo.org>

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: <path>
 # @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



  parent reply	other threads:[~2013-09-13 18:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 1/8] Add PYTHON_SCRIPTDIR for script installation path Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 2/8] Clean up python_replicate_script() Michał Górny
2013-09-15 17:11   ` [gentoo-python] " Mike Gilbert
2013-09-15 17:36     ` Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 3/8] Clean up python_newscript() Michał Górny
2013-09-13 18:58 ` Michał Górny [this message]
2013-09-13 18:58 ` [gentoo-python] [PATCH 5/8] distutils-r1: disable sub-root merging Michał Górny
2013-09-14 22:16   ` [gentoo-python] " Mike Gilbert
2013-09-14 22:38     ` Michał Górny
2013-09-14 23:33       ` Mike Gilbert
2013-09-15  9:04         ` Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 6/8] _distutils-r1_wrap_scripts(): do not pass root path explicitly Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 7/8] Replace _python_ln_rel() with _python_symlink_wrapper() Michał Górny
2013-09-15 17:27   ` [gentoo-python] " Mike Gilbert
2013-09-13 18:58 ` [gentoo-python] [PATCH 8/8] Support python-exec:2 Michał Górny
2013-09-15  9:03 ` [gentoo-python] Clean up of python eclasses and support for python-exec:2, r2 Michał Górny
2013-09-15  9:03   ` [gentoo-python] [PATCH 1/2] distutils-r1: clean up script install/wrapping Michał Górny
2013-09-15  9:03   ` [gentoo-python] [PATCH 2/2] Support python-exec:2 Michał Górny
2013-09-15  9:29     ` Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379098729-2801-5-git-send-email-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-python@lists.gentoo.org \
    --cc=python@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox