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 8/8] Support python-exec:2.
Date: Fri, 13 Sep 2013 18:58:41
Message-Id: 1379098729-2801-9-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-python] Clean up of python eclasses and support for python-exec:2 by "Michał Górny"
1 ---
2 gx86/eclass/distutils-r1.eclass | 8 +++++---
3 gx86/eclass/python-r1.eclass | 36 +++++++++++++++++++++++++--------
4 gx86/eclass/python-single-r1.eclass | 8 +++++++-
5 gx86/eclass/python-utils-r1.eclass | 40 ++++++++++++++++++++++++++++++++++---
6 4 files changed, 77 insertions(+), 15 deletions(-)
7
8 diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
9 index 0517bbb..1e04bd4 100644
10 --- a/gx86/eclass/distutils-r1.eclass
11 +++ b/gx86/eclass/distutils-r1.eclass
12 @@ -428,9 +428,11 @@ _distutils-r1_wrap_scripts() {
13 if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then
14 debug-print "${FUNCNAME}: matching shebang: ${shebang}"
15
16 - local newfn=${basename}-${EPYTHON}
17 - debug-print "${FUNCNAME}: renaming to /usr/bin/${newfn}"
18 - mv "${f}" "${ED%/}/usr/bin/${newfn}" || die
19 + if ! _python_want_python_exec2; then
20 + local newfn=${basename}-${EPYTHON}
21 + debug-print "${FUNCNAME}: renaming to /usr/bin/${newfn}"
22 + mv "${f}" "${ED%/}/usr/bin/${newfn}" || die
23 + fi
24
25 debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}"
26 _python_symlink_wrapper "${ED%/}/usr/bin/${basename}"
27 diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
28 index d1b2143..f146f91 100644
29 --- a/gx86/eclass/python-r1.eclass
30 +++ b/gx86/eclass/python-r1.eclass
31 @@ -122,7 +122,7 @@ fi
32 #
33 # Example value:
34 # @CODE
35 -# dev-python/python-exec:0
36 +# dev-python/python-exec:=
37 # python_targets_python2_6? ( dev-lang/python:2.6[gdbm] )
38 # python_targets_python2_7? ( dev-lang/python:2.7[gdbm] )
39 # @CODE
40 @@ -203,7 +203,13 @@ _python_set_globals() {
41 # but no point in making this overcomplex, BDEP doesn't hurt anyone
42 # 2) python-exec should be built with all targets forced anyway
43 # but if new targets were added, we may need to force a rebuild
44 - PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
45 + # 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4,
46 + # just fix :0 for now since := deps are not supported.
47 + if [[ ${EAPI} != 4 ]]; then
48 + PYTHON_DEPS+="dev-python/python-exec:=[${PYTHON_USEDEP}]"
49 + else
50 + PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
51 + fi
52 }
53 _python_set_globals
54
55 @@ -742,12 +748,26 @@ python_replicate_script() {
56 debug-print-function ${FUNCNAME} "${@}"
57
58 _python_replicate_script() {
59 - local f
60 - for f in "${files[@]}"; do
61 - cp -p "${f}" "${f}-${EPYTHON}" || die
62 - done
63 - _python_rewrite_shebang "${EPYTHON}" \
64 - "${files[@]/%/-${EPYTHON}}"
65 + if _python_want_python_exec2; then
66 + local PYTHON_SCRIPTDIR
67 + python_export PYTHON_SCRIPTDIR
68 +
69 + (
70 + exeinto "${PYTHON_SCRIPTDIR#${EPREFIX}}"
71 + doexe "${files[@]}"
72 + )
73 +
74 + _python_rewrite_shebang "${EPYTHON}" \
75 + "${files[@]/*\//${D%/}/${PYTHON_SCRIPTDIR}/}"
76 + else
77 + local f
78 + for f in "${files[@]}"; do
79 + cp -p "${f}" "${f}-${EPYTHON}" || die
80 + done
81 +
82 + _python_rewrite_shebang "${EPYTHON}" \
83 + "${files[@]/%/-${EPYTHON}}"
84 + fi
85 }
86
87 local files=( "${@}" )
88 diff --git a/gx86/eclass/python-single-r1.eclass b/gx86/eclass/python-single-r1.eclass
89 index 2b099c3..46786ea 100644
90 --- a/gx86/eclass/python-single-r1.eclass
91 +++ b/gx86/eclass/python-single-r1.eclass
92 @@ -193,7 +193,13 @@ _python_single_set_globals() {
93 # but no point in making this overcomplex, BDEP doesn't hurt anyone
94 # 2) python-exec should be built with all targets forced anyway
95 # but if new targets were added, we may need to force a rebuild
96 - PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
97 + # 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4,
98 + # just fix :0 for now since := deps are not supported.
99 + if [[ ${EAPI} != 4 ]]; then
100 + PYTHON_DEPS+="dev-python/python-exec:=[${PYTHON_USEDEP}]"
101 + else
102 + PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
103 + fi
104 }
105 _python_single_set_globals
106
107 diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
108 index dd1ce0b..bacfc70 100644
109 --- a/gx86/eclass/python-utils-r1.eclass
110 +++ b/gx86/eclass/python-utils-r1.eclass
111 @@ -583,7 +583,11 @@ _python_rewrite_shebang() {
112 _python_symlink_wrapper() {
113 debug-print-function ${FUNCNAME} "${@}"
114
115 - local from=${ED%/}/usr/bin/python-exec
116 + if _python_want_python_exec2; then
117 + local from=${ED%/}/usr/lib/python-exec/python-exec2
118 + else
119 + local from=${ED%/}/usr/bin/python-exec
120 + fi
121 local to=${1}
122
123 local frpath=${from%/*}/
124 @@ -756,20 +760,30 @@ python_newscript() {
125 [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
126
127 local d=${python_scriptroot:-${DESTTREE}/bin}
128 + local wrapd=${d}
129
130 local f=${1}
131 local barefn=${2}
132 + local newfn
133
134 - local newfn=${barefn}-${EPYTHON}
135 + if _python_want_python_exec2; then
136 + local PYTHON_SCRIPTDIR
137 + python_export PYTHON_SCRIPTDIR
138 + d=${PYTHON_SCRIPTDIR#${EPREFIX}}
139 + newfn=${barefn}
140 + else
141 + newfn=${barefn}-${EPYTHON}
142 + fi
143
144 (
145 + dodir "${wrapd}"
146 exeinto "${d}"
147 newexe "${f}" "${newfn}" || die
148 )
149 _python_rewrite_shebang "${ED%/}/${d}/${newfn}"
150
151 # install the wrapper
152 - _python_symlink_wrapper "${ED%/}/${d}/${barefn}"
153 + _python_symlink_wrapper "${ED%/}/${wrapd}/${barefn}"
154 }
155
156 # @ECLASS-VARIABLE: python_moduleroot
157 @@ -984,5 +998,25 @@ python_is_python3() {
158 [[ ${impl} == python3* ]]
159 }
160
161 +# @FUNCTION: _python_want_python_exec2
162 +# @INTERNAL
163 +# @DESCRIPTION:
164 +# Check whether we should be using python-exec:2.
165 +_python_want_python_exec2() {
166 + debug-print-function ${FUNCNAME} "${@}"
167 +
168 + # EAPI 4 lacks slot operators, so just fix it on python-exec:0.
169 + [[ ${EAPI} == 4 ]] && return 1
170 +
171 + # Check if we cached the result, or someone put an override.
172 + if [[ ! ${_PYTHON_WANT_PYTHON_EXEC2+1} ]]; then
173 + has_version 'dev-python/python-exec:2'
174 + _PYTHON_WANT_PYTHON_EXEC2=$(( ! ${?} ))
175 + fi
176 +
177 + # Non-zero means 'yes', zero means 'no'.
178 + [[ ${_PYTHON_WANT_PYTHON_EXEC2} != 0 ]]
179 +}
180 +
181 _PYTHON_UTILS_R1=1
182 fi
183 --
184 1.8.3.2