1 |
--- |
2 |
gx86/eclass/distutils-r1.eclass | 28 +++++++++++++++++---- |
3 |
gx86/eclass/python-r1.eclass | 38 +++++++++++++++++++++------- |
4 |
gx86/eclass/python-single-r1.eclass | 8 +++++- |
5 |
gx86/eclass/python-utils-r1.eclass | 50 ++++++++++++++++++++++++++++++++++--- |
6 |
4 files changed, 106 insertions(+), 18 deletions(-) |
7 |
|
8 |
diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass |
9 |
index 985e707..e03e135 100644 |
10 |
--- a/gx86/eclass/distutils-r1.eclass |
11 |
+++ b/gx86/eclass/distutils-r1.eclass |
12 |
@@ -421,6 +421,10 @@ _distutils-r1_wrap_scripts() { |
13 |
local path=${1} |
14 |
[[ ${path} ]] || die "${FUNCNAME}: no path given" |
15 |
|
16 |
+ if ! _python_want_python_exec2; then |
17 |
+ local PYTHON_SCRIPTDIR=${EPREFIX}/usr/bin |
18 |
+ fi |
19 |
+ |
20 |
mkdir -p "${path}/usr/bin" || die |
21 |
local f |
22 |
while IFS= read -r -d '' f; do |
23 |
@@ -432,15 +436,22 @@ _distutils-r1_wrap_scripts() { |
24 |
if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then |
25 |
debug-print "${FUNCNAME}: matching shebang: ${shebang}" |
26 |
|
27 |
- local newf=${f%/*}/${basename}-${EPYTHON} |
28 |
- debug-print "${FUNCNAME}: renaming to ${newf#${path}}" |
29 |
- mv "${f}" "${newf}" || die |
30 |
+ if ! _python_want_python_exec2; then |
31 |
+ local newf=${f%/*}/${basename}-${EPYTHON} |
32 |
+ debug-print "${FUNCNAME}: renaming to ${newf#${path}}" |
33 |
+ mv "${f}" "${newf}" || die |
34 |
+ fi |
35 |
|
36 |
debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}" |
37 |
- _python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec \ |
38 |
+ _python_ln_rel "${path}${EPREFIX}"$(_python_get_wrapper_path) \ |
39 |
"${path}${EPREFIX}/usr/bin/${basename}" || die |
40 |
+ elif _python_want_python_exec2; then |
41 |
+ debug-print "${FUNCNAME}: non-matching shebang: ${shebang}" |
42 |
+ |
43 |
+ debug-print "${FUNCNAME}: moving to /usr/bin/${basename}" |
44 |
+ mv "${f}" "${ED%/}/usr/bin/${basename}" || die |
45 |
fi |
46 |
- done < <(find "${path}/usr/bin" -type f -print0) |
47 |
+ done < <(find "${path}${PYTHON_SCRIPTDIR}" -type f -print0) |
48 |
} |
49 |
|
50 |
# @FUNCTION: distutils-r1_python_install |
51 |
@@ -475,6 +486,13 @@ distutils-r1_python_install() { |
52 |
[[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D} |
53 |
flags+=( --root="${root}" ) |
54 |
|
55 |
+ if [[ ! ${DISTUTILS_SINGLE_IMPL} ]] && _python_want_python_exec2 |
56 |
+ then |
57 |
+ local PYTHON_SCRIPTDIR |
58 |
+ python_export PYTHON_SCRIPTDIR |
59 |
+ flags+=( --install-scripts="${PYTHON_SCRIPTDIR}" ) |
60 |
+ fi |
61 |
+ |
62 |
esetup.py install "${flags[@]}" "${@}" |
63 |
|
64 |
if [[ -d ${root}$(python_get_sitedir)/tests ]]; then |
65 |
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass |
66 |
index e006744..d80c7b6 100644 |
67 |
--- a/gx86/eclass/python-r1.eclass |
68 |
+++ b/gx86/eclass/python-r1.eclass |
69 |
@@ -122,7 +122,7 @@ fi |
70 |
# |
71 |
# Example value: |
72 |
# @CODE |
73 |
-# dev-python/python-exec:0 |
74 |
+# dev-python/python-exec:= |
75 |
# python_targets_python2_6? ( dev-lang/python:2.6[gdbm] ) |
76 |
# python_targets_python2_7? ( dev-lang/python:2.7[gdbm] ) |
77 |
# @CODE |
78 |
@@ -203,7 +203,13 @@ _python_set_globals() { |
79 |
# but no point in making this overcomplex, BDEP doesn't hurt anyone |
80 |
# 2) python-exec should be built with all targets forced anyway |
81 |
# but if new targets were added, we may need to force a rebuild |
82 |
- PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]" |
83 |
+ # 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4, |
84 |
+ # just fix :0 for now since := deps are not supported. |
85 |
+ if [[ ${EAPI} != 4 ]]; then |
86 |
+ PYTHON_DEPS+="dev-python/python-exec:=[${PYTHON_USEDEP}]" |
87 |
+ else |
88 |
+ PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]" |
89 |
+ fi |
90 |
} |
91 |
_python_set_globals |
92 |
|
93 |
@@ -742,12 +748,26 @@ python_replicate_script() { |
94 |
debug-print-function ${FUNCNAME} "${@}" |
95 |
|
96 |
_python_replicate_script() { |
97 |
- local f |
98 |
- for f in "${files[@]}"; do |
99 |
- cp -p "${f}" "${f}-${EPYTHON}" || die |
100 |
- done |
101 |
- _python_rewrite_shebang "${EPYTHON}" \ |
102 |
- "${files[@]/%/-${EPYTHON}}" |
103 |
+ if _python_want_python_exec2; then |
104 |
+ local PYTHON_SCRIPTDIR |
105 |
+ python_export PYTHON_SCRIPTDIR |
106 |
+ |
107 |
+ ( |
108 |
+ exeinto "${PYTHON_SCRIPTDIR#${EPREFIX}}" |
109 |
+ doexe "${files[@]}" |
110 |
+ ) |
111 |
+ |
112 |
+ _python_rewrite_shebang "${EPYTHON}" \ |
113 |
+ "${files[@]/*\//${D%/}/${PYTHON_SCRIPTDIR}/}" |
114 |
+ else |
115 |
+ local f |
116 |
+ for f in "${files[@]}"; do |
117 |
+ cp -p "${f}" "${f}-${EPYTHON}" || die |
118 |
+ done |
119 |
+ |
120 |
+ _python_rewrite_shebang "${EPYTHON}" \ |
121 |
+ "${files[@]/%/-${EPYTHON}}" |
122 |
+ fi |
123 |
} |
124 |
|
125 |
local files=( "${@}" ) |
126 |
@@ -756,7 +776,7 @@ python_replicate_script() { |
127 |
# install the wrappers |
128 |
local f |
129 |
for f; do |
130 |
- _python_ln_rel "${ED%/}"/usr/bin/python-exec "${f}" || die |
131 |
+ _python_ln_rel "${ED%/}$(_python_get_wrapper_path)" "${f}" || die |
132 |
done |
133 |
} |
134 |
|
135 |
diff --git a/gx86/eclass/python-single-r1.eclass b/gx86/eclass/python-single-r1.eclass |
136 |
index 2b099c3..46786ea 100644 |
137 |
--- a/gx86/eclass/python-single-r1.eclass |
138 |
+++ b/gx86/eclass/python-single-r1.eclass |
139 |
@@ -193,7 +193,13 @@ _python_single_set_globals() { |
140 |
# but no point in making this overcomplex, BDEP doesn't hurt anyone |
141 |
# 2) python-exec should be built with all targets forced anyway |
142 |
# but if new targets were added, we may need to force a rebuild |
143 |
- PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]" |
144 |
+ # 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4, |
145 |
+ # just fix :0 for now since := deps are not supported. |
146 |
+ if [[ ${EAPI} != 4 ]]; then |
147 |
+ PYTHON_DEPS+="dev-python/python-exec:=[${PYTHON_USEDEP}]" |
148 |
+ else |
149 |
+ PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]" |
150 |
+ fi |
151 |
} |
152 |
_python_single_set_globals |
153 |
|
154 |
diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass |
155 |
index 6cf23f0..a15a3f3 100644 |
156 |
--- a/gx86/eclass/python-utils-r1.eclass |
157 |
+++ b/gx86/eclass/python-utils-r1.eclass |
158 |
@@ -607,7 +607,7 @@ _python_ln_rel() { |
159 |
rel_path=../${rel_path}${frseg:+${frseg}/} |
160 |
fi |
161 |
done |
162 |
- rel_path+=${frpath}${1##*/} |
163 |
+ rel_path+=${frpath}${from##*/} |
164 |
|
165 |
debug-print "${FUNCNAME}: ${from} -> ${to}" |
166 |
debug-print "${FUNCNAME}: rel_path = ${rel_path}" |
167 |
@@ -756,20 +756,30 @@ python_newscript() { |
168 |
[[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>" |
169 |
|
170 |
local d=${python_scriptroot:-${DESTTREE}/bin} |
171 |
+ local wrapd=${d} |
172 |
|
173 |
local f=${1} |
174 |
local barefn=${2} |
175 |
+ local newfn |
176 |
|
177 |
- local newfn=${barefn}-${EPYTHON} |
178 |
+ if _python_want_python_exec2; then |
179 |
+ local PYTHON_SCRIPTDIR |
180 |
+ python_export PYTHON_SCRIPTDIR |
181 |
+ d=${PYTHON_SCRIPTDIR#${EPREFIX}} |
182 |
+ newfn=${barefn} |
183 |
+ else |
184 |
+ newfn=${barefn}-${EPYTHON} |
185 |
+ fi |
186 |
|
187 |
( |
188 |
+ dodir "${wrapd}" |
189 |
exeinto "${d}" |
190 |
newexe "${f}" "${newfn}" || die |
191 |
) |
192 |
_python_rewrite_shebang "${ED%/}/${d}/${newfn}" |
193 |
|
194 |
# install the wrapper |
195 |
- _python_ln_rel "${ED%/}"/usr/bin/python-exec \ |
196 |
+ _python_ln_rel "${ED%/}"$(_python_get_wrapper_path) \ |
197 |
"${ED%/}/${d}/${barefn}" || die |
198 |
} |
199 |
|
200 |
@@ -985,5 +995,39 @@ python_is_python3() { |
201 |
[[ ${impl} == python3* ]] |
202 |
} |
203 |
|
204 |
+# @FUNCTION: _python_want_python_exec2 |
205 |
+# @INTERNAL |
206 |
+# @DESCRIPTION: |
207 |
+# Check whether we should be using python-exec:2. |
208 |
+_python_want_python_exec2() { |
209 |
+ debug-print-function ${FUNCNAME} "${@}" |
210 |
+ |
211 |
+ # EAPI 4 lacks slot operators, so just fix it on python-exec:0. |
212 |
+ [[ ${EAPI} == 4 ]] && return 1 |
213 |
+ |
214 |
+ # Check if we cached the result, or someone put an override. |
215 |
+ if [[ ! ${_PYTHON_WANT_PYTHON_EXEC2+1} ]]; then |
216 |
+ has_version 'dev-python/python-exec:2' |
217 |
+ _PYTHON_WANT_PYTHON_EXEC2=$(( ! ${?} )) |
218 |
+ fi |
219 |
+ |
220 |
+ # Non-zero means 'yes', zero means 'no'. |
221 |
+ [[ ${_PYTHON_WANT_PYTHON_EXEC2} != 0 ]] |
222 |
+} |
223 |
+ |
224 |
+# @FUNCTION: _python_get_wrapper_path |
225 |
+# @INTERNAL |
226 |
+# @DESCRIPTION: |
227 |
+# Output path to proper python-exec slot. |
228 |
+_python_get_wrapper_path() { |
229 |
+ debug-print-function ${FUNCNAME} "${@}" |
230 |
+ |
231 |
+ if _python_want_python_exec2; then |
232 |
+ echo /usr/lib/python-exec/python-exec2 |
233 |
+ else |
234 |
+ echo /usr/bin/python-exec |
235 |
+ fi |
236 |
+} |
237 |
+ |
238 |
_PYTHON_UTILS_R1=1 |
239 |
fi |
240 |
-- |
241 |
1.8.3.2 |