dev-python/josepy: 1.1.0 cleanup
[gentoo.git] / eclass / python-single-r1.eclass
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: python-single-r1.eclass
5 # @MAINTAINER:
6 # Python team <python@gentoo.org>
7 # @AUTHOR:
8 # Author: Michał Górny <mgorny@gentoo.org>
9 # Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
10 # @SUPPORTED_EAPIS: 5 6 7
11 # @BLURB: An eclass for Python packages not installed for multiple implementations.
12 # @DESCRIPTION:
13 # An extension of the python-r1 eclass suite for packages which
14 # don't support being installed for multiple Python implementations.
15 # This mostly includes tools embedding Python and packages using foreign
16 # build systems.
17 #
18 # This eclass sets correct IUSE.  It also provides PYTHON_DEPS
19 # and PYTHON_REQUIRED_USE that need to be added to appropriate ebuild
20 # metadata variables.
21 #
22 # The eclass exports PYTHON_SINGLE_USEDEP that is suitable for depending
23 # on other packages using the eclass.  Dependencies on packages using
24 # python-r1 should be created via python_gen_cond_dep() function,
25 # using PYTHON_MULTI_USEDEP placeholder.
26 #
27 # Please note that packages support multiple Python implementations
28 # (using python-r1 eclass) can not depend on packages not supporting
29 # them (using this eclass).
30 #
31 # Please note that python-single-r1 will always inherit python-utils-r1
32 # as well. Thus, all the functions defined there can be used
33 # in the packages using python-single-r1, and there is no need ever
34 # to inherit both.
35 #
36 # For more information, please see the wiki:
37 # https://wiki.gentoo.org/wiki/Project:Python/python-single-r1
38
39 case "${EAPI:-0}" in
40         0|1|2|3|4)
41                 die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
42                 ;;
43         5|6|7)
44                 # EAPI=5 is required for sane USE_EXPAND dependencies
45                 ;;
46         *)
47                 die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
48                 ;;
49 esac
50
51 if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
52
53 if [[ ${_PYTHON_R1} ]]; then
54         die 'python-single-r1.eclass can not be used with python-r1.eclass.'
55 elif [[ ${_PYTHON_ANY_R1} ]]; then
56         die 'python-single-r1.eclass can not be used with python-any-r1.eclass.'
57 fi
58
59 inherit python-utils-r1
60
61 fi
62
63 EXPORT_FUNCTIONS pkg_setup
64
65 # @ECLASS-VARIABLE: PYTHON_COMPAT
66 # @REQUIRED
67 # @DESCRIPTION:
68 # This variable contains a list of Python implementations the package
69 # supports. It must be set before the `inherit' call. It has to be
70 # an array.
71 #
72 # Example:
73 # @CODE
74 # PYTHON_COMPAT=( python2_7 python3_3 python3_4 )
75 # @CODE
76 #
77 # Please note that you can also use bash brace expansion if you like:
78 # @CODE
79 # PYTHON_COMPAT=( python2_7 python3_{3,4} )
80 # @CODE
81
82 # @ECLASS-VARIABLE: PYTHON_COMPAT_OVERRIDE
83 # @INTERNAL
84 # @DESCRIPTION:
85 # This variable can be used when working with ebuilds to override
86 # the in-ebuild PYTHON_COMPAT. It is a string naming the implementation
87 # which package will be built for. It needs to be specified
88 # in the calling environment, and not in ebuilds.
89 #
90 # It should be noted that in order to preserve metadata immutability,
91 # PYTHON_COMPAT_OVERRIDE does not affect IUSE nor dependencies.
92 # The state of PYTHON_TARGETS and PYTHON_SINGLE_TARGET is ignored,
93 # and the implementation in PYTHON_COMPAT_OVERRIDE is built instead.
94 # Dependencies need to be satisfied manually.
95 #
96 # Example:
97 # @CODE
98 # PYTHON_COMPAT_OVERRIDE='pypy' emerge -1v dev-python/bar
99 # @CODE
100
101 # @ECLASS-VARIABLE: PYTHON_REQ_USE
102 # @DEFAULT_UNSET
103 # @DESCRIPTION:
104 # The list of USEflags required to be enabled on the chosen Python
105 # implementations, formed as a USE-dependency string. It should be valid
106 # for all implementations in PYTHON_COMPAT, so it may be necessary to
107 # use USE defaults.
108 #
109 # This should be set before calling `inherit'.
110 #
111 # Example:
112 # @CODE
113 # PYTHON_REQ_USE="gdbm,ncurses(-)?"
114 # @CODE
115 #
116 # It will cause the Python dependencies to look like:
117 # @CODE
118 # python_single_target_pythonX_Y? ( dev-lang/python:X.Y[gdbm,ncurses(-)?] )
119 # @CODE
120
121 # @ECLASS-VARIABLE: PYTHON_DEPS
122 # @DESCRIPTION:
123 # This is an eclass-generated Python dependency string for all
124 # implementations listed in PYTHON_COMPAT.
125 #
126 # The dependency string is conditional on PYTHON_SINGLE_TARGET.
127 #
128 # Example use:
129 # @CODE
130 # RDEPEND="${PYTHON_DEPS}
131 #       dev-foo/mydep"
132 # DEPEND="${RDEPEND}"
133 # @CODE
134 #
135 # Example value:
136 # @CODE
137 # dev-lang/python-exec:=
138 # python_single_target_python2_7? ( dev-lang/python:2.7[gdbm] )
139 # python_single_target_pypy? ( dev-python/pypy[gdbm] )
140 # @CODE
141
142 # @ECLASS-VARIABLE: PYTHON_USEDEP
143 # @DESCRIPTION:
144 # DEPRECATED.  Use PYTHON_SINGLE_USEDEP or python_gen_cond_dep with
145 # PYTHON_MULTI_USEDEP placeholder instead.
146 #
147 # This is an eclass-generated USE-dependency string which can be used to
148 # depend on another Python package being built for the same Python
149 # implementations.
150 #
151 # The generate USE-flag list is compatible with packages using python-r1,
152 # python-single-r1 and python-distutils-ng eclasses. It must not be used
153 # on packages using python.eclass.
154 #
155 # Example use:
156 # @CODE
157 # RDEPEND="dev-python/foo[${PYTHON_USEDEP}]"
158 # @CODE
159 #
160 # Example value:
161 # @CODE
162 # python_targets_python2_7(-)?,python_single_target_python3_4(+)?
163 # @CODE
164
165 # @ECLASS-VARIABLE: PYTHON_SINGLE_USEDEP
166 # @DESCRIPTION:
167 # This is an eclass-generated USE-dependency string which can be used to
168 # depend on another python-single-r1 package being built for the same
169 # Python implementations.
170 #
171 # If you need to depend on a multi-impl (python-r1) package, use
172 # python_gen_cond_dep with PYTHON_MULTI_USEDEP placeholder instead.
173 #
174 # Example use:
175 # @CODE
176 # RDEPEND="dev-python/foo[${PYTHON_SINGLE_USEDEP}]"
177 # @CODE
178 #
179 # Example value:
180 # @CODE
181 # python_single_target_python3_4(-)?
182 # @CODE
183
184 # @ECLASS-VARIABLE: PYTHON_MULTI_USEDEP
185 # @DESCRIPTION:
186 # This is a placeholder variable supported by python_gen_cond_dep,
187 # in order to depend on python-r1 packages built for the same Python
188 # implementations.
189 #
190 # Example use:
191 # @CODE
192 # RDEPEND="$(python_gen_cond_dep '
193 #     dev-python/foo[${PYTHON_MULTI_USEDEP}]
194 #   ')"
195 # @CODE
196 #
197 # Example value:
198 # @CODE
199 # python_targets_python3_4(-)
200 # @CODE
201
202 # @ECLASS-VARIABLE: PYTHON_REQUIRED_USE
203 # @DESCRIPTION:
204 # This is an eclass-generated required-use expression which ensures the following
205 # when more than one python implementation is possible:
206 # 1. Exactly one PYTHON_SINGLE_TARGET value has been enabled.
207 # 2. The selected PYTHON_SINGLE_TARGET value is enabled in PYTHON_TARGETS.
208 #
209 # This expression should be utilized in an ebuild by including it in
210 # REQUIRED_USE, optionally behind a use flag.
211 #
212 # Example use:
213 # @CODE
214 # REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
215 # @CODE
216 #
217 # Example value:
218 # @CODE
219 # python_single_target_python2_7? ( python_targets_python2_7 )
220 # python_single_target_python3_3? ( python_targets_python3_3 )
221 # ^^ ( python_single_target_python2_7 python_single_target_python3_3 )
222 # @CODE
223
224 _python_single_set_globals() {
225         _python_set_impls
226
227         local flags_mt=( "${_PYTHON_SUPPORTED_IMPLS[@]/#/python_targets_}" )
228         local flags=( "${_PYTHON_SUPPORTED_IMPLS[@]/#/python_single_target_}" )
229         local unflags=( "${_PYTHON_UNSUPPORTED_IMPLS[@]/#/-python_single_target_}" )
230
231         if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
232                 # if only one implementation is supported, use IUSE defaults
233                 # to avoid requesting the user to enable it
234                 IUSE="+${flags_mt[0]} +${flags[0]}"
235         else
236                 IUSE="${flags_mt[*]} ${flags[*]}"
237         fi
238
239         local requse="^^ ( ${flags[*]} )"
240         local optflags="${flags_mt[@]/%/(-)?},${unflags[@]/%/(-)},${flags[@]/%/(+)?}"
241         local usedep="${optflags// /,}"
242         local single_flags="${flags[@]/%/(-)?}"
243         local single_usedep=${single_flags// /,}
244
245         local deps= i PYTHON_PKG_DEP
246         for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
247                 # The chosen targets need to be in PYTHON_TARGETS as well.
248                 # This is in order to enforce correct dependencies on packages
249                 # supporting multiple implementations.
250                 requse+=" python_single_target_${i}? ( python_targets_${i} )"
251
252                 python_export "${i}" PYTHON_PKG_DEP
253                 # 1) well, python-exec would suffice as an RDEP
254                 # but no point in making this overcomplex, BDEP doesn't hurt anyone
255                 # 2) python-exec should be built with all targets forced anyway
256                 # but if new targets were added, we may need to force a rebuild
257                 deps+="python_single_target_${i}? (
258                         ${PYTHON_PKG_DEP}
259                         >=dev-lang/python-exec-2:=[python_targets_${i}]
260                 ) "
261         done
262
263         if [[ ${PYTHON_DEPS+1} ]]; then
264                 if [[ ${PYTHON_DEPS} != "${deps}" ]]; then
265                         eerror "PYTHON_DEPS have changed between inherits (PYTHON_REQ_USE?)!"
266                         eerror "Before: ${PYTHON_DEPS}"
267                         eerror "Now   : ${deps}"
268                         die "PYTHON_DEPS integrity check failed"
269                 fi
270
271                 # these two are formality -- they depend on PYTHON_COMPAT only
272                 if [[ ${PYTHON_REQUIRED_USE} != ${requse} ]]; then
273                         eerror "PYTHON_REQUIRED_USE have changed between inherits!"
274                         eerror "Before: ${PYTHON_REQUIRED_USE}"
275                         eerror "Now   : ${requse}"
276                         die "PYTHON_REQUIRED_USE integrity check failed"
277                 fi
278
279                 if [[ ${PYTHON_USEDEP} != "${usedep}" ]]; then
280                         eerror "PYTHON_USEDEP have changed between inherits!"
281                         eerror "Before: ${PYTHON_USEDEP}"
282                         eerror "Now   : ${usedep}"
283                         die "PYTHON_USEDEP integrity check failed"
284                 fi
285
286                 if [[ ${PYTHON_SINGLE_USEDEP} != "${single_usedep}" ]]; then
287                         eerror "PYTHON_SINGLE_USEDEP have changed between inherits!"
288                         eerror "Before: ${PYTHON_SINGLE_USEDEP}"
289                         eerror "Now   : ${single_usedep}"
290                         die "PYTHON_SINGLE_USEDEP integrity check failed"
291                 fi
292         else
293                 PYTHON_DEPS=${deps}
294                 PYTHON_REQUIRED_USE=${requse}
295                 PYTHON_USEDEP=${usedep}
296                 PYTHON_SINGLE_USEDEP=${single_usedep}
297                 readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP \
298                         PYTHON_SINGLE_USEDEP
299         fi
300 }
301 _python_single_set_globals
302 unset -f _python_single_set_globals
303
304 if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
305
306 # @FUNCTION: _python_gen_usedep
307 # @INTERNAL
308 # @USAGE: <-s|-u> [<pattern>...]
309 # @DESCRIPTION:
310 # Output a USE dependency string for Python implementations which
311 # are both in PYTHON_COMPAT and match any of the patterns passed
312 # as parameters to the function.
313 #
314 # The first argument specifies USE-dependency type: '-s' for new-style
315 # PYTHON_SINGLE_USEDEP, '-u' for backwards-compatible PYTHON_USEDEP.
316 #
317 # The patterns can be either fnmatch-style patterns (matched via bash
318 # == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
319 # appropriately all enabled Python 2/3 implementations (alike
320 # python_is_python3). Remember to escape or quote the fnmatch patterns
321 # to prevent accidental shell filename expansion.
322 #
323 # This is an internal function used to implement python_gen_cond_dep
324 # and deprecated python_gen_usedep.
325 _python_gen_usedep() {
326         debug-print-function ${FUNCNAME} "${@}"
327
328         local mode=${1}
329         shift
330         local impl matches=()
331
332         for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
333                 if _python_impl_matches "${impl}" "${@}"; then
334                         case ${mode} in
335                                 -s)
336                                         matches+=(
337                                                 "python_single_target_${impl}(-)?"
338                                         )
339                                         ;;
340                                 -u)
341                                         matches+=(
342                                                 "python_targets_${impl}(-)?"
343                                                 "python_single_target_${impl}(+)?"
344                                         )
345                                 ;;
346                         esac
347                 fi
348         done
349
350         [[ ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}"
351
352         local out=${matches[@]}
353         echo "${out// /,}"
354 }
355
356 # @FUNCTION: python_gen_usedep
357 # @USAGE: <pattern> [...]
358 # @DESCRIPTION:
359 # DEPRECATED.  Please use python_gen_cond_dep instead.
360 #
361 # Output a USE dependency string for Python implementations which
362 # are both in PYTHON_COMPAT and match any of the patterns passed
363 # as parameters to the function.
364 #
365 # The patterns can be either fnmatch-style patterns (matched via bash
366 # == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
367 # appropriately all enabled Python 2/3 implementations (alike
368 # python_is_python3). Remember to escape or quote the fnmatch patterns
369 # to prevent accidental shell filename expansion.
370 #
371 # When all implementations are requested, please use ${PYTHON_USEDEP}
372 # instead. Please also remember to set an appropriate REQUIRED_USE
373 # to avoid ineffective USE flags.
374 #
375 # Example:
376 # @CODE
377 # PYTHON_COMPAT=( python{2_7,3_4} )
378 # DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )"
379 # @CODE
380 #
381 # It will cause the dependency to look like:
382 # @CODE
383 # DEPEND="doc? ( dev-python/epydoc[python_targets_python2_7(-)?,...] )"
384 # @CODE
385 python_gen_usedep() {
386         debug-print-function ${FUNCNAME} "${@}"
387
388         # output only once, during some reasonable phase
389         # (avoid spamming cache regen runs)
390         if [[ ${EBUILD_PHASE} == setup ]]; then
391                 eqawarn "python_gen_usedep() is deprecated. Please use python_gen_cond_dep instead."
392         fi
393         _python_gen_usedep -u "${@}"
394 }
395
396 # @FUNCTION: python_gen_useflags
397 # @USAGE: [<pattern>...]
398 # @DESCRIPTION:
399 # Output a list of USE flags for Python implementations which
400 # are both in PYTHON_COMPAT and match any of the patterns passed
401 # as parameters to the function.
402 #
403 # The patterns can be either fnmatch-style patterns (matched via bash
404 # == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
405 # appropriately all enabled Python 2/3 implementations (alike
406 # python_is_python3). Remember to escape or quote the fnmatch patterns
407 # to prevent accidental shell filename expansion.
408 #
409 # Example:
410 # @CODE
411 # PYTHON_COMPAT=( python{2_7,3_4} )
412 # REQUIRED_USE="doc? ( ^^ ( $(python_gen_useflags 'python2*') ) )"
413 # @CODE
414 #
415 # It will cause the variable to look like:
416 # @CODE
417 # REQUIRED_USE="doc? ( ^^ ( python_single_target_python2_7 ) )"
418 # @CODE
419 python_gen_useflags() {
420         debug-print-function ${FUNCNAME} "${@}"
421
422         local impl matches=()
423
424         for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
425                 if _python_impl_matches "${impl}" "${@}"; then
426                         matches+=( "python_single_target_${impl}" )
427                 fi
428         done
429
430         echo "${matches[@]}"
431 }
432
433 # @FUNCTION: python_gen_cond_dep
434 # @USAGE: <dependency> [<pattern>...]
435 # @DESCRIPTION:
436 # Output a list of <dependency>-ies made conditional to USE flags
437 # of Python implementations which are both in PYTHON_COMPAT and match
438 # any of the patterns passed as the remaining parameters.
439 #
440 # The patterns can be either fnmatch-style patterns (matched via bash
441 # == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
442 # appropriately all enabled Python 2/3 implementations (alike
443 # python_is_python3). Remember to escape or quote the fnmatch patterns
444 # to prevent accidental shell filename expansion.
445 #
446 # In order to enforce USE constraints on the packages, verbatim
447 # '${PYTHON_USEDEP}', '${PYTHON_SINGLE_USEDEP}'
448 # and '${PYTHON_MULTI_USEDEP}' (quoted!) may be placed in the dependency
449 # specification. It will get expanded within the function into a proper
450 # USE dependency string.
451 #
452 # Example:
453 # @CODE
454 # PYTHON_COMPAT=( python{2_7,3_{3,4}} pypy )
455 # RDEPEND="$(python_gen_cond_dep \
456 #   'dev-python/unittest2[${PYTHON_MULTI_USEDEP}]' python2_7 pypy )"
457 # @CODE
458 #
459 # It will cause the variable to look like:
460 # @CODE
461 # RDEPEND="python_single_target_python2_7? (
462 #     dev-python/unittest2[python_targets_python2_7(-)?,...] )
463 #       python_single_target_pypy? (
464 #     dev-python/unittest2[python_targets_pypy(-)?,...] )"
465 # @CODE
466 python_gen_cond_dep() {
467         debug-print-function ${FUNCNAME} "${@}"
468
469         local impl matches=()
470
471         local dep=${1}
472         shift
473
474         for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
475                 if _python_impl_matches "${impl}" "${@}"; then
476                         # substitute ${PYTHON_USEDEP} if used
477                         # (since python_gen_usedep() will not return ${PYTHON_USEDEP}
478                         #  the code is run at most once)
479                         if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
480                                 local usedep=$(_python_gen_usedep -u "${@}")
481                                 dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}}
482                         fi
483                         if [[ ${dep} == *'${PYTHON_SINGLE_USEDEP}'* ]]; then
484                                 local usedep=$(_python_gen_usedep -s "${@}")
485                                 dep=${dep//\$\{PYTHON_SINGLE_USEDEP\}/${usedep}}
486                         fi
487                         local multi_usedep="python_targets_${impl}(-)"
488
489                         matches+=( "python_single_target_${impl}? (
490                                 ${dep//\$\{PYTHON_MULTI_USEDEP\}/${multi_usedep}} )" )
491                 fi
492         done
493
494         echo "${matches[@]}"
495 }
496
497 # @FUNCTION: python_gen_impl_dep
498 # @USAGE: [<requested-use-flags> [<impl-pattern>...]]
499 # @DESCRIPTION:
500 # Output a dependency on Python implementations with the specified USE
501 # dependency string appended, or no USE dependency string if called
502 # without the argument (or with empty argument). If any implementation
503 # patterns are passed, the output dependencies will be generated only
504 # for the implementations matching them.
505 #
506 # The patterns can be either fnmatch-style patterns (matched via bash
507 # == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
508 # appropriately all enabled Python 2/3 implementations (alike
509 # python_is_python3). Remember to escape or quote the fnmatch patterns
510 # to prevent accidental shell filename expansion.
511 #
512 # Use this function when you need to request different USE flags
513 # on the Python interpreter depending on package's USE flags. If you
514 # only need a single set of interpreter USE flags, just set
515 # PYTHON_REQ_USE and use ${PYTHON_DEPS} globally.
516 #
517 # Example:
518 # @CODE
519 # PYTHON_COMPAT=( python{2_7,3_{3,4}} pypy )
520 # RDEPEND="foo? ( $(python_gen_impl_dep 'xml(+)') )"
521 # @CODE
522 #
523 # It will cause the variable to look like:
524 # @CODE
525 # RDEPEND="foo? (
526 #   python_single_target_python2_7? (
527 #     dev-lang/python:2.7[xml(+)] )
528 #       python_single_target_pypy? (
529 #     dev-python/pypy[xml(+)] ) )"
530 # @CODE
531 python_gen_impl_dep() {
532         debug-print-function ${FUNCNAME} "${@}"
533
534         local impl
535         local matches=()
536
537         local PYTHON_REQ_USE=${1}
538         shift
539
540         for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
541                 if _python_impl_matches "${impl}" "${@}"; then
542                         local PYTHON_PKG_DEP
543                         python_export "${impl}" PYTHON_PKG_DEP
544                         matches+=( "python_single_target_${impl}? ( ${PYTHON_PKG_DEP} )" )
545                 fi
546         done
547
548         echo "${matches[@]}"
549 }
550
551 # @FUNCTION: python_setup
552 # @DESCRIPTION:
553 # Determine what the selected Python implementation is and set
554 # the Python build environment up for it.
555 python_setup() {
556         debug-print-function ${FUNCNAME} "${@}"
557
558         unset EPYTHON
559
560         # support developer override
561         if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
562                 local impls=( ${PYTHON_COMPAT_OVERRIDE} )
563                 [[ ${#impls[@]} -eq 1 ]] || die "PYTHON_COMPAT_OVERRIDE must name exactly one implementation for python-single-r1"
564
565                 ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python"
566                 ewarn "implementation will be used:"
567                 ewarn
568                 ewarn " ${PYTHON_COMPAT_OVERRIDE}"
569                 ewarn
570                 ewarn "Dependencies won't be satisfied, and PYTHON_SINGLE_TARGET flags will be ignored."
571
572                 python_export "${impls[0]}" EPYTHON PYTHON
573                 python_wrapper_setup
574                 return
575         fi
576
577         local impl
578         for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
579                 if use "python_single_target_${impl}"; then
580                         if [[ ${EPYTHON} ]]; then
581                                 eerror "Your PYTHON_SINGLE_TARGET setting lists more than a single Python"
582                                 eerror "implementation. Please set it to just one value. If you need"
583                                 eerror "to override the value for a single package, please use package.env"
584                                 eerror "or an equivalent solution (man 5 portage)."
585                                 echo
586                                 die "More than one implementation in PYTHON_SINGLE_TARGET."
587                         fi
588
589                         if ! use "python_targets_${impl}"; then
590                                 eerror "The implementation chosen as PYTHON_SINGLE_TARGET must be added"
591                                 eerror "to PYTHON_TARGETS as well. This is in order to ensure that"
592                                 eerror "dependencies are satisfied correctly. We're sorry"
593                                 eerror "for the inconvenience."
594                                 echo
595                                 die "Build target (${impl}) not in PYTHON_TARGETS."
596                         fi
597
598                         python_export "${impl}" EPYTHON PYTHON
599                         python_wrapper_setup
600                 fi
601         done
602
603         if [[ ! ${EPYTHON} ]]; then
604                 eerror "No Python implementation selected for the build. Please set"
605                 eerror "the PYTHON_SINGLE_TARGET variable in your make.conf to one"
606                 eerror "of the following values:"
607                 eerror
608                 eerror "${_PYTHON_SUPPORTED_IMPLS[@]}"
609                 echo
610                 die "No supported Python implementation in PYTHON_SINGLE_TARGET/PYTHON_TARGETS."
611         fi
612 }
613
614 # @FUNCTION: python-single-r1_pkg_setup
615 # @DESCRIPTION:
616 # Runs python_setup.
617 python-single-r1_pkg_setup() {
618         debug-print-function ${FUNCNAME} "${@}"
619
620         [[ ${MERGE_TYPE} != binary ]] && python_setup
621 }
622
623 _PYTHON_SINGLE_R1=1
624 fi