/[gentoo-x86]/eclass/python-r1.eclass
Gentoo

Contents of /eclass/python-r1.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.47 - (show annotations) (download)
Mon Mar 4 19:28:47 2013 UTC (13 months, 1 week ago) by mgorny
Branch: MAIN
Changes since 1.46: +34 -1 lines
Introduce python_parallel_foreach_impl() and reuse it in distutils-r1.

1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.46 2013/03/04 19:27:58 mgorny Exp $
4
5 # @ECLASS: python-r1
6 # @MAINTAINER:
7 # Python team <python@gentoo.org>
8 # @AUTHOR:
9 # Author: Michał Górny <mgorny@gentoo.org>
10 # Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
11 # @BLURB: A common, simple eclass for Python packages.
12 # @DESCRIPTION:
13 # A common eclass providing helper functions to build and install
14 # packages supporting being installed for multiple Python
15 # implementations.
16 #
17 # This eclass sets correct IUSE and REQUIRED_USE. It exports PYTHON_DEPS
18 # and PYTHON_USEDEP so you can create correct dependencies for your
19 # package easily. It also provides methods to easily run a command for
20 # each enabled Python implementation and duplicate the sources for them.
21 #
22 # Please note that python-r1 will always inherit python-utils-r1 as
23 # well. Thus, all the functions defined there can be used
24 # in the packages using python-r1, and there is no need ever to inherit
25 # both.
26 #
27 # For more information, please see the python-r1 Developer's Guide:
28 # http://www.gentoo.org/proj/en/Python/python-r1/dev-guide.xml
29
30 case "${EAPI:-0}" in
31 0|1|2|3|4)
32 die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
33 ;;
34 5)
35 # EAPI=5 is required for meaningful USE default deps
36 # on USE_EXPAND flags
37 ;;
38 *)
39 die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
40 ;;
41 esac
42
43 if [[ ! ${_PYTHON_R1} ]]; then
44
45 if [[ ${_PYTHON_SINGLE_R1} ]]; then
46 die 'python-r1.eclass can not be used with python-single-r1.eclass.'
47 elif [[ ${_PYTHON_ANY_R1} ]]; then
48 die 'python-r1.eclass can not be used with python-any-r1.eclass.'
49 fi
50
51 inherit multibuild python-utils-r1
52
53 # @ECLASS-VARIABLE: PYTHON_COMPAT
54 # @REQUIRED
55 # @DESCRIPTION:
56 # This variable contains a list of Python implementations the package
57 # supports. It must be set before the `inherit' call. It has to be
58 # an array.
59 #
60 # Example:
61 # @CODE
62 # PYTHON_COMPAT=( python2_5 python2_6 python2_7 )
63 # @CODE
64 #
65 # Please note that you can also use bash brace expansion if you like:
66 # @CODE
67 # PYTHON_COMPAT=( python{2_5,2_6,2_7} )
68 # @CODE
69 if ! declare -p PYTHON_COMPAT &>/dev/null; then
70 if [[ ${CATEGORY}/${PN} == dev-python/python-exec ]]; then
71 PYTHON_COMPAT=( "${_PYTHON_ALL_IMPLS[@]}" )
72 else
73 die 'PYTHON_COMPAT not declared.'
74 fi
75 fi
76
77 # @ECLASS-VARIABLE: PYTHON_REQ_USE
78 # @DEFAULT_UNSET
79 # @DESCRIPTION:
80 # The list of USEflags required to be enabled on the chosen Python
81 # implementations, formed as a USE-dependency string. It should be valid
82 # for all implementations in PYTHON_COMPAT, so it may be necessary to
83 # use USE defaults.
84 #
85 # Example:
86 # @CODE
87 # PYTHON_REQ_USE="gdbm,ncurses(-)?"
88 # @CODE
89 #
90 # It will cause the Python dependencies to look like:
91 # @CODE
92 # python_targets_pythonX_Y? ( dev-lang/python:X.Y[gdbm,ncurses(-)?] )
93 # @CODE
94
95 # @ECLASS-VARIABLE: PYTHON_DEPS
96 # @DESCRIPTION:
97 # This is an eclass-generated Python dependency string for all
98 # implementations listed in PYTHON_COMPAT.
99 #
100 # Example use:
101 # @CODE
102 # RDEPEND="${PYTHON_DEPS}
103 # dev-foo/mydep"
104 # DEPEND="${RDEPEND}"
105 # @CODE
106 #
107 # Example value:
108 # @CODE
109 # dev-python/python-exec
110 # python_targets_python2_6? ( dev-lang/python:2.6[gdbm] )
111 # python_targets_python2_7? ( dev-lang/python:2.7[gdbm] )
112 # @CODE
113
114 # @ECLASS-VARIABLE: PYTHON_USEDEP
115 # @DESCRIPTION:
116 # This is an eclass-generated USE-dependency string which can be used to
117 # depend on another Python package being built for the same Python
118 # implementations.
119 #
120 # The generate USE-flag list is compatible with packages using python-r1
121 # and python-distutils-ng eclasses. It must not be used on packages
122 # using python.eclass.
123 #
124 # Example use:
125 # @CODE
126 # RDEPEND="dev-python/foo[${PYTHON_USEDEP}]"
127 # @CODE
128 #
129 # Example value:
130 # @CODE
131 # python_targets_python2_6(-)?,python_targets_python2_7(-)?
132 # @CODE
133
134 _python_set_globals() {
135 local impls=()
136
137 PYTHON_DEPS=
138 local i PYTHON_PKG_DEP
139 for i in "${PYTHON_COMPAT[@]}"; do
140 _python_impl_supported "${i}" || continue
141
142 python_export "${i}" PYTHON_PKG_DEP
143 PYTHON_DEPS+="python_targets_${i}? ( ${PYTHON_PKG_DEP} ) "
144
145 impls+=( "${i}" )
146 done
147
148 if [[ ${#impls[@]} -eq 0 ]]; then
149 die "No supported implementation in PYTHON_COMPAT."
150 fi
151
152 local flags=( "${impls[@]/#/python_targets_}" )
153 local optflags=${flags[@]/%/(-)?}
154
155 # A nice QA trick here. Since a python-single-r1 package has to have
156 # at least one PYTHON_SINGLE_TARGET enabled (REQUIRED_USE),
157 # the following check will always fail on those packages. Therefore,
158 # it should prevent developers from mistakenly depending on packages
159 # not supporting multiple Python implementations.
160
161 local flags_st=( "${impls[@]/#/-python_single_target_}" )
162 optflags+=,${flags_st[@]/%/(-)}
163
164 IUSE=${flags[*]}
165 #REQUIRED_USE="|| ( ${flags[*]} )"
166 PYTHON_USEDEP=${optflags// /,}
167
168 # 1) well, python-exec would suffice as an RDEP
169 # but no point in making this overcomplex, BDEP doesn't hurt anyone
170 # 2) python-exec should be built with all targets forced anyway
171 # but if new targets were added, we may need to force a rebuild
172 PYTHON_DEPS+="dev-python/python-exec[${PYTHON_USEDEP}]"
173 }
174 _python_set_globals
175
176 # @ECLASS-VARIABLE: DISTUTILS_JOBS
177 # @DEFAULT_UNSET
178 # @DESCRIPTION:
179 # The number of parallel jobs to run for distutils-r1 parallel builds.
180 # If unset, the job-count in ${MAKEOPTS} will be used.
181 #
182 # This variable is intended to be set in make.conf.
183
184 # @FUNCTION: _python_validate_useflags
185 # @INTERNAL
186 # @DESCRIPTION:
187 # Enforce the proper setting of PYTHON_TARGETS.
188 _python_validate_useflags() {
189 debug-print-function ${FUNCNAME} "${@}"
190
191 local i
192
193 for i in "${PYTHON_COMPAT[@]}"; do
194 _python_impl_supported "${i}" || continue
195
196 use "python_targets_${i}" && return 0
197 done
198
199 eerror "No Python implementation selected for the build. Please add one"
200 eerror "of the following values to your PYTHON_TARGETS (in make.conf):"
201 eerror
202 eerror "${PYTHON_COMPAT[@]}"
203 echo
204 die "No supported Python implementation in PYTHON_TARGETS."
205 }
206
207 # @FUNCTION: python_gen_usedep
208 # @USAGE: <pattern> [...]
209 # @DESCRIPTION:
210 # Output a USE dependency string for Python implementations which
211 # are both in PYTHON_COMPAT and match any of the patterns passed
212 # as parameters to the function.
213 #
214 # When all implementations are requested, please use ${PYTHON_USEDEP}
215 # instead. Please also remember to set an appropriate REQUIRED_USE
216 # to avoid ineffective USE flags.
217 #
218 # Example:
219 # @CODE
220 # PYTHON_COMPAT=( python{2_7,3_2} )
221 # DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep python2*)] )"
222 # @CODE
223 #
224 # It will cause the dependency to look like:
225 # @CODE
226 # DEPEND="doc? ( dev-python/epydoc[python_targets_python2_7?] )"
227 # @CODE
228 python_gen_usedep() {
229 debug-print-function ${FUNCNAME} "${@}"
230
231 local impl pattern
232 local matches=()
233
234 for impl in "${PYTHON_COMPAT[@]}"; do
235 _python_impl_supported "${impl}" || continue
236
237 for pattern; do
238 if [[ ${impl} == ${pattern} ]]; then
239 matches+=(
240 "python_targets_${impl}(-)?"
241 "-python_single_target_${impl}(-)"
242 )
243 break
244 fi
245 done
246 done
247
248 local out=${matches[@]}
249 echo ${out// /,}
250 }
251
252 # @FUNCTION: python_gen_useflags
253 # @USAGE: <pattern> [...]
254 # @DESCRIPTION:
255 # Output a list of USE flags for Python implementations which
256 # are both in PYTHON_COMPAT and match any of the patterns passed
257 # as parameters to the function.
258 #
259 # Example:
260 # @CODE
261 # PYTHON_COMPAT=( python{2_7,3_2} )
262 # REQUIRED_USE="doc? ( || ( $(python_gen_useflags python2*) ) )"
263 # @CODE
264 #
265 # It will cause the variable to look like:
266 # @CODE
267 # REQUIRED_USE="doc? ( || ( python_targets_python2_7 ) )"
268 # @CODE
269 python_gen_useflags() {
270 debug-print-function ${FUNCNAME} "${@}"
271
272 local impl pattern
273 local matches=()
274
275 for impl in "${PYTHON_COMPAT[@]}"; do
276 _python_impl_supported "${impl}" || continue
277
278 for pattern; do
279 if [[ ${impl} == ${pattern} ]]; then
280 matches+=( "python_targets_${impl}" )
281 break
282 fi
283 done
284 done
285
286 echo ${matches[@]}
287 }
288
289 # @FUNCTION: python_gen_cond_dep
290 # @USAGE: <dependency> <pattern> [...]
291 # @DESCRIPTION:
292 # Output a list of <dependency>-ies made conditional to USE flags
293 # of Python implementations which are both in PYTHON_COMPAT and match
294 # any of the patterns passed as the remaining parameters.
295 #
296 # Please note that USE constraints on the package need to be enforced
297 # separately. Therefore, the dependency usually needs to use
298 # python_gen_usedep as well.
299 #
300 # Example:
301 # @CODE
302 # PYTHON_COMPAT=( python{2_5,2_6,2_7} )
303 # RDEPEND="$(python_gen_cond_dep dev-python/unittest2 python{2_5,2_6})"
304 # @CODE
305 #
306 # It will cause the variable to look like:
307 # @CODE
308 # RDEPEND="python_targets_python2_5? ( dev-python/unittest2 )
309 # python_targets_python2_6? ( dev-python/unittest2 )"
310 # @CODE
311 python_gen_cond_dep() {
312 debug-print-function ${FUNCNAME} "${@}"
313
314 local impl pattern
315 local matches=()
316
317 local dep=${1}
318 shift
319
320 for impl in "${PYTHON_COMPAT[@]}"; do
321 _python_impl_supported "${impl}" || continue
322
323 for pattern; do
324 if [[ ${impl} == ${pattern} ]]; then
325 matches+=( "python_targets_${impl}? ( ${dep} )" )
326 break
327 fi
328 done
329 done
330
331 echo ${matches[@]}
332 }
333
334 # @ECLASS-VARIABLE: BUILD_DIR
335 # @DESCRIPTION:
336 # The current build directory. In global scope, it is supposed to
337 # contain an initial build directory; if unset, it defaults to ${S}.
338 #
339 # In functions run by python_foreach_impl(), the BUILD_DIR is locally
340 # set to an implementation-specific build directory. That path is
341 # created through appending a hyphen and the implementation name
342 # to the final component of the initial BUILD_DIR.
343 #
344 # Example value:
345 # @CODE
346 # ${WORKDIR}/foo-1.3-python2_6
347 # @CODE
348
349 # @FUNCTION: python_copy_sources
350 # @DESCRIPTION:
351 # Create a single copy of the package sources (${S}) for each enabled
352 # Python implementation.
353 #
354 # The sources are always copied from S to implementation-specific build
355 # directories respecting BUILD_DIR.
356 python_copy_sources() {
357 debug-print-function ${FUNCNAME} "${@}"
358
359 _python_validate_useflags
360
361 local impl
362 local bdir=${BUILD_DIR:-${S}}
363
364 debug-print "${FUNCNAME}: bdir = ${bdir}"
365 einfo "Will copy sources from ${S}"
366 # the order is irrelevant here
367 for impl in "${PYTHON_COMPAT[@]}"; do
368 _python_impl_supported "${impl}" || continue
369
370 if use "python_targets_${impl}"
371 then
372 local BUILD_DIR=${bdir%%/}-${impl}
373
374 einfo "${impl}: copying to ${BUILD_DIR}"
375 debug-print "${FUNCNAME}: [${impl}] cp ${S} => ${BUILD_DIR}"
376 cp -pr "${S}" "${BUILD_DIR}" || die
377 fi
378 done
379 }
380
381 # @FUNCTION: _python_check_USE_PYTHON
382 # @INTERNAL
383 # @DESCRIPTION:
384 # Check whether USE_PYTHON and PYTHON_TARGETS are in sync. Output
385 # warnings if they are not.
386 _python_check_USE_PYTHON() {
387 debug-print-function ${FUNCNAME} "${@}"
388
389 if [[ ! ${_PYTHON_USE_PYTHON_CHECKED} ]]; then
390 _PYTHON_USE_PYTHON_CHECKED=1
391
392 # python-exec has profile-forced flags.
393 if [[ ${CATEGORY}/${PN} == dev-python/python-exec ]]; then
394 return
395 fi
396
397 _try_eselect() {
398 # The eselect solution will work only with one py2 & py3.
399
400 local impl py2 py3 dis_py2 dis_py3
401 for impl in "${PYTHON_COMPAT[@]}"; do
402 _python_impl_supported "${impl}" || continue
403
404 if use "python_targets_${impl}"; then
405 case "${impl}" in
406 python2_*)
407 if [[ ${py2+1} ]]; then
408 debug-print "${FUNCNAME}: -> more than one py2: ${py2} ${impl}"
409 return 1
410 fi
411 py2=${impl/_/.}
412 ;;
413 python3_*)
414 if [[ ${py3+1} ]]; then
415 debug-print "${FUNCNAME}: -> more than one py3: ${py3} ${impl}"
416 return 1
417 fi
418 py3=${impl/_/.}
419 ;;
420 *)
421 return 1
422 ;;
423 esac
424 else
425 case "${impl}" in
426 python2_*)
427 dis_py2=1
428 ;;
429 python3_*)
430 dis_py3=1
431 ;;
432 esac
433 fi
434 done
435
436 # The eselect solution won't work if the disabled Python version
437 # is installed.
438 if [[ ! ${py2+1} && ${dis_py2} ]]; then
439 debug-print "${FUNCNAME}: -> all py2 versions disabled"
440 if ! has python2_7 "${PYTHON_COMPAT[@]}"; then
441 debug-print "${FUNCNAME}: ---> package does not support 2.7"
442 return 0
443 fi
444 if has_version '=dev-lang/python-2*'; then
445 debug-print "${FUNCNAME}: ---> but =python-2* installed!"
446 return 1
447 fi
448 fi
449 if [[ ! ${py3+1} && ${dis_py3} ]]; then
450 debug-print "${FUNCNAME}: -> all py3 versions disabled"
451 if ! has python3_2 "${PYTHON_COMPAT[@]}"; then
452 debug-print "${FUNCNAME}: ---> package does not support 3.2"
453 return 0
454 fi
455 if has_version '=dev-lang/python-3*'; then
456 debug-print "${FUNCNAME}: ---> but =python-3* installed!"
457 return 1
458 fi
459 fi
460
461 local warned
462
463 # Now check whether the correct implementations are active.
464 if [[ ${py2+1} ]]; then
465 local sel_py2=$(eselect python show --python2)
466
467 debug-print "${FUNCNAME}: -> py2 built: ${py2}, active: ${sel_py2}"
468 if [[ ${py2} != ${sel_py2} ]]; then
469 ewarn "Building package for ${py2} only while ${sel_py2} is active."
470 ewarn "Please consider switching the active Python 2 interpreter:"
471 ewarn
472 ewarn " eselect python set --python2 ${py2}"
473 warned=1
474 fi
475 fi
476
477 if [[ ${py3+1} ]]; then
478 local sel_py3=$(eselect python show --python3)
479
480 debug-print "${FUNCNAME}: -> py3 built: ${py3}, active: ${sel_py3}"
481 if [[ ${py3} != ${sel_py3} ]]; then
482 [[ ${warned} ]] && ewarn
483 ewarn "Building package for ${py3} only while ${sel_py3} is active."
484 ewarn "Please consider switching the active Python 3 interpreter:"
485 ewarn
486 ewarn " eselect python set --python3 ${py3}"
487 warned=1
488 fi
489 fi
490
491 if [[ ${warned} ]]; then
492 ewarn
493 ewarn "Please note that after switching the active Python interpreter,"
494 ewarn "you may need to run 'python-updater' to rebuild affected packages."
495 ewarn
496 ewarn "For more information on python.eclass compatibility, please see"
497 ewarn "the appropriate python-r1 User's Guide chapter [1]."
498 ewarn
499 ewarn "[1] http://www.gentoo.org/proj/en/Python/python-r1/user-guide.xml#doc_chap2"
500 fi
501 }
502
503 # If user has no USE_PYTHON, try to avoid it.
504 if [[ ! ${USE_PYTHON} ]]; then
505 debug-print "${FUNCNAME}: trying eselect solution ..."
506 _try_eselect && return
507 fi
508
509 debug-print "${FUNCNAME}: trying USE_PYTHON solution ..."
510 debug-print "${FUNCNAME}: -> USE_PYTHON=${USE_PYTHON}"
511
512 local impl old=${USE_PYTHON} new=() removed=()
513
514 for impl in "${PYTHON_COMPAT[@]}"; do
515 _python_impl_supported "${impl}" || continue
516
517 local abi
518 case "${impl}" in
519 python*)
520 abi=${impl#python}
521 ;;
522 jython*)
523 abi=${impl#jython}-jython
524 ;;
525 pypy*)
526 abi=2.7-pypy-${impl#pypy}
527 ;;
528 *)
529 die "Unexpected Python implementation: ${impl}"
530 ;;
531 esac
532 abi=${abi/_/.}
533
534 has "${abi}" ${USE_PYTHON}
535 local has_abi=${?}
536 use "python_targets_${impl}"
537 local has_impl=${?}
538
539 # 0 = has, 1 = does not have
540 if [[ ${has_abi} == 0 && ${has_impl} == 1 ]]; then
541 debug-print "${FUNCNAME}: ---> remove ${abi}"
542 # remove from USE_PYTHON
543 old=${old/${abi}/}
544 removed+=( ${abi} )
545 elif [[ ${has_abi} == 1 && ${has_impl} == 0 ]]; then
546 debug-print "${FUNCNAME}: ---> add ${abi}"
547 # add to USE_PYTHON
548 new+=( ${abi} )
549 fi
550 done
551
552 if [[ ${removed[@]} || ${new[@]} ]]; then
553 old=( ${old} )
554
555 debug-print "${FUNCNAME}: -> old: ${old[@]}"
556 debug-print "${FUNCNAME}: -> new: ${new[@]}"
557 debug-print "${FUNCNAME}: -> removed: ${removed[@]}"
558
559 if [[ ${USE_PYTHON} ]]; then
560 ewarn "It seems that your USE_PYTHON setting lists different Python"
561 ewarn "implementations than your PYTHON_TARGETS variable. Please consider"
562 ewarn "using the following value instead:"
563 ewarn
564 ewarn " USE_PYTHON='\033[35m${old[@]}${new[@]+ \033[1m${new[@]}}\033[0m'"
565
566 if [[ ${removed[@]} ]]; then
567 ewarn
568 ewarn "(removed \033[31m${removed[@]}\033[0m)"
569 fi
570 else
571 ewarn "It seems that you need to set USE_PYTHON to make sure that legacy"
572 ewarn "packages will be built with respect to PYTHON_TARGETS correctly:"
573 ewarn
574 ewarn " USE_PYTHON='\033[35;1m${new[@]}\033[0m'"
575 fi
576
577 ewarn
578 ewarn "Please note that after changing the USE_PYTHON variable, you may need"
579 ewarn "to run 'python-updater' to rebuild affected packages."
580 ewarn
581 ewarn "For more information on python.eclass compatibility, please see"
582 ewarn "the appropriate python-r1 User's Guide chapter [1]."
583 ewarn
584 ewarn "[1] http://www.gentoo.org/proj/en/Python/python-r1/user-guide.xml#doc_chap2"
585 fi
586 fi
587 }
588
589 # @FUNCTION: _python_obtain_impls
590 # @INTERNAL
591 # @DESCRIPTION:
592 # Set up the enabled implementation list.
593 _python_obtain_impls() {
594 MULTIBUILD_VARIANTS=()
595
596 for impl in "${_PYTHON_ALL_IMPLS[@]}"; do
597 if has "${impl}" "${PYTHON_COMPAT[@]}" \
598 && use "python_targets_${impl}"
599 then
600 MULTIBUILD_VARIANTS+=( "${impl}" )
601 fi
602 done
603 }
604
605 # @FUNCTION: _python_multibuild_wrapper
606 # @USAGE: <command> [<args>...]
607 # @INTERNAL
608 # @DESCRIPTION:
609 # Initialize the environment for Python implementation selected
610 # for multibuild.
611 _python_multibuild_wrapper() {
612 debug-print-function ${FUNCNAME} "${@}"
613
614 local -x EPYTHON PYTHON
615 python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON
616
617 "${@}"
618 }
619
620 # @FUNCTION: python_foreach_impl
621 # @USAGE: <command> [<args>...]
622 # @DESCRIPTION:
623 # Run the given command for each of the enabled Python implementations.
624 # If additional parameters are passed, they will be passed through
625 # to the command.
626 #
627 # The function will return 0 status if all invocations succeed.
628 # Otherwise, the return code from first failing invocation will
629 # be returned.
630 #
631 # For each command being run, EPYTHON, PYTHON and BUILD_DIR are set
632 # locally, and the former two are exported to the command environment.
633 python_foreach_impl() {
634 debug-print-function ${FUNCNAME} "${@}"
635
636 _python_validate_useflags
637 _python_check_USE_PYTHON
638
639 local MULTIBUILD_VARIANTS
640 _python_obtain_impls
641
642 multibuild_foreach_variant _python_multibuild_wrapper "${@}"
643 }
644
645 # @FUNCTION: python_parallel_foreach_impl
646 # @USAGE: <command> [<args>...]
647 # @DESCRIPTION:
648 # Run the given command for each of the enabled Python implementations.
649 # If additional parameters are passed, they will be passed through
650 # to the command.
651 #
652 # The function will return 0 status if all invocations succeed.
653 # Otherwise, the return code from first failing invocation will
654 # be returned.
655 #
656 # For each command being run, EPYTHON, PYTHON and BUILD_DIR are set
657 # locally, and the former two are exported to the command environment.
658 #
659 # Multiple invocations of the command will be run in parallel, up to
660 # DISTUTILS_JOBS (defaulting to '-j' option argument from MAKEOPTS).
661 python_parallel_foreach_impl() {
662 debug-print-function ${FUNCNAME} "${@}"
663
664 local MULTIBUILD_JOBS=${MULTIBUILD_JOBS:-${DISTUTILS_JOBS}}
665 local MULTIBUILD_VARIANTS
666 _python_obtain_impls
667 multibuild_parallel_foreach_variant _python_multibuild_wrapper "${@}"
668 }
669
670 # @FUNCTION: python_export_best
671 # @USAGE: [<variable>...]
672 # @DESCRIPTION:
673 # Find the best (most preferred) Python implementation enabled
674 # and export given variables for it. If no variables are provided,
675 # EPYTHON & PYTHON will be exported.
676 python_export_best() {
677 debug-print-function ${FUNCNAME} "${@}"
678
679 _python_validate_useflags
680
681 [[ ${#} -gt 0 ]] || set -- EPYTHON PYTHON
682
683 local impl best
684 for impl in "${_PYTHON_ALL_IMPLS[@]}"; do
685 if has "${impl}" "${PYTHON_COMPAT[@]}" \
686 && _python_impl_supported "${impl}" \
687 && use "python_targets_${impl}"
688 then
689 best=${impl}
690 fi
691 done
692
693 [[ ${best+1} ]] || die "python_export_best(): no implementation found!"
694
695 debug-print "${FUNCNAME}: Best implementation is: ${impl}"
696 python_export "${impl}" "${@}"
697 }
698
699 # @FUNCTION: python_replicate_script
700 # @USAGE: <path>...
701 # @DESCRIPTION:
702 # Copy the given script to variants for all enabled Python
703 # implementations, then replace it with a symlink to the wrapper.
704 #
705 # All specified files must start with a 'python' shebang. A file not
706 # having a matching shebang will be refused.
707 python_replicate_script() {
708 debug-print-function ${FUNCNAME} "${@}"
709
710 _python_validate_useflags
711
712 local suffixes=()
713
714 _add_suffix() {
715 suffixes+=( "${EPYTHON}" )
716 }
717 python_foreach_impl _add_suffix
718 debug-print "${FUNCNAME}: suffixes = ( ${suffixes[@]} )"
719
720 local f suffix
721 for suffix in "${suffixes[@]}"; do
722 for f; do
723 local newf=${f}-${suffix}
724
725 debug-print "${FUNCNAME}: ${f} -> ${newf}"
726 cp "${f}" "${newf}" || die
727 done
728
729 _python_rewrite_shebang "${suffix}" "${@/%/-${suffix}}"
730 done
731
732 for f; do
733 _python_ln_rel "${ED}"/usr/bin/python-exec "${f}" || die
734 done
735 }
736
737 _PYTHON_R1=1
738 fi

  ViewVC Help
Powered by ViewVC 1.1.20