1 |
djc 11/07/04 11:00:52 |
2 |
|
3 |
Modified: python.eclass |
4 |
Log: |
5 |
Fix coding style in some functions for consistency with other functions. |
6 |
(Patch by Arfrever. Backported from python overlay.) |
7 |
|
8 |
Revision Changes Path |
9 |
1.114 eclass/python.eclass |
10 |
|
11 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.114&view=markup |
12 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.114&content-type=text/plain |
13 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.113&r2=1.114 |
14 |
|
15 |
Index: python.eclass |
16 |
=================================================================== |
17 |
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v |
18 |
retrieving revision 1.113 |
19 |
retrieving revision 1.114 |
20 |
diff -u -r1.113 -r1.114 |
21 |
--- python.eclass 4 Jul 2011 10:59:25 -0000 1.113 |
22 |
+++ python.eclass 4 Jul 2011 11:00:52 -0000 1.114 |
23 |
@@ -1,6 +1,6 @@ |
24 |
# Copyright 1999-2011 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.113 2011/07/04 10:59:25 djc Exp $ |
27 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.114 2011/07/04 11:00:52 djc Exp $ |
28 |
|
29 |
# @ECLASS: python.eclass |
30 |
# @MAINTAINER: |
31 |
@@ -360,11 +360,10 @@ |
32 |
# |
33 |
# This function is exported in EAPI 2 and 3 when PYTHON_USE_WITH or PYTHON_USE_WITH_OR variable |
34 |
# is set and always in EAPI >=4. Calling of this function is mandatory in EAPI >=4. |
35 |
-# |
36 |
-# This function can be used only in pkg_setup() phase. |
37 |
python_pkg_setup() { |
38 |
- # Check if phase is pkg_setup(). |
39 |
- [[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase" |
40 |
+ if [[ "${EBUILD_PHASE}" != "setup" ]]; then |
41 |
+ die "${FUNCNAME}() can be used only in pkg_setup() phase" |
42 |
+ fi |
43 |
|
44 |
if [[ "$#" -ne 0 ]]; then |
45 |
die "${FUNCNAME}() does not accept arguments" |
46 |
@@ -515,15 +514,18 @@ |
47 |
# @USAGE: [-q|--quiet] |
48 |
# @DESCRIPTION: |
49 |
# Delete needless files in installation image. |
50 |
+# |
51 |
+# This function can be used only in src_install() phase. |
52 |
python_clean_installation_image() { |
53 |
+ if [[ "${EBUILD_PHASE}" != "install" ]]; then |
54 |
+ die "${FUNCNAME}() can be used only in src_install() phase" |
55 |
+ fi |
56 |
+ |
57 |
_python_check_python_pkg_setup_execution |
58 |
_python_initialize_prefix_variables |
59 |
|
60 |
local file files=() quiet="0" |
61 |
|
62 |
- # Check if phase is src_install(). |
63 |
- [[ "${EBUILD_PHASE}" != "install" ]] && die "${FUNCNAME}() can be used only in src_install() phase" |
64 |
- |
65 |
while (($#)); do |
66 |
case "$1" in |
67 |
-q|--quiet) |
68 |
@@ -586,15 +588,19 @@ |
69 |
# @ECLASS-VARIABLE: PYTHON_EXPORT_PHASE_FUNCTIONS |
70 |
# @DESCRIPTION: |
71 |
# Set this to export phase functions for the following ebuild phases: |
72 |
-# src_prepare, src_configure, src_compile, src_test, src_install. |
73 |
+# src_prepare(), src_configure(), src_compile(), src_test(), src_install(). |
74 |
if ! has "${EAPI:-0}" 0 1; then |
75 |
python_src_prepare() { |
76 |
- _python_check_python_pkg_setup_execution |
77 |
+ if [[ "${EBUILD_PHASE}" != "prepare" ]]; then |
78 |
+ die "${FUNCNAME}() can be used only in src_prepare() phase" |
79 |
+ fi |
80 |
|
81 |
if ! _python_package_supporting_installation_for_multiple_python_abis; then |
82 |
die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" |
83 |
fi |
84 |
|
85 |
+ _python_check_python_pkg_setup_execution |
86 |
+ |
87 |
if [[ "$#" -ne 0 ]]; then |
88 |
die "${FUNCNAME}() does not accept arguments" |
89 |
fi |
90 |
@@ -604,18 +610,26 @@ |
91 |
|
92 |
for python_default_function in src_configure src_compile src_test; do |
93 |
eval "python_${python_default_function}() { |
94 |
- _python_check_python_pkg_setup_execution |
95 |
+ if [[ \"\${EBUILD_PHASE}\" != \"${python_default_function#src_}\" ]]; then |
96 |
+ die \"\${FUNCNAME}() can be used only in ${python_default_function}() phase\" |
97 |
+ fi |
98 |
|
99 |
if ! _python_package_supporting_installation_for_multiple_python_abis; then |
100 |
die \"\${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs\" |
101 |
fi |
102 |
|
103 |
+ _python_check_python_pkg_setup_execution |
104 |
+ |
105 |
python_execute_function -d -s -- \"\$@\" |
106 |
}" |
107 |
done |
108 |
unset python_default_function |
109 |
|
110 |
python_src_install() { |
111 |
+ if [[ "${EBUILD_PHASE}" != "install" ]]; then |
112 |
+ die "${FUNCNAME}() can be used only in src_install() phase" |
113 |
+ fi |
114 |
+ |
115 |
if ! _python_package_supporting_installation_for_multiple_python_abis; then |
116 |
die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" |
117 |
fi |
118 |
@@ -690,7 +704,7 @@ |
119 |
die "USE_PYTHON variable does not enable any CPython ABI" |
120 |
fi |
121 |
else |
122 |
- local python_version python2_version= python3_version= support_python_major_version |
123 |
+ local python_version python2_version python3_version support_python_major_version |
124 |
|
125 |
if ! has_version "dev-lang/python"; then |
126 |
die "${FUNCNAME}(): 'dev-lang/python' is not installed" |
127 |
@@ -830,15 +844,14 @@ |
128 |
# Execute specified function for each value of PYTHON_ABIS, optionally passing additional |
129 |
# arguments. The specified function can use PYTHON_ABI and BUILDDIR variables. |
130 |
python_execute_function() { |
131 |
- _python_check_python_pkg_setup_execution |
132 |
- |
133 |
if ! _python_package_supporting_installation_for_multiple_python_abis; then |
134 |
die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" |
135 |
fi |
136 |
|
137 |
+ _python_check_python_pkg_setup_execution |
138 |
_python_set_color_variables |
139 |
|
140 |
- local action action_message action_message_template= default_function="0" failure_message failure_message_template= final_ABI="0" function iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" return_code separate_build_dirs="0" source_dir= |
141 |
+ local action action_message action_message_template default_function="0" failure_message failure_message_template final_ABI="0" function iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" return_code separate_build_dirs="0" source_dir |
142 |
|
143 |
while (($#)); do |
144 |
case "$1" in |
145 |
@@ -1063,12 +1076,12 @@ |
146 |
# @DESCRIPTION: |
147 |
# Copy unpacked sources of current package to separate build directory for each Python ABI. |
148 |
python_copy_sources() { |
149 |
- _python_check_python_pkg_setup_execution |
150 |
- |
151 |
if ! _python_package_supporting_installation_for_multiple_python_abis; then |
152 |
die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" |
153 |
fi |
154 |
|
155 |
+ _python_check_python_pkg_setup_execution |
156 |
+ |
157 |
local dir dirs=() PYTHON_ABI |
158 |
|
159 |
if [[ "$#" -eq 0 ]]; then |
160 |
@@ -1094,13 +1107,18 @@ |
161 |
# Generate wrapper scripts. Existing files are overwritten only with --force option. |
162 |
# If --respect-EPYTHON option is specified, then generated wrapper scripts will |
163 |
# respect EPYTHON variable at run time. |
164 |
+# |
165 |
+# This function can be used only in src_install() phase. |
166 |
python_generate_wrapper_scripts() { |
167 |
- _python_check_python_pkg_setup_execution |
168 |
+ if [[ "${EBUILD_PHASE}" != "install" ]]; then |
169 |
+ die "${FUNCNAME}() can be used only in src_install() phase" |
170 |
+ fi |
171 |
|
172 |
if ! _python_package_supporting_installation_for_multiple_python_abis; then |
173 |
die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" |
174 |
fi |
175 |
|
176 |
+ _python_check_python_pkg_setup_execution |
177 |
_python_initialize_prefix_variables |
178 |
|
179 |
local eselect_python_option file force="0" quiet="0" PYTHON_ABI PYTHON_ABIS_list python2_enabled="0" python3_enabled="0" respect_EPYTHON="0" |
180 |
@@ -1341,15 +1359,22 @@ |
181 |
# @USAGE: [-q|--quiet] [--] <intermediate_installation_images_directory> |
182 |
# @DESCRIPTION: |
183 |
# Merge intermediate installation images into installation image. |
184 |
+# |
185 |
+# This function can be used only in src_install() phase. |
186 |
python_merge_intermediate_installation_images() { |
187 |
+ if [[ "${EBUILD_PHASE}" != "install" ]]; then |
188 |
+ die "${FUNCNAME}() can be used only in src_install() phase" |
189 |
+ fi |
190 |
+ |
191 |
+ if ! _python_package_supporting_installation_for_multiple_python_abis; then |
192 |
+ die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" |
193 |
+ fi |
194 |
+ |
195 |
_python_check_python_pkg_setup_execution |
196 |
_python_initialize_prefix_variables |
197 |
|
198 |
local b file files=() intermediate_installation_images_directory PYTHON_ABI quiet="0" regex shebang version_executable wrapper_scripts=() wrapper_scripts_set=() |
199 |
|
200 |
- # Check if phase is src_install(). |
201 |
- [[ "${EBUILD_PHASE}" != "install" ]] && die "${FUNCNAME}() can be used only in src_install() phase" |
202 |
- |
203 |
while (($#)); do |
204 |
case "$1" in |
205 |
-q|--quiet) |
206 |
@@ -1524,8 +1549,9 @@ |
207 |
# |
208 |
# This function can be used only in pkg_setup() phase. |
209 |
python_set_active_version() { |
210 |
- # Check if phase is pkg_setup(). |
211 |
- [[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase" |
212 |
+ if [[ "${EBUILD_PHASE}" != "setup" ]]; then |
213 |
+ die "${FUNCNAME}() can be used only in pkg_setup() phase" |
214 |
+ fi |
215 |
|
216 |
if _python_package_supporting_installation_for_multiple_python_abis; then |
217 |
die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" |
218 |
@@ -1575,12 +1601,12 @@ |
219 |
# @DESCRIPTION: Mark current package for rebuilding by python-updater after |
220 |
# switching of active version of Python. |
221 |
python_need_rebuild() { |
222 |
- _python_check_python_pkg_setup_execution |
223 |
- |
224 |
if _python_package_supporting_installation_for_multiple_python_abis; then |
225 |
die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" |
226 |
fi |
227 |
|
228 |
+ _python_check_python_pkg_setup_execution |
229 |
+ |
230 |
if [[ "$#" -ne 0 ]]; then |
231 |
die "${FUNCNAME}() does not accept arguments" |
232 |
fi |
233 |
@@ -2184,7 +2210,7 @@ |
234 |
_python_check_python_pkg_setup_execution |
235 |
_python_set_color_variables |
236 |
|
237 |
- local PYTHONPATH_template= separate_build_dirs= |
238 |
+ local PYTHONPATH_template separate_build_dirs |
239 |
|
240 |
while (($#)); do |
241 |
case "$1" in |
242 |
@@ -2248,7 +2274,7 @@ |
243 |
_python_check_python_pkg_setup_execution |
244 |
_python_set_color_variables |
245 |
|
246 |
- local PYTHONPATH_template= separate_build_dirs= |
247 |
+ local PYTHONPATH_template separate_build_dirs |
248 |
|
249 |
while (($#)); do |
250 |
case "$1" in |
251 |
@@ -2312,7 +2338,7 @@ |
252 |
_python_check_python_pkg_setup_execution |
253 |
_python_set_color_variables |
254 |
|
255 |
- local PYTHONPATH_template= separate_build_dirs= |
256 |
+ local PYTHONPATH_template separate_build_dirs |
257 |
|
258 |
while (($#)); do |
259 |
case "$1" in |
260 |
@@ -2497,12 +2523,13 @@ |
261 |
# |
262 |
# This function can be used only in pkg_postinst() phase. |
263 |
python_mod_optimize() { |
264 |
+ if [[ "${EBUILD_PHASE}" != "postinst" ]]; then |
265 |
+ die "${FUNCNAME}() can be used only in pkg_postinst() phase" |
266 |
+ fi |
267 |
+ |
268 |
_python_check_python_pkg_setup_execution |
269 |
_python_initialize_prefix_variables |
270 |
|
271 |
- # Check if phase is pkg_postinst(). |
272 |
- [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase" |
273 |
- |
274 |
if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis || _python_implementation || [[ "${CATEGORY}/${PN}" == "sys-apps/portage" ]]; then |
275 |
# PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs. |
276 |
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=() |
277 |
@@ -2756,14 +2783,15 @@ |
278 |
# |
279 |
# This function can be used only in pkg_postrm() phase. |
280 |
python_mod_cleanup() { |
281 |
+ if [[ "${EBUILD_PHASE}" != "postrm" ]]; then |
282 |
+ die "${FUNCNAME}() can be used only in pkg_postrm() phase" |
283 |
+ fi |
284 |
+ |
285 |
_python_check_python_pkg_setup_execution |
286 |
_python_initialize_prefix_variables |
287 |
|
288 |
local allow_evaluated_non_sitedir_paths="0" dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir |
289 |
|
290 |
- # Check if phase is pkg_postrm(). |
291 |
- [[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase" |
292 |
- |
293 |
if _python_package_supporting_installation_for_multiple_python_abis; then |
294 |
if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then |
295 |
die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called" |