Gentoo Archives: gentoo-commits

From: "Arfrever Frehtes Taifersar Arahesis (arfrever)" <arfrever@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
Date: Mon, 25 Oct 2010 11:54:28
Message-Id: 20101025115419.8BF5D20051@flycatcher.gentoo.org
1 arfrever 10/10/25 11:54:19
2
3 Modified: python.eclass
4 Log:
5 Set IUSE in EAPI >=4.
6 Rename _parse_PYTHON_DEPEND() to _python_parse_PYTHON_DEPEND() and unset it after its using.
7 Ban NEED_PYTHON variable.
8 Add python_abi_depend().
9 Fix exporting of python_pkg_setup() in EAPI >=4.
10 Update and improve _python_calculate_PYTHON_ABIS().
11 Support EAPI="0" in python_get_implementational_package().
12 Use non-deprecated parts of python_mod_optimize() and python_mod_cleanup() for dev-lang/python and sys-apps/portage.
13 Disallow not passing of paths to Python modules to python_mod_optimize() and python_mod_cleanup().
14 Fix a typo in python_mod_optimize().
15 Ban python_mod_compile().
16
17 Revision Changes Path
18 1.104 eclass/python.eclass
19
20 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.104&view=markup
21 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.104&content-type=text/plain
22 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.103&r2=1.104
23
24 Index: python.eclass
25 ===================================================================
26 RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
27 retrieving revision 1.103
28 retrieving revision 1.104
29 diff -u -r1.103 -r1.104
30 --- python.eclass 3 Oct 2010 00:38:13 -0000 1.103
31 +++ python.eclass 25 Oct 2010 11:54:19 -0000 1.104
32 @@ -1,6 +1,6 @@
33 # Copyright 1999-2010 Gentoo Foundation
34 # Distributed under the terms of the GNU General Public License v2
35 -# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.103 2010/10/03 00:38:13 arfrever Exp $
36 +# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.104 2010/10/25 11:54:19 arfrever Exp $
37
38 # @ECLASS: python.eclass
39 # @MAINTAINER:
40 @@ -18,6 +18,36 @@
41 _CPYTHON2_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
42 _CPYTHON3_SUPPORTED_ABIS=(3.0 3.1 3.2)
43 _JYTHON_SUPPORTED_ABIS=(2.5-jython)
44 +_PYTHON_SUPPORTED_ABIS=(${_CPYTHON2_SUPPORTED_ABIS[@]} ${_CPYTHON3_SUPPORTED_ABIS[@]} ${_JYTHON_SUPPORTED_ABIS[@]})
45 +
46 +# ================================================================================================
47 +# ===================================== HANDLING OF METADATA =====================================
48 +# ================================================================================================
49 +
50 +_python_set_IUSE() {
51 + local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI
52 +
53 + _PYTHON_ABIS_USE_FLAGS=""
54 + restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}"
55 +
56 + for PYTHON_ABI in "${_PYTHON_SUPPORTED_ABIS[@]}"; do
57 + support_ABI="1"
58 + while read restricted_ABI; do
59 + if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
60 + support_ABI="0"
61 + break
62 + fi
63 + done <<< "${restricted_ABIs}"
64 + [[ "${support_ABI}" == "1" ]] && _PYTHON_ABIS_USE_FLAGS+="${_PYTHON_ABIS_USE_FLAGS:+ }python_abis_${PYTHON_ABI}"
65 + done
66 +
67 + IUSE="${_PYTHON_ABIS_USE_FLAGS}"
68 +}
69 +
70 +if ! has "${EAPI:-0}" 0 1 2 3 && [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
71 + _python_set_IUSE
72 +fi
73 +unset -f _python_set_IUSE
74
75 # @ECLASS-VARIABLE: PYTHON_DEPEND
76 # @DESCRIPTION:
77 @@ -29,7 +59,7 @@
78 # minimal_version: <minimal_major_version.minimal_minor_version>
79 # maximal_version: <maximal_major_version.maximal_minor_version>
80
81 -_parse_PYTHON_DEPEND() {
82 +_python_parse_PYTHON_DEPEND() {
83 local major_version maximal_version minimal_version python_all="0" python_maximal_version python_minimal_version python_versions=() python2="0" python2_maximal_version python2_minimal_version python3="0" python3_maximal_version python3_minimal_version USE_flag= version_components_group version_components_group_regex version_components_groups
84
85 version_components_group_regex="(2|3|\*)(:([[:digit:]]+\.[[:digit:]]+)?(:([[:digit:]]+\.[[:digit:]]+)?)?)?"
86 @@ -155,31 +185,17 @@
87 DEPEND=">=app-admin/eselect-python-20091230"
88 RDEPEND="${DEPEND}"
89
90 -if [[ -n "${PYTHON_DEPEND}" && -n "${NEED_PYTHON}" ]]; then
91 - die "PYTHON_DEPEND and NEED_PYTHON cannot be set simultaneously"
92 -elif [[ -n "${PYTHON_DEPEND}" ]]; then
93 - _parse_PYTHON_DEPEND
94 -elif [[ -n "${NEED_PYTHON}" ]]; then
95 - if ! has "${EAPI:-0}" 0 1 2; then
96 - eerror "Use PYTHON_DEPEND variable instead of NEED_PYTHON variable."
97 - die "NEED_PYTHON variable cannot be used in this EAPI"
98 - fi
99 -
100 - ewarn
101 - ewarn "\"${EBUILD}\":"
102 - ewarn "Deprecation Warning: NEED_PYTHON variable is deprecated and will be banned on 2010-10-01."
103 - ewarn "Use PYTHON_DEPEND variable instead of NEED_PYTHON variable."
104 - ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
105 - ewarn
106 -
107 - unset _BOLD _NORMAL
108 -
109 - _PYTHON_ATOMS=(">=dev-lang/python-${NEED_PYTHON}")
110 - DEPEND+="${DEPEND:+ }${_PYTHON_ATOMS[@]}"
111 - RDEPEND+="${RDEPEND:+ }${_PYTHON_ATOMS[@]}"
112 +if [[ -n "${PYTHON_DEPEND}" ]]; then
113 + _python_parse_PYTHON_DEPEND
114 else
115 _PYTHON_ATOMS=("dev-lang/python")
116 fi
117 +unset -f _python_parse_PYTHON_DEPEND
118 +
119 +if [[ -n "${NEED_PYTHON}" ]]; then
120 + eerror "Use PYTHON_DEPEND variable instead of NEED_PYTHON variable."
121 + die "NEED_PYTHON variable is banned"
122 +fi
123
124 # @ECLASS-VARIABLE: PYTHON_USE_WITH
125 # @DESCRIPTION:
126 @@ -223,6 +239,135 @@
127
128 unset _PYTHON_ATOMS
129
130 +# @FUNCTION: python_abi_depend
131 +# @USAGE: [-e|--exclude-ABIs Python_ABIs] [-i|--include-ABIs Python_ABIs] [--] <dependency_atom> [dependency_atoms]
132 +# @DESCRIPTION:
133 +# Print dependency atoms with USE dependencies for Python ABIs added.
134 +# If --exclude-ABIs option is specified, then Python ABIs matching its argument are not used.
135 +# If --include-ABIs option is specified, then only Python ABIs matching its argument are used.
136 +# --exclude-ABIs and --include-ABIs options cannot be specified simultaneously.
137 +python_abi_depend() {
138 + local atom atom_index atoms=() exclude_ABIs="0" excluded_ABI excluded_ABIs include_ABIs="0" included_ABI included_ABIs support_ABI USE_dependencies USE_flag USE_flag_index USE_flags=()
139 +
140 + if has "${EAPI:-0}" 0 1 2 3; then
141 + die "${FUNCNAME}() cannot be used in this EAPI"
142 + fi
143 +
144 + if [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
145 + die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
146 + fi
147 +
148 + while (($#)); do
149 + case "$1" in
150 + -e|--exclude-ABIs)
151 + exclude_ABIs="1"
152 + excluded_ABIs="${2// /$'\n'}"
153 + shift
154 + ;;
155 + -i|--include-ABIs)
156 + include_ABIs="1"
157 + included_ABIs="${2// /$'\n'}"
158 + shift
159 + ;;
160 + --)
161 + shift
162 + break
163 + ;;
164 + -*)
165 + die "${FUNCNAME}(): Unrecognized option '$1'"
166 + ;;
167 + *)
168 + break
169 + ;;
170 + esac
171 + shift
172 + done
173 +
174 + if [[ "${exclude_ABIs}" == "1" && "${include_ABIs}" == "1" ]]; then
175 + die "${FUNCNAME}(): '--exclude-ABIs' and '--include-ABIs' options cannot be specified simultaneously"
176 + fi
177 +
178 + if [[ "$#" -eq 0 ]]; then
179 + die "${FUNCNAME}(): Missing dependency atoms"
180 + fi
181 +
182 + atoms=("$@")
183 +
184 + if [[ "${exclude_ABIs}" == "0" && "${include_ABIs}" == "0" ]]; then
185 + USE_dependencies="$(printf ",%s?" ${_PYTHON_ABIS_USE_FLAGS})"
186 + USE_dependencies="${USE_dependencies#,}"
187 +
188 + for atom_index in "${!atoms[@]}"; do
189 + atom="${atoms[${atom_index}]}"
190 +
191 + if [[ "${atom}" == *"["*"]" ]]; then
192 + echo -n "${atom%]},"
193 + else
194 + echo -n "${atom}["
195 + fi
196 + echo -n "${USE_dependencies}]"
197 +
198 + if [[ "${atom_index}" -ne $((${#atoms[@]} - 1)) ]]; then
199 + echo -n " "
200 + fi
201 + done
202 + else
203 + if [[ "${exclude_ABIs}" == "1" ]]; then
204 + for USE_flag in ${_PYTHON_ABIS_USE_FLAGS}; do
205 + while read excluded_ABI; do
206 + support_ABI="1"
207 + if [[ "${USE_flag}" == python_abis_${excluded_ABI} ]]; then
208 + support_ABI="0"
209 + break
210 + fi
211 + done <<< "${excluded_ABIs}"
212 + [[ "${support_ABI}" == "1" ]] && USE_flags+=("${USE_flag}")
213 + done
214 + elif [[ "${include_ABIs}" == "1" ]]; then
215 + for USE_flag in ${_PYTHON_ABIS_USE_FLAGS}; do
216 + while read included_ABI; do
217 + support_ABI="0"
218 + if [[ "${USE_flag}" == python_abis_${included_ABI} ]]; then
219 + support_ABI="1"
220 + break
221 + fi
222 + done <<< "${included_ABIs}"
223 + [[ "${support_ABI}" == "1" ]] && USE_flags+=("${USE_flag}")
224 + done
225 + else
226 + die "${FUNCNAME}(): Internal error"
227 + fi
228 +
229 + for USE_flag_index in "${!USE_flags[@]}"; do
230 + USE_flag="${USE_flags[${USE_flag_index}]}"
231 + USE_dependencies="${USE_flag}"
232 +
233 + echo -n "${USE_flag}? ( "
234 +
235 + for atom_index in "${!atoms[@]}"; do
236 + atom="${atoms[${atom_index}]}"
237 +
238 + if [[ "${atom}" == *"["*"]" ]]; then
239 + echo -n "${atom%]},"
240 + else
241 + echo -n "${atom}["
242 + fi
243 + echo -n "${USE_dependencies}]"
244 +
245 + if [[ "${atom_index}" -ne $((${#atoms[@]} - 1)) ]]; then
246 + echo -n " "
247 + fi
248 + done
249 +
250 + echo -n " )"
251 +
252 + if [[ "${USE_flag_index}" -ne $((${#USE_flags[@]} - 1)) ]]; then
253 + echo -n " "
254 + fi
255 + done
256 + fi
257 +}
258 +
259 # ================================================================================================
260 # =================================== MISCELLANEOUS FUNCTIONS ====================================
261 # ================================================================================================
262 @@ -410,7 +555,7 @@
263 PYTHON_PKG_SETUP_EXECUTED="1"
264 }
265
266 -if ! has "${EAPI:-0}" 0 1 2 3 || has "${EAPI:-0}" 2 3 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then
267 +if ! has "${EAPI:-0}" 0 1 2 3 || { has "${EAPI:-0}" 2 3 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; }; then
268 EXPORT_FUNCTIONS pkg_setup
269 fi
270
271 @@ -603,7 +748,9 @@
272 fi
273 fi
274
275 -unset PYTHON_ABIS
276 +if has "${EAPI:-0}" 0 1 2 3; then
277 + unset PYTHON_ABIS
278 +fi
279
280 _python_calculate_PYTHON_ABIS() {
281 if ! _python_package_supporting_installation_for_multiple_python_abis; then
282 @@ -612,10 +759,10 @@
283
284 _python_initial_sanity_checks
285
286 - # USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 5.
287 - if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then
288 - local PYTHON_ABI restricted_ABI support_ABI supported_PYTHON_ABIS=
289 - PYTHON_ABI_SUPPORTED_VALUES="${_CPYTHON2_SUPPORTED_ABIS[@]} ${_CPYTHON3_SUPPORTED_ABIS[@]} ${_JYTHON_SUPPORTED_ABIS[@]}"
290 + if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then
291 + local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI supported_PYTHON_ABIS
292 +
293 + restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}"
294
295 if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
296 local cpython_enabled="0"
297 @@ -625,7 +772,7 @@
298 fi
299
300 for PYTHON_ABI in ${USE_PYTHON}; do
301 - if ! has "${PYTHON_ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
302 + if ! has "${PYTHON_ABI}" ${_PYTHON_SUPPORTED_ABIS[@]}; then
303 die "USE_PYTHON variable contains invalid value '${PYTHON_ABI}'"
304 fi
305
306 @@ -634,12 +781,12 @@
307 fi
308
309 support_ABI="1"
310 - for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
311 + while read restricted_ABI; do
312 if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
313 support_ABI="0"
314 break
315 fi
316 - done
317 + done <<< "${restricted_ABIs}"
318 [[ "${support_ABI}" == "1" ]] && export PYTHON_ABIS+="${PYTHON_ABIS:+ }${PYTHON_ABI}"
319 done
320
321 @@ -668,19 +815,19 @@
322
323 for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}"; do
324 support_python_major_version="1"
325 - for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
326 + while read restricted_ABI; do
327 if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
328 support_python_major_version="0"
329 fi
330 - done
331 + done <<< "${restricted_ABIs}"
332 [[ "${support_python_major_version}" == "1" ]] && break
333 done
334 if [[ "${support_python_major_version}" == "1" ]]; then
335 - for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
336 + while read restricted_ABI; do
337 if [[ "${python2_version}" == ${restricted_ABI} ]]; then
338 die "Active version of Python 2 is not supported by ${CATEGORY}/${PF}"
339 fi
340 - done
341 + done <<< "${restricted_ABIs}"
342 else
343 python2_version=""
344 fi
345 @@ -695,19 +842,19 @@
346
347 for PYTHON_ABI in "${_CPYTHON3_SUPPORTED_ABIS[@]}"; do
348 support_python_major_version="1"
349 - for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
350 + while read restricted_ABI; do
351 if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
352 support_python_major_version="0"
353 fi
354 - done
355 + done <<< "${restricted_ABIs}"
356 [[ "${support_python_major_version}" == "1" ]] && break
357 done
358 if [[ "${support_python_major_version}" == "1" ]]; then
359 - for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
360 + while read restricted_ABI; do
361 if [[ "${python3_version}" == ${restricted_ABI} ]]; then
362 die "Active version of Python 3 is not supported by ${CATEGORY}/${PF}"
363 fi
364 - done
365 + done <<< "${restricted_ABIs}"
366 else
367 python3_version=""
368 fi
369 @@ -1564,10 +1711,18 @@
370 fi
371 fi
372
373 - if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
374 - echo "dev-lang/python:${PYTHON_ABI}"
375 - elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
376 - echo "dev-java/jython:${PYTHON_ABI%-jython}"
377 + if [[ "${EAPI:-0}" == "0" ]]; then
378 + if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
379 + echo "=dev-lang/python-${PYTHON_ABI}*"
380 + elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
381 + echo "=dev-java/jython-${PYTHON_ABI%-jython}*"
382 + fi
383 + else
384 + if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
385 + echo "dev-lang/python:${PYTHON_ABI}"
386 + elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
387 + echo "dev-java/jython:${PYTHON_ABI%-jython}"
388 + fi
389 fi
390 }
391
392 @@ -2116,7 +2271,7 @@
393 _python_initialize_prefix_variables
394 _python_set_color_variables
395
396 - [[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_compile|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage"
397 + [[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage"
398
399 local base_module_name compiled_file compiled_files=() dir path py_file root
400
401 @@ -2203,15 +2358,10 @@
402 }
403
404 # @FUNCTION: python_mod_optimize
405 -# @USAGE: [options] [directory|file]
406 +# @USAGE: [--allow-evaluated-non-sitedir-paths] [-d directory] [-f] [-l] [-q] [-x regular_expression] [--] <file|directory> [files|directories]
407 # @DESCRIPTION:
408 -# If no arguments supplied, it will recompile not recursively all modules
409 -# under sys.path (eg. /usr/lib/python2.6, /usr/lib/python2.6/site-packages).
410 -#
411 -# If supplied with arguments, it will recompile all modules recursively
412 -# in the supplied directory.
413 -#
414 -# Options passed to this function are passed to compileall.py.
415 +# Byte-compile specified Python modules.
416 +# -d, -f, -l, -q and -x options passed to this function are passed to compileall.py.
417 #
418 # This function can be used only in pkg_postinst() phase.
419 python_mod_optimize() {
420 @@ -2221,7 +2371,7 @@
421 # Check if phase is pkg_postinst().
422 [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
423
424 - if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
425 + if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis || _python_implementation || [[ "${CATEGORY}/${PN}" == "sys-apps/portage" ]]; then
426 # PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs.
427 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=()
428
429 @@ -2272,11 +2422,7 @@
430 fi
431
432 if [[ "$#" -eq 0 ]]; then
433 - ewarn
434 - ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
435 - ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
436 - ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
437 - ewarn
438 + die "${FUNCNAME}(): Missing files or directories"
439 fi
440
441 while (($#)); do
442 @@ -2388,12 +2534,18 @@
443 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
444 "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
445 fi
446 - _python_clean_compiled_modules "${other_dirs[@]}"
447 + _python_clean_compiled_modules "${other_files[@]}"
448 fi
449 eend "${return_code}"
450 fi
451 else
452 # Deprecated part of python_mod_optimize()
453 + # ewarn
454 + # ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
455 + # ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-06-01."
456 + # ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
457 + # ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
458 + # ewarn
459
460 local myroot mydirs=() myfiles=() myopts=() return_code="0"
461
462 @@ -2425,11 +2577,7 @@
463 done
464
465 if [[ "$#" -eq 0 ]]; then
466 - ewarn
467 - ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
468 - ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
469 - ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
470 - ewarn
471 + die "${FUNCNAME}(): Missing files or directories"
472 fi
473
474 while (($#)); do
475 @@ -2438,8 +2586,7 @@
476 elif [[ -d "${myroot}/${1#/}" ]]; then
477 mydirs+=("${myroot}/${1#/}")
478 elif [[ -f "${myroot}/${1#/}" ]]; then
479 - # Files are passed to python_mod_compile which is EROOT-aware
480 - myfiles+=("$1")
481 + myfiles+=("${myroot}/${1#/}")
482 elif [[ -e "${myroot}/${1#/}" ]]; then
483 eerror "${FUNCNAME}(): ${myroot}/${1#/} is not a regular file or directory"
484 else
485 @@ -2461,7 +2608,9 @@
486 fi
487
488 if ((${#myfiles[@]})); then
489 - python_mod_compile "${myfiles[@]}"
490 + "$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" || return_code="1"
491 + "$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null || return_code="1"
492 + _python_clean_compiled_modules "${myfiles[@]}"
493 fi
494
495 eend "${return_code}"
496 @@ -2469,14 +2618,9 @@
497 }
498
499 # @FUNCTION: python_mod_cleanup
500 -# @USAGE: [directory|file]
501 +# @USAGE: [--allow-evaluated-non-sitedir-paths] [--] <file|directory> [files|directories]
502 # @DESCRIPTION:
503 -# Run with optional arguments, where arguments are Python modules. If none given,
504 -# it will look in /usr/lib/python[0-9].[0-9].
505 -#
506 -# It will recursively scan all compiled Python modules in the directories and
507 -# determine if they are orphaned (i.e. their corresponding .py files are missing.)
508 -# If they are, then it will remove their corresponding .pyc and .pyo files.
509 +# Delete orphaned byte-compiled Python modules corresponding to specified Python modules.
510 #
511 # This function can be used only in pkg_postrm() phase.
512 python_mod_cleanup() {
513 @@ -2527,61 +2671,48 @@
514 die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
515 fi
516
517 - if [[ "$#" -gt 0 ]]; then
518 - if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
519 - while (($#)); do
520 - if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
521 - die "${FUNCNAME}(): Invalid argument '$1'"
522 - elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
523 - die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
524 - elif [[ "$1" =~ ^/ ]]; then
525 - if _python_package_supporting_installation_for_multiple_python_abis; then
526 - if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
527 - die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
528 - fi
529 - if [[ "$1" != *\$* ]]; then
530 - die "${FUNCNAME}(): '$1' has invalid syntax"
531 - fi
532 - for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
533 - eval "search_paths+=(\"\${root}$1\")"
534 - done
535 - else
536 - search_paths+=("${root}$1")
537 + if [[ "$#" -eq 0 ]]; then
538 + die "${FUNCNAME}(): Missing files or directories"
539 + fi
540 +
541 + if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis || _python_implementation || [[ "${CATEGORY}/${PN}" == "sys-apps/portage" ]]; then
542 + while (($#)); do
543 + if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
544 + die "${FUNCNAME}(): Invalid argument '$1'"
545 + elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
546 + die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
547 + elif [[ "$1" =~ ^/ ]]; then
548 + if _python_package_supporting_installation_for_multiple_python_abis; then
549 + if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
550 + die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
551 + fi
552 + if [[ "$1" != *\$* ]]; then
553 + die "${FUNCNAME}(): '$1' has invalid syntax"
554 fi
555 - else
556 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
557 - search_paths+=("${root}$(python_get_sitedir)/$1")
558 + eval "search_paths+=(\"\${root}$1\")"
559 done
560 + else
561 + search_paths+=("${root}$1")
562 fi
563 - shift
564 - done
565 - else
566 - # Deprecated part of python_mod_cleanup()
567 -
568 - search_paths=("${@#/}")
569 - search_paths=("${search_paths[@]/#/${root}/}")
570 - fi
571 - else
572 - ewarn
573 - ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
574 - ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
575 - ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
576 - ewarn
577 -
578 - for dir in "${root}"/usr/lib*; do
579 - if [[ -d "${dir}" && ! -L "${dir}" ]]; then
580 - for sitedir in "${dir}"/python*/site-packages; do
581 - if [[ -d "${sitedir}" ]]; then
582 - search_paths+=("${sitedir}")
583 - fi
584 + else
585 + for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
586 + search_paths+=("${root}$(python_get_sitedir)/$1")
587 done
588 fi
589 + shift
590 done
591 - for sitedir in "${root}"/usr/share/jython-*/Lib/site-packages; do
592 - if [[ -d "${sitedir}" ]]; then
593 - search_paths+=("${sitedir}")
594 - fi
595 - done
596 + else
597 + # Deprecated part of python_mod_cleanup()
598 + # ewarn
599 + # ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
600 + # ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-06-01."
601 + # ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
602 + # ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
603 + # ewarn
604 +
605 + search_paths=("${@#/}")
606 + search_paths=("${search_paths[@]/#/${root}/}")
607 fi
608
609 _python_clean_compiled_modules "${search_paths[@]}"
610 @@ -2609,52 +2740,8 @@
611 die "${FUNCNAME}() is banned"
612 }
613
614 -# @FUNCTION: python_mod_compile
615 -# @USAGE: <file> [more files ...]
616 -# @DESCRIPTION:
617 -# Given filenames, it will pre-compile the module's .pyc and .pyo.
618 -# This function can be used only in pkg_postinst() phase.
619 -#
620 -# Example:
621 -# python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
622 -#
623 +# Scheduled for deletion on 2011-04-01.
624 python_mod_compile() {
625 - if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
626 - eerror "Use python_mod_optimize() instead of ${FUNCNAME}()."
627 - die "${FUNCNAME}() cannot be used in this EAPI"
628 - fi
629 -
630 - _python_initialize_prefix_variables
631 - _python_set_color_variables
632 -
633 - if [[ "${FUNCNAME[1]}" != "python_mod_optimize" ]]; then
634 - ewarn
635 - ewarn "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01."
636 - ewarn "Use python_mod_optimize() instead of ${FUNCNAME}()."
637 - ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
638 - ewarn
639 - fi
640 -
641 - local f myroot myfiles=()
642 -
643 - # Check if phase is pkg_postinst()
644 - [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
645 -
646 - # strip trailing slash
647 - myroot="${EROOT%/}"
648 -
649 - # respect EROOT
650 - for f in "$@"; do
651 - [[ -f "${myroot}/${f}" ]] && myfiles+=("${myroot}/${f}")
652 - done
653 -
654 - PYTHON_ABI="$(PYTHON --ABI)"
655 -
656 - if ((${#myfiles[@]})); then
657 - "$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}"
658 - "$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null
659 - _python_clean_compiled_modules "${myfiles[@]}"
660 - else
661 - ewarn "No files to compile!"
662 - fi
663 + eerror "Use python_mod_optimize() instead of ${FUNCNAME}()."
664 + die "${FUNCNAME}() is banned"
665 }