1 |
arfrever 10/10/03 00:38:13 |
2 |
|
3 |
Modified: python.eclass |
4 |
Log: |
5 |
Fix preservation of whitespace in python_execute_function(), python_execute_nosetests(), python_execute_py.test() and python_execute_trial(). |
6 |
Support --allow-evaluated-non-sitedir-paths option in python_mod_optimize() and python_mod_cleanup(). |
7 |
|
8 |
Revision Changes Path |
9 |
1.103 eclass/python.eclass |
10 |
|
11 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.103&view=markup |
12 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.103&content-type=text/plain |
13 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.102&r2=1.103 |
14 |
|
15 |
Index: python.eclass |
16 |
=================================================================== |
17 |
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v |
18 |
retrieving revision 1.102 |
19 |
retrieving revision 1.103 |
20 |
diff -u -r1.102 -r1.103 |
21 |
--- python.eclass 18 Jul 2010 20:45:50 -0000 1.102 |
22 |
+++ python.eclass 3 Oct 2010 00:38:13 -0000 1.103 |
23 |
@@ -1,6 +1,6 @@ |
24 |
# Copyright 1999-2010 Gentoo Foundation |
25 |
# Distributed under the terms of the GNU General Public License v2 |
26 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.102 2010/07/18 20:45:50 arfrever Exp $ |
27 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.103 2010/10/03 00:38:13 arfrever Exp $ |
28 |
|
29 |
# @ECLASS: python.eclass |
30 |
# @MAINTAINER: |
31 |
@@ -925,7 +925,7 @@ |
32 |
|
33 |
if [[ "${quiet}" == "0" ]]; then |
34 |
if [[ -n "${action_message_template}" ]]; then |
35 |
- action_message="$(eval echo -n "${action_message_template}")" |
36 |
+ eval "action_message=\"${action_message_template}\"" |
37 |
else |
38 |
action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)..." |
39 |
fi |
40 |
@@ -959,7 +959,7 @@ |
41 |
|
42 |
if [[ "${return_code}" -ne 0 ]]; then |
43 |
if [[ -n "${failure_message_template}" ]]; then |
44 |
- failure_message="$(eval echo -n "${failure_message_template}")" |
45 |
+ eval "failure_message=\"${failure_message_template}\"" |
46 |
else |
47 |
failure_message="${action} failed with $(python_get_implementation) $(python_get_version) in ${function}() function" |
48 |
fi |
49 |
@@ -1925,7 +1925,7 @@ |
50 |
python_test_function() { |
51 |
local evaluated_PYTHONPATH |
52 |
|
53 |
- evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" |
54 |
+ eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\"" |
55 |
|
56 |
_python_test_hook pre |
57 |
|
58 |
@@ -1989,7 +1989,7 @@ |
59 |
python_test_function() { |
60 |
local evaluated_PYTHONPATH |
61 |
|
62 |
- evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" |
63 |
+ eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\"" |
64 |
|
65 |
_python_test_hook pre |
66 |
|
67 |
@@ -2053,7 +2053,7 @@ |
68 |
python_test_function() { |
69 |
local evaluated_PYTHONPATH |
70 |
|
71 |
- evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" |
72 |
+ eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\"" |
73 |
|
74 |
_python_test_hook pre |
75 |
|
76 |
@@ -2223,7 +2223,7 @@ |
77 |
|
78 |
if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then |
79 |
# PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs. |
80 |
- local dir file iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=() |
81 |
+ local allow_evaluated_non_sitedir_paths="0" dir dirs=() evaluated_dirs=() evaluated_files=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=() |
82 |
|
83 |
if _python_package_supporting_installation_for_multiple_python_abis; then |
84 |
if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then |
85 |
@@ -2243,6 +2243,9 @@ |
86 |
|
87 |
while (($#)); do |
88 |
case "$1" in |
89 |
+ --allow-evaluated-non-sitedir-paths) |
90 |
+ allow_evaluated_non_sitedir_paths="1" |
91 |
+ ;; |
92 |
-l|-f|-q) |
93 |
options+=("$1") |
94 |
;; |
95 |
@@ -2264,6 +2267,10 @@ |
96 |
shift |
97 |
done |
98 |
|
99 |
+ if [[ "${allow_evaluated_non_sitedir_paths}" == "1" ]] && ! _python_package_supporting_installation_for_multiple_python_abis; then |
100 |
+ die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" |
101 |
+ fi |
102 |
+ |
103 |
if [[ "$#" -eq 0 ]]; then |
104 |
ewarn |
105 |
ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" |
106 |
@@ -2279,16 +2286,27 @@ |
107 |
die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories" |
108 |
elif [[ "$1" =~ ^/ ]]; then |
109 |
if _python_package_supporting_installation_for_multiple_python_abis; then |
110 |
- die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" |
111 |
- fi |
112 |
- if [[ -d "${root}$1" ]]; then |
113 |
- other_dirs+=("${root}$1") |
114 |
- elif [[ -f "${root}$1" ]]; then |
115 |
- other_files+=("${root}$1") |
116 |
- elif [[ -e "${root}$1" ]]; then |
117 |
- eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory" |
118 |
+ if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then |
119 |
+ die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" |
120 |
+ fi |
121 |
+ if [[ "$1" != *\$* ]]; then |
122 |
+ die "${FUNCNAME}(): '$1' has invalid syntax" |
123 |
+ fi |
124 |
+ if [[ "$1" == *.py ]]; then |
125 |
+ evaluated_files+=("$1") |
126 |
+ else |
127 |
+ evaluated_dirs+=("$1") |
128 |
+ fi |
129 |
else |
130 |
- eerror "${FUNCNAME}(): '${root}$1' does not exist" |
131 |
+ if [[ -d "${root}$1" ]]; then |
132 |
+ other_dirs+=("${root}$1") |
133 |
+ elif [[ -f "${root}$1" ]]; then |
134 |
+ other_files+=("${root}$1") |
135 |
+ elif [[ -e "${root}$1" ]]; then |
136 |
+ eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory" |
137 |
+ else |
138 |
+ eerror "${FUNCNAME}(): '${root}$1' does not exist" |
139 |
+ fi |
140 |
fi |
141 |
else |
142 |
for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do |
143 |
@@ -2312,32 +2330,38 @@ |
144 |
options+=("-q") |
145 |
|
146 |
for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do |
147 |
- if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then |
148 |
+ if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})) || ((${#evaluated_dirs[@]})) || ((${#evaluated_files[@]})); then |
149 |
return_code="0" |
150 |
ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)" |
151 |
- if ((${#site_packages_dirs[@]})); then |
152 |
+ if ((${#site_packages_dirs[@]})) || ((${#evaluated_dirs[@]})); then |
153 |
for dir in "${site_packages_dirs[@]}"; do |
154 |
- site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}") |
155 |
+ dirs+=("${root}$(python_get_sitedir)/${dir}") |
156 |
+ done |
157 |
+ for dir in "${evaluated_dirs[@]}"; do |
158 |
+ eval "dirs+=(\"\${root}${dir}\")" |
159 |
done |
160 |
- "$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1" |
161 |
+ "$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" || return_code="1" |
162 |
if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then |
163 |
- "$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &> /dev/null || return_code="1" |
164 |
+ "$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1" |
165 |
fi |
166 |
- _python_clean_compiled_modules "${site_packages_absolute_dirs[@]}" |
167 |
+ _python_clean_compiled_modules "${dirs[@]}" |
168 |
fi |
169 |
- if ((${#site_packages_files[@]})); then |
170 |
+ if ((${#site_packages_files[@]})) || ((${#evaluated_files[@]})); then |
171 |
for file in "${site_packages_files[@]}"; do |
172 |
- site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}") |
173 |
+ files+=("${root}$(python_get_sitedir)/${file}") |
174 |
done |
175 |
- "$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1" |
176 |
+ for file in "${evaluated_files[@]}"; do |
177 |
+ eval "files+=(\"\${root}${file}\")" |
178 |
+ done |
179 |
+ "$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" || return_code="1" |
180 |
if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then |
181 |
- "$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &> /dev/null || return_code="1" |
182 |
+ "$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" &> /dev/null || return_code="1" |
183 |
fi |
184 |
- _python_clean_compiled_modules "${site_packages_absolute_files[@]}" |
185 |
+ _python_clean_compiled_modules "${files[@]}" |
186 |
fi |
187 |
eend "${return_code}" |
188 |
fi |
189 |
- unset site_packages_absolute_dirs site_packages_absolute_files |
190 |
+ unset dirs files |
191 |
done |
192 |
|
193 |
if _python_package_supporting_installation_for_multiple_python_abis; then |
194 |
@@ -2459,7 +2483,7 @@ |
195 |
_python_check_python_pkg_setup_execution |
196 |
_python_initialize_prefix_variables |
197 |
|
198 |
- local dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir |
199 |
+ local allow_evaluated_non_sitedir_paths="0" dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir |
200 |
|
201 |
# Check if phase is pkg_postrm(). |
202 |
[[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase" |
203 |
@@ -2480,6 +2504,29 @@ |
204 |
# Strip trailing slash from EROOT. |
205 |
root="${EROOT%/}" |
206 |
|
207 |
+ while (($#)); do |
208 |
+ case "$1" in |
209 |
+ --allow-evaluated-non-sitedir-paths) |
210 |
+ allow_evaluated_non_sitedir_paths="1" |
211 |
+ ;; |
212 |
+ --) |
213 |
+ shift |
214 |
+ break |
215 |
+ ;; |
216 |
+ -*) |
217 |
+ die "${FUNCNAME}(): Unrecognized option '$1'" |
218 |
+ ;; |
219 |
+ *) |
220 |
+ break |
221 |
+ ;; |
222 |
+ esac |
223 |
+ shift |
224 |
+ done |
225 |
+ |
226 |
+ if [[ "${allow_evaluated_non_sitedir_paths}" == "1" ]] && ! _python_package_supporting_installation_for_multiple_python_abis; then |
227 |
+ die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" |
228 |
+ fi |
229 |
+ |
230 |
if [[ "$#" -gt 0 ]]; then |
231 |
if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then |
232 |
while (($#)); do |
233 |
@@ -2489,9 +2536,18 @@ |
234 |
die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories" |
235 |
elif [[ "$1" =~ ^/ ]]; then |
236 |
if _python_package_supporting_installation_for_multiple_python_abis; then |
237 |
- die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" |
238 |
+ if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then |
239 |
+ die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" |
240 |
+ fi |
241 |
+ if [[ "$1" != *\$* ]]; then |
242 |
+ die "${FUNCNAME}(): '$1' has invalid syntax" |
243 |
+ fi |
244 |
+ for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do |
245 |
+ eval "search_paths+=(\"\${root}$1\")" |
246 |
+ done |
247 |
+ else |
248 |
+ search_paths+=("${root}$1") |
249 |
fi |
250 |
- search_paths+=("${root}$1") |
251 |
else |
252 |
for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do |
253 |
search_paths+=("${root}$(python_get_sitedir)/$1") |