Gentoo Archives: gentoo-python

From: "Michał Górny" <mgorny@g.o>
To: gentoo-python@l.g.o
Cc: python@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-python] [PATCH 1/2] distutils-r1: clean up script install/wrapping.
Date: Sun, 15 Sep 2013 09:03:12
Message-Id: 1379235806-15800-2-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-python] Clean up of python eclasses and support for python-exec:2, r2 by "Michał Górny"
1 ---
2 gx86/eclass/distutils-r1.eclass | 34 +++++++++++++++++-----------------
3 1 file changed, 17 insertions(+), 17 deletions(-)
4
5 diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
6 index c2872b3..985e707 100644
7 --- a/gx86/eclass/distutils-r1.eclass
8 +++ b/gx86/eclass/distutils-r1.eclass
9 @@ -409,39 +409,38 @@ distutils-r1_python_test() {
10 :
11 }
12
13 -# @FUNCTION: _distutils-r1_rename_scripts
14 +# @FUNCTION: _distutils-r1_wrap_scripts
15 # @USAGE: <path>
16 # @INTERNAL
17 # @DESCRIPTION:
18 -# Renames installed Python scripts to be implementation-suffixed.
19 -# ${EPYTHON} needs to be set to the implementation name.
20 -#
21 -# All executable scripts having shebang referencing ${EPYTHON}
22 -# in given path will be renamed.
23 -_distutils-r1_rename_scripts() {
24 +# Moves and wraps all Python scripts installed to PYTHON_SCRIPTDIR
25 +# as necessary.
26 +_distutils-r1_wrap_scripts() {
27 debug-print-function ${FUNCNAME} "${@}"
28
29 local path=${1}
30 [[ ${path} ]] || die "${FUNCNAME}: no path given"
31
32 + mkdir -p "${path}/usr/bin" || die
33 local f
34 while IFS= read -r -d '' f; do
35 - debug-print "${FUNCNAME}: found executable at ${f#${D}/}"
36 + local basename=${f##*/}
37 + debug-print "${FUNCNAME}: found executable at ${f#${path}/}"
38
39 local shebang
40 read -r shebang < "${f}"
41 - if [[ ${shebang} == '#!'*${EPYTHON}* ]]
42 - then
43 + if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then
44 debug-print "${FUNCNAME}: matching shebang: ${shebang}"
45
46 - local newf=${f}-${EPYTHON}
47 - debug-print "${FUNCNAME}: renaming to ${newf#${D}/}"
48 + local newf=${f%/*}/${basename}-${EPYTHON}
49 + debug-print "${FUNCNAME}: renaming to ${newf#${path}}"
50 mv "${f}" "${newf}" || die
51
52 - debug-print "${FUNCNAME}: installing wrapper at ${f#${D}/}"
53 - _python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec "${f}" || die
54 + debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}"
55 + _python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec \
56 + "${path}${EPREFIX}/usr/bin/${basename}" || die
57 fi
58 - done < <(find "${path}" -type f -executable -print0)
59 + done < <(find "${path}/usr/bin" -type f -print0)
60 }
61
62 # @FUNCTION: distutils-r1_python_install
63 @@ -474,15 +473,16 @@ distutils-r1_python_install() {
64
65 local root=${D}/_${EPYTHON}
66 [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
67 + flags+=( --root="${root}" )
68
69 - esetup.py install "${flags[@]}" --root="${root}" "${@}"
70 + esetup.py install "${flags[@]}" "${@}"
71
72 if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
73 die "Package installs 'tests' package, file collisions likely."
74 fi
75
76 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
77 - _distutils-r1_rename_scripts "${root}"
78 + _distutils-r1_wrap_scripts "${root}"
79 multibuild_merge_root "${root}" "${D}"
80 fi
81 }
82 --
83 1.8.3.2