Merge remote-tracking branch 'remotes/joe-konno-gitlab/topic/gentoo-565434-v2'
[gentoo.git] / eclass / python-r1.eclass
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: python-r1.eclass
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. Modification of REQUIRED_USE has to
18 # be done by the author of the ebuild (but PYTHON_REQUIRED_USE is
19 # provided for convenience, see below). python-r1 exports PYTHON_DEPS
20 # and PYTHON_USEDEP so you can create correct dependencies for your
21 # package easily. It also provides methods to easily run a command for
22 # each enabled Python implementation and duplicate the sources for them.
23 #
24 # Please note that python-r1 will always inherit python-utils-r1 as
25 # well. Thus, all the functions defined there can be used
26 # in the packages using python-r1, and there is no need ever to inherit
27 # both.
28 #
29 # For more information, please see the wiki:
30 # https://wiki.gentoo.org/wiki/Project:Python/python-r1
31
32 case "${EAPI:-0}" in
33         0|1|2|3)
34                 die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
35                 ;;
36         4)
37                 # EAPI=4 is only allowed on legacy packages
38                 if [[ ${CATEGORY}/${P} == dev-python/pyelftools-0.2[123] ]]; then
39                         :
40                 elif [[ ${CATEGORY}/${P} == sys-apps/file-5.22 ]]; then
41                         :
42                 elif [[ ${CATEGORY}/${P} == sys-apps/i2c-tools-3.1.1 ]]; then
43                         :
44                 elif [[ ${CATEGORY}/${P} == sys-libs/cracklib-2.9.[12] ]]; then
45                         :
46                 else
47                         die "Unsupported EAPI=${EAPI:-4} (too old, allowed only on restricted set of packages) for ${ECLASS}"
48                 fi
49                 ;;
50         5|6)
51                 # EAPI=5 is required for sane USE_EXPAND dependencies
52                 ;;
53         *)
54                 die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
55                 ;;
56 esac
57
58 if [[ ! ${_PYTHON_R1} ]]; then
59
60 if [[ ${_PYTHON_SINGLE_R1} ]]; then
61         die 'python-r1.eclass can not be used with python-single-r1.eclass.'
62 elif [[ ${_PYTHON_ANY_R1} ]]; then
63         die 'python-r1.eclass can not be used with python-any-r1.eclass.'
64 fi
65
66 [[ ${EAPI} == [45] ]] && inherit eutils
67 inherit multibuild python-utils-r1
68
69 # @ECLASS-VARIABLE: PYTHON_COMPAT
70 # @REQUIRED
71 # @DESCRIPTION:
72 # This variable contains a list of Python implementations the package
73 # supports. It must be set before the `inherit' call. It has to be
74 # an array.
75 #
76 # Example:
77 # @CODE
78 # PYTHON_COMPAT=( python2_7 python3_3 python3_4} )
79 # @CODE
80 #
81 # Please note that you can also use bash brace expansion if you like:
82 # @CODE
83 # PYTHON_COMPAT=( python2_7 python3_{3,4} )
84 # @CODE
85 if ! declare -p PYTHON_COMPAT &>/dev/null; then
86         die 'PYTHON_COMPAT not declared.'
87 fi
88 if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
89         die 'PYTHON_COMPAT must be an array.'
90 fi
91
92 # @ECLASS-VARIABLE: PYTHON_COMPAT_OVERRIDE
93 # @INTERNAL
94 # @DESCRIPTION:
95 # This variable can be used when working with ebuilds to override
96 # the in-ebuild PYTHON_COMPAT. It is a string listing all
97 # the implementations which package will be built for. It need be
98 # specified in the calling environment, and not in ebuilds.
99 #
100 # It should be noted that in order to preserve metadata immutability,
101 # PYTHON_COMPAT_OVERRIDE does not affect IUSE nor dependencies.
102 # The state of PYTHON_TARGETS is ignored, and all the implementations
103 # in PYTHON_COMPAT_OVERRIDE are built. Dependencies need to be satisfied
104 # manually.
105 #
106 # Example:
107 # @CODE
108 # PYTHON_COMPAT_OVERRIDE='pypy python3_3' emerge -1v dev-python/foo
109 # @CODE
110
111 # @ECLASS-VARIABLE: PYTHON_REQ_USE
112 # @DEFAULT_UNSET
113 # @DESCRIPTION:
114 # The list of USEflags required to be enabled on the chosen Python
115 # implementations, formed as a USE-dependency string. It should be valid
116 # for all implementations in PYTHON_COMPAT, so it may be necessary to
117 # use USE defaults.
118 #
119 # This should be set before calling `inherit'.
120 #
121 # Example:
122 # @CODE
123 # PYTHON_REQ_USE="gdbm,ncurses(-)?"
124 # @CODE
125 #
126 # It will cause the Python dependencies to look like:
127 # @CODE
128 # python_targets_pythonX_Y? ( dev-lang/python:X.Y[gdbm,ncurses(-)?] )
129 # @CODE
130
131 # @ECLASS-VARIABLE: PYTHON_DEPS
132 # @DESCRIPTION:
133 # This is an eclass-generated Python dependency string for all
134 # implementations listed in PYTHON_COMPAT.
135 #
136 # Example use:
137 # @CODE
138 # RDEPEND="${PYTHON_DEPS}
139 #       dev-foo/mydep"
140 # DEPEND="${RDEPEND}"
141 # @CODE
142 #
143 # Example value:
144 # @CODE
145 # dev-lang/python-exec:=
146 # python_targets_python2_7? ( dev-lang/python:2.7[gdbm] )
147 # python_targets_pypy? ( virtual/pypy[gdbm] )
148 # @CODE
149
150 # @ECLASS-VARIABLE: PYTHON_USEDEP
151 # @DESCRIPTION:
152 # This is an eclass-generated USE-dependency string which can be used to
153 # depend on another Python package being built for the same Python
154 # implementations.
155 #
156 # The generate USE-flag list is compatible with packages using python-r1
157 # and python-distutils-ng eclasses. It must not be used on packages
158 # using python.eclass.
159 #
160 # Example use:
161 # @CODE
162 # RDEPEND="dev-python/foo[${PYTHON_USEDEP}]"
163 # @CODE
164 #
165 # Example value:
166 # @CODE
167 # python_targets_python2_7(-)?,python_targets_python3_4(-)?
168 # @CODE
169
170 # @ECLASS-VARIABLE: PYTHON_REQUIRED_USE
171 # @DESCRIPTION:
172 # This is an eclass-generated required-use expression which ensures at
173 # least one Python implementation has been enabled.
174 #
175 # This expression should be utilized in an ebuild by including it in
176 # REQUIRED_USE, optionally behind a use flag.
177 #
178 # Example use:
179 # @CODE
180 # REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
181 # @CODE
182 #
183 # Example value:
184 # @CODE
185 # || ( python_targets_python2_7 python_targets_python3_4 )
186 # @CODE
187
188 _python_set_globals() {
189         local impls=()
190
191         PYTHON_DEPS=
192         local i PYTHON_PKG_DEP
193         for i in "${PYTHON_COMPAT[@]}"; do
194                 _python_impl_supported "${i}" || continue
195
196                 python_export "${i}" PYTHON_PKG_DEP
197                 PYTHON_DEPS+="python_targets_${i}? ( ${PYTHON_PKG_DEP} ) "
198
199                 impls+=( "${i}" )
200         done
201
202         if [[ ${#impls[@]} -eq 0 ]]; then
203                 die "No supported implementation in PYTHON_COMPAT."
204         fi
205
206         local flags=( "${impls[@]/#/python_targets_}" )
207         local optflags=${flags[@]/%/(-)?}
208
209         # A nice QA trick here. Since a python-single-r1 package has to have
210         # at least one PYTHON_SINGLE_TARGET enabled (REQUIRED_USE),
211         # the following check will always fail on those packages. Therefore,
212         # it should prevent developers from mistakenly depending on packages
213         # not supporting multiple Python implementations.
214
215         local flags_st=( "${impls[@]/#/-python_single_target_}" )
216         optflags+=,${flags_st[@]/%/(-)}
217
218         IUSE=${flags[*]}
219         PYTHON_REQUIRED_USE="|| ( ${flags[*]} )"
220         PYTHON_USEDEP=${optflags// /,}
221
222         # 1) well, python-exec would suffice as an RDEP
223         # but no point in making this overcomplex, BDEP doesn't hurt anyone
224         # 2) python-exec should be built with all targets forced anyway
225         # but if new targets were added, we may need to force a rebuild
226         # 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4,
227         # just fix :2 since := deps are not supported.
228         if [[ ${_PYTHON_WANT_PYTHON_EXEC2} == 0 ]]; then
229                 die "python-exec:0 is no longer supported, please fix your ebuild to work with python-exec:2"
230         elif [[ ${EAPI} != 4 ]]; then
231                 PYTHON_DEPS+=">=dev-lang/python-exec-2:=[${PYTHON_USEDEP}]"
232         else
233                 PYTHON_DEPS+="dev-lang/python-exec:2[${PYTHON_USEDEP}]"
234         fi
235 }
236 _python_set_globals
237
238 # @FUNCTION: _python_validate_useflags
239 # @INTERNAL
240 # @DESCRIPTION:
241 # Enforce the proper setting of PYTHON_TARGETS.
242 _python_validate_useflags() {
243         debug-print-function ${FUNCNAME} "${@}"
244
245         local i
246
247         for i in "${PYTHON_COMPAT[@]}"; do
248                 _python_impl_supported "${i}" || continue
249
250                 use "python_targets_${i}" && return 0
251         done
252
253         eerror "No Python implementation selected for the build. Please add one"
254         eerror "of the following values to your PYTHON_TARGETS (in make.conf):"
255         eerror
256         eerror "${PYTHON_COMPAT[@]}"
257         echo
258         die "No supported Python implementation in PYTHON_TARGETS."
259 }
260
261 # @FUNCTION: python_gen_usedep
262 # @USAGE: <pattern> [...]
263 # @DESCRIPTION:
264 # Output a USE dependency string for Python implementations which
265 # are both in PYTHON_COMPAT and match any of the patterns passed
266 # as parameters to the function.
267 #
268 # Remember to escape or quote the patterns to prevent shell filename
269 # expansion.
270 #
271 # When all implementations are requested, please use ${PYTHON_USEDEP}
272 # instead. Please also remember to set an appropriate REQUIRED_USE
273 # to avoid ineffective USE flags.
274 #
275 # Example:
276 # @CODE
277 # PYTHON_COMPAT=( python{2_7,3_4} )
278 # DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )"
279 # @CODE
280 #
281 # It will cause the dependency to look like:
282 # @CODE
283 # DEPEND="doc? ( dev-python/epydoc[python_targets_python2_7?] )"
284 # @CODE
285 python_gen_usedep() {
286         debug-print-function ${FUNCNAME} "${@}"
287
288         local impl pattern
289         local matches=()
290
291         for impl in "${PYTHON_COMPAT[@]}"; do
292                 _python_impl_supported "${impl}" || continue
293
294                 for pattern; do
295                         if [[ ${impl} == ${pattern} ]]; then
296                                 matches+=(
297                                         "python_targets_${impl}(-)?"
298                                         "-python_single_target_${impl}(-)"
299                                 )
300                                 break
301                         fi
302                 done
303         done
304
305         [[ ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}"
306
307         local out=${matches[@]}
308         echo "${out// /,}"
309 }
310
311 # @FUNCTION: python_gen_useflags
312 # @USAGE: <pattern> [...]
313 # @DESCRIPTION:
314 # Output a list of USE flags for Python implementations which
315 # are both in PYTHON_COMPAT and match any of the patterns passed
316 # as parameters to the function.
317 #
318 # Example:
319 # @CODE
320 # PYTHON_COMPAT=( python{2_7,3_4} )
321 # REQUIRED_USE="doc? ( || ( $(python_gen_useflags python2*) ) )"
322 # @CODE
323 #
324 # It will cause the variable to look like:
325 # @CODE
326 # REQUIRED_USE="doc? ( || ( python_targets_python2_7 ) )"
327 # @CODE
328 python_gen_useflags() {
329         debug-print-function ${FUNCNAME} "${@}"
330
331         local impl pattern
332         local matches=()
333
334         for impl in "${PYTHON_COMPAT[@]}"; do
335                 _python_impl_supported "${impl}" || continue
336
337                 for pattern; do
338                         if [[ ${impl} == ${pattern} ]]; then
339                                 matches+=( "python_targets_${impl}" )
340                                 break
341                         fi
342                 done
343         done
344
345         echo "${matches[@]}"
346 }
347
348 # @FUNCTION: python_gen_cond_dep
349 # @USAGE: <dependency> <pattern> [...]
350 # @DESCRIPTION:
351 # Output a list of <dependency>-ies made conditional to USE flags
352 # of Python implementations which are both in PYTHON_COMPAT and match
353 # any of the patterns passed as the remaining parameters.
354 #
355 # In order to enforce USE constraints on the packages, verbatim
356 # '${PYTHON_USEDEP}' (quoted!) may be placed in the dependency
357 # specification. It will get expanded within the function into a proper
358 # USE dependency string.
359 #
360 # Example:
361 # @CODE
362 # PYTHON_COMPAT=( python{2_7,3_{3,4}} pypy )
363 # RDEPEND="$(python_gen_cond_dep \
364 #   'dev-python/unittest2[${PYTHON_USEDEP}]' python2_7 pypy )"
365 # @CODE
366 #
367 # It will cause the variable to look like:
368 # @CODE
369 # RDEPEND="python_targets_python2_7? (
370 #     dev-python/unittest2[python_targets_python2_7?] )
371 #       python_targets_pypy? (
372 #     dev-python/unittest2[python_targets_pypy?] )"
373 # @CODE
374 python_gen_cond_dep() {
375         debug-print-function ${FUNCNAME} "${@}"
376
377         local impl pattern
378         local matches=()
379
380         local dep=${1}
381         shift
382
383         for impl in "${PYTHON_COMPAT[@]}"; do
384                 _python_impl_supported "${impl}" || continue
385
386                 for pattern; do
387                         if [[ ${impl} == ${pattern} ]]; then
388                                 # substitute ${PYTHON_USEDEP} if used
389                                 # (since python_gen_usedep() will not return ${PYTHON_USEDEP}
390                                 #  the code is run at most once)
391                                 if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
392                                         local PYTHON_USEDEP=$(python_gen_usedep "${@}")
393                                         dep=${dep//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}}
394                                 fi
395
396                                 matches+=( "python_targets_${impl}? ( ${dep} )" )
397                                 break
398                         fi
399                 done
400         done
401
402         echo "${matches[@]}"
403 }
404
405 # @ECLASS-VARIABLE: BUILD_DIR
406 # @DESCRIPTION:
407 # The current build directory. In global scope, it is supposed to
408 # contain an initial build directory; if unset, it defaults to ${S}.
409 #
410 # In functions run by python_foreach_impl(), the BUILD_DIR is locally
411 # set to an implementation-specific build directory. That path is
412 # created through appending a hyphen and the implementation name
413 # to the final component of the initial BUILD_DIR.
414 #
415 # Example value:
416 # @CODE
417 # ${WORKDIR}/foo-1.3-python2_7
418 # @CODE
419
420 # @FUNCTION: python_copy_sources
421 # @DESCRIPTION:
422 # Create a single copy of the package sources for each enabled Python
423 # implementation.
424 #
425 # The sources are always copied from initial BUILD_DIR (or S if unset)
426 # to implementation-specific build directory matching BUILD_DIR used by
427 # python_foreach_abi().
428 python_copy_sources() {
429         debug-print-function ${FUNCNAME} "${@}"
430
431         local MULTIBUILD_VARIANTS
432         _python_obtain_impls
433
434         multibuild_copy_sources
435 }
436
437 # @FUNCTION: _python_obtain_impls
438 # @INTERNAL
439 # @DESCRIPTION:
440 # Set up the enabled implementation list.
441 _python_obtain_impls() {
442         if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
443                 if [[ ! ${_PYTHON_COMPAT_OVERRIDE_WARNED} ]]; then
444                         ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python"
445                         ewarn "implementations will be enabled:"
446                         ewarn
447                         ewarn " ${PYTHON_COMPAT_OVERRIDE}"
448                         ewarn
449                         ewarn "Dependencies won't be satisfied, and PYTHON_TARGETS will be ignored."
450                         _PYTHON_COMPAT_OVERRIDE_WARNED=1
451                 fi
452
453                 MULTIBUILD_VARIANTS=( ${PYTHON_COMPAT_OVERRIDE} )
454                 return
455         fi
456
457         _python_validate_useflags
458
459         MULTIBUILD_VARIANTS=()
460
461         for impl in "${_PYTHON_ALL_IMPLS[@]}"; do
462                 if has "${impl}" "${PYTHON_COMPAT[@]}" \
463                         && use "python_targets_${impl}"
464                 then
465                         MULTIBUILD_VARIANTS+=( "${impl}" )
466                 fi
467         done
468 }
469
470 # @FUNCTION: _python_multibuild_wrapper
471 # @USAGE: <command> [<args>...]
472 # @INTERNAL
473 # @DESCRIPTION:
474 # Initialize the environment for Python implementation selected
475 # for multibuild.
476 _python_multibuild_wrapper() {
477         debug-print-function ${FUNCNAME} "${@}"
478
479         local -x EPYTHON PYTHON
480         local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
481         python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON
482         python_wrapper_setup
483
484         "${@}"
485 }
486
487 # @FUNCTION: python_foreach_impl
488 # @USAGE: <command> [<args>...]
489 # @DESCRIPTION:
490 # Run the given command for each of the enabled Python implementations.
491 # If additional parameters are passed, they will be passed through
492 # to the command.
493 #
494 # The function will return 0 status if all invocations succeed.
495 # Otherwise, the return code from first failing invocation will
496 # be returned.
497 #
498 # For each command being run, EPYTHON, PYTHON and BUILD_DIR are set
499 # locally, and the former two are exported to the command environment.
500 python_foreach_impl() {
501         debug-print-function ${FUNCNAME} "${@}"
502
503         local MULTIBUILD_VARIANTS
504         _python_obtain_impls
505
506         multibuild_foreach_variant _python_multibuild_wrapper "${@}"
507 }
508
509 # @FUNCTION: python_parallel_foreach_impl
510 # @USAGE: <command> [<args>...]
511 # @DESCRIPTION:
512 # Run the given command for each of the enabled Python implementations.
513 # If additional parameters are passed, they will be passed through
514 # to the command.
515 #
516 # The function will return 0 status if all invocations succeed.
517 # Otherwise, the return code from first failing invocation will
518 # be returned.
519 #
520 # For each command being run, EPYTHON, PYTHON and BUILD_DIR are set
521 # locally, and the former two are exported to the command environment.
522 #
523 # This command used to be the parallel variant of python_foreach_impl.
524 # However, the parallel run support has been removed to simplify
525 # the eclasses and make them more predictable and therefore it is now
526 # only a deprecated alias to python_foreach_impl.
527 python_parallel_foreach_impl() {
528         debug-print-function ${FUNCNAME} "${@}"
529
530         [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}"
531
532         if [[ ! ${_PYTHON_PARALLEL_WARNED} ]]; then
533                 eqawarn "python_parallel_foreach_impl() is no longer meaningful. All runs"
534                 eqawarn "are non-parallel now. Please replace the call with python_foreach_impl."
535
536                 _PYTHON_PARALLEL_WARNED=1
537         fi
538
539         local MULTIBUILD_VARIANTS
540         _python_obtain_impls
541         multibuild_foreach_variant _python_multibuild_wrapper "${@}"
542 }
543
544 # @FUNCTION: python_setup
545 # @USAGE: [<impl-pattern>...]
546 # @DESCRIPTION:
547 # Find the best (most preferred) Python implementation that is enabled
548 # and matches at least one of the patterns passed (or '*' if no patterns
549 # passed). Set the Python build environment up for that implementation.
550 #
551 # This function needs to be used when Python is being called outside
552 # of python_foreach_impl calls (e.g. for shared processes like doc
553 # building). python_foreach_impl sets up the build environment itself.
554 #
555 # If the specific commands support only a subset of Python
556 # implementations, patterns need to be passed to restrict the allowed
557 # implementations.
558 #
559 # Example:
560 # @CODE
561 # DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )"
562 #
563 # src_compile() {
564 #   #...
565 #   if use doc; then
566 #     python_setup 'python2*'
567 #     make doc
568 #   fi
569 # }
570 # @CODE
571 python_setup() {
572         debug-print-function ${FUNCNAME} "${@}"
573
574         local best_impl patterns=( "${@-*}" )
575         _python_try_impl() {
576                 local pattern
577                 for pattern in "${patterns[@]}"; do
578                         if [[ ${EPYTHON} == ${pattern} ]]; then
579                                 best_impl=${EPYTHON}
580                         fi
581                 done
582         }
583         python_foreach_impl _python_try_impl
584
585         if [[ ! ${best_impl} ]]; then
586                 eerror "${FUNCNAME}: none of the enabled implementation matched the patterns."
587                 eerror "  patterns: ${@-'(*)'}"
588                 eerror "Likely a REQUIRED_USE constraint (possibly USE-conditional) is missing."
589                 eerror "  suggested: || ( \$(python_gen_useflags ${@}) )"
590                 eerror "(remember to quote all the patterns with '')"
591                 die "${FUNCNAME}: no enabled implementation satisfy requirements"
592         fi
593
594         python_export "${best_impl}" EPYTHON PYTHON
595         python_wrapper_setup
596 }
597
598 # @FUNCTION: python_export_best
599 # @USAGE: [<variable>...]
600 # @DESCRIPTION:
601 # Find the best (most preferred) Python implementation enabled
602 # and export given variables for it. If no variables are provided,
603 # EPYTHON & PYTHON will be exported.
604 python_export_best() {
605         debug-print-function ${FUNCNAME} "${@}"
606
607         [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}"
608
609         eqawarn "python_export_best() is deprecated. Please use python_setup instead,"
610         eqawarn "combined with python_export if necessary."
611
612         [[ ${#} -gt 0 ]] || set -- EPYTHON PYTHON
613
614         local best MULTIBUILD_VARIANTS
615         _python_obtain_impls
616
617         _python_set_best() {
618                 best=${MULTIBUILD_VARIANT}
619         }
620         multibuild_for_best_variant _python_set_best
621
622         debug-print "${FUNCNAME}: Best implementation is: ${best}"
623         python_export "${best}" "${@}"
624         python_wrapper_setup
625 }
626
627 # @FUNCTION: python_replicate_script
628 # @USAGE: <path>...
629 # @DESCRIPTION:
630 # Copy the given script to variants for all enabled Python
631 # implementations, then replace it with a symlink to the wrapper.
632 #
633 # All specified files must start with a 'python' shebang. A file not
634 # having a matching shebang will be refused.
635 python_replicate_script() {
636         debug-print-function ${FUNCNAME} "${@}"
637
638         _python_replicate_script() {
639                 local _PYTHON_FIX_SHEBANG_QUIET=1
640
641                 local PYTHON_SCRIPTDIR
642                 python_export PYTHON_SCRIPTDIR
643
644                 (
645                         exeinto "${PYTHON_SCRIPTDIR#${EPREFIX}}"
646                         doexe "${files[@]}"
647                 )
648
649                 python_fix_shebang -q \
650                         "${files[@]/*\//${D%/}/${PYTHON_SCRIPTDIR}/}"
651         }
652
653         local files=( "${@}" )
654         python_foreach_impl _python_replicate_script
655
656         # install the wrappers
657         local f
658         for f; do
659                 _python_ln_rel "${ED%/}/usr/lib/python-exec/python-exec2" "${f}" || die
660         done
661 }
662
663 _PYTHON_R1=1
664 fi