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

Contents of /eclass/distutils-r1.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.101 - (show annotations) (download)
Tue Jul 8 08:49:10 2014 UTC (3 months, 1 week ago) by mgorny
Branch: MAIN
Changes since 1.100: +4 -1 lines
Support linking Python modules on aix, thanks to haubi.

1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.100 2014/06/29 14:24:22 floppym Exp $
4
5 # @ECLASS: distutils-r1
6 # @MAINTAINER:
7 # Python team <python@gentoo.org>
8 # @AUTHOR:
9 # Author: Michał Górny <mgorny@gentoo.org>
10 # Based on the work of: Krzysztof Pawlik <nelchael@gentoo.org>
11 # @BLURB: A simple eclass to build Python packages using distutils.
12 # @DESCRIPTION:
13 # A simple eclass providing functions to build Python packages using
14 # the distutils build system. It exports phase functions for all
15 # the src_* phases. Each of the phases runs two pseudo-phases:
16 # python_..._all() (e.g. python_prepare_all()) once in ${S}, then
17 # python_...() (e.g. python_prepare()) for each implementation
18 # (see: python_foreach_impl() in python-r1).
19 #
20 # In distutils-r1_src_prepare(), the 'all' function is run before
21 # per-implementation ones (because it creates the implementations),
22 # per-implementation functions are run in a random order.
23 #
24 # In remaining phase functions, the per-implementation functions are run
25 # before the 'all' one, and they are ordered from the least to the most
26 # preferred implementation (so that 'better' files overwrite 'worse'
27 # ones).
28 #
29 # If the ebuild doesn't specify a particular pseudo-phase function,
30 # the default one will be used (distutils-r1_...). Defaults are provided
31 # for all per-implementation pseudo-phases, python_prepare_all()
32 # and python_install_all(); whenever writing your own pseudo-phase
33 # functions, you should consider calling the defaults (and especially
34 # distutils-r1_python_prepare_all).
35 #
36 # Please note that distutils-r1 sets RDEPEND and DEPEND unconditionally
37 # for you.
38 #
39 # Also, please note that distutils-r1 will always inherit python-r1
40 # as well. Thus, all the variables defined and documented there are
41 # relevant to the packages using distutils-r1.
42 #
43 # For more information, please see the python-r1 Developer's Guide:
44 # http://www.gentoo.org/proj/en/Python/python-r1/dev-guide.xml
45
46 case "${EAPI:-0}" in
47 0|1|2|3)
48 die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
49 ;;
50 4|5)
51 ;;
52 *)
53 die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
54 ;;
55 esac
56
57 # @ECLASS-VARIABLE: DISTUTILS_OPTIONAL
58 # @DEFAULT_UNSET
59 # @DESCRIPTION:
60 # If set to a non-null value, distutils part in the ebuild will
61 # be considered optional. No dependencies will be added and no phase
62 # functions will be exported.
63 #
64 # If you enable DISTUTILS_OPTIONAL, you have to set proper dependencies
65 # for your package (using ${PYTHON_DEPS}) and to either call
66 # distutils-r1 default phase functions or call the build system
67 # manually.
68
69 # @ECLASS-VARIABLE: DISTUTILS_SINGLE_IMPL
70 # @DEFAULT_UNSET
71 # @DESCRIPTION:
72 # If set to a non-null value, the ebuild will support setting a single
73 # Python implementation only. It will effectively replace the python-r1
74 # eclass inherit with python-single-r1.
75 #
76 # Note that inheriting python-single-r1 will cause pkg_setup()
77 # to be exported. It must be run in order for the eclass functions
78 # to function properly.
79
80 if [[ ! ${_DISTUTILS_R1} ]]; then
81
82 inherit eutils toolchain-funcs
83
84 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
85 inherit multiprocessing python-r1
86 else
87 inherit python-single-r1
88 fi
89
90 fi
91
92 if [[ ! ${DISTUTILS_OPTIONAL} ]]; then
93 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
94 fi
95
96 if [[ ! ${_DISTUTILS_R1} ]]; then
97
98 if [[ ! ${DISTUTILS_OPTIONAL} ]]; then
99 RDEPEND=${PYTHON_DEPS}
100 DEPEND=${PYTHON_DEPS}
101 REQUIRED_USE=${PYTHON_REQUIRED_USE}
102 fi
103
104 # @ECLASS-VARIABLE: PATCHES
105 # @DEFAULT_UNSET
106 # @DESCRIPTION:
107 # An array containing patches to be applied to the sources before
108 # copying them.
109 #
110 # If unset, no custom patches will be applied.
111 #
112 # Please note, however, that at some point the eclass may apply
113 # additional distutils patches/quirks independently of this variable.
114 #
115 # Example:
116 # @CODE
117 # PATCHES=( "${FILESDIR}"/${P}-make-gentoo-happy.patch )
118 # @CODE
119
120 # @ECLASS-VARIABLE: DOCS
121 # @DEFAULT_UNSET
122 # @DESCRIPTION:
123 # An array containing documents installed using dodoc. The files listed
124 # there must exist in the directory from which
125 # distutils-r1_python_install_all() is run (${S} by default).
126 #
127 # If unset, the function will instead look up files matching default
128 # filename pattern list (from the Package Manager Specification),
129 # and install those found.
130 #
131 # Example:
132 # @CODE
133 # DOCS=( NEWS README )
134 # @CODE
135
136 # @ECLASS-VARIABLE: HTML_DOCS
137 # @DEFAULT_UNSET
138 # @DESCRIPTION:
139 # An array containing documents installed using dohtml. The files
140 # and directories listed there must exist in the directory from which
141 # distutils-r1_python_install_all() is run (${S} by default).
142 #
143 # If unset, no HTML docs will be installed.
144 #
145 # Example:
146 # @CODE
147 # HTML_DOCS=( doc/html/. )
148 # @CODE
149
150 # @ECLASS-VARIABLE: EXAMPLES
151 # @DEFAULT_UNSET
152 # @DESCRIPTION:
153 # An array containing examples installed into 'examples' doc
154 # subdirectory. The files and directories listed there must exist
155 # in the directory from which distutils-r1_python_install_all() is run
156 # (${S} by default).
157 #
158 # The 'examples' subdirectory will be marked not to be compressed
159 # automatically.
160 #
161 # If unset, no examples will be installed.
162 #
163 # Example:
164 # @CODE
165 # EXAMPLES=( examples/. demos/. )
166 # @CODE
167
168 # @ECLASS-VARIABLE: DISTUTILS_IN_SOURCE_BUILD
169 # @DEFAULT_UNSET
170 # @DESCRIPTION:
171 # If set to a non-null value, in-source builds will be enabled.
172 # If unset, the default is to use in-source builds when python_prepare()
173 # is declared, and out-of-source builds otherwise.
174 #
175 # If in-source builds are used, the eclass will create a copy of package
176 # sources for each Python implementation in python_prepare_all(),
177 # and work on that copy afterwards.
178 #
179 # If out-of-source builds are used, the eclass will instead work
180 # on the sources directly, prepending setup.py arguments with
181 # 'build --build-base ${BUILD_DIR}' to enforce keeping & using built
182 # files in the specific root.
183
184 # @ECLASS-VARIABLE: DISTUTILS_NO_PARALLEL_BUILD
185 # @DEFAULT_UNSET
186 # @DESCRIPTION:
187 # If set to a non-null value, the parallel build feature will
188 # be disabled.
189 #
190 # When parallel builds are used, the implementation-specific sub-phases
191 # for selected Python implementation will be run in parallel. This will
192 # increase build efficiency with distutils which does not do parallel
193 # builds.
194 #
195 # This variable can be used to disable the afore-mentioned feature
196 # in case it causes issues with the package.
197
198 # @ECLASS-VARIABLE: mydistutilsargs
199 # @DEFAULT_UNSET
200 # @DESCRIPTION:
201 # An array containing options to be passed to setup.py.
202 #
203 # Example:
204 # @CODE
205 # python_configure_all() {
206 # mydistutilsargs=( --enable-my-hidden-option )
207 # }
208 # @CODE
209
210 # @FUNCTION: esetup.py
211 # @USAGE: [<args>...]
212 # @DESCRIPTION:
213 # Run setup.py using currently selected Python interpreter
214 # (if ${PYTHON} is set; fallback 'python' otherwise).
215 #
216 # setup.py will be passed the following, in order:
217 # 1. ${mydistutilsargs[@]}
218 # 2. additional arguments passed to the esetup.py function.
219 #
220 # This command dies on failure.
221 esetup.py() {
222 debug-print-function ${FUNCNAME} "${@}"
223
224 set -- "${PYTHON:-python}" setup.py "${mydistutilsargs[@]}" "${@}"
225
226 echo "${@}" >&2
227 "${@}" || die
228 }
229
230 # @FUNCTION: distutils_install_for_testing
231 # @USAGE: [<args>...]
232 # @DESCRIPTION:
233 # Install the package into a temporary location for running tests.
234 # Update PYTHONPATH appropriately and set TEST_DIR to the test
235 # installation root. The Python packages will be installed in 'lib'
236 # subdir, and scripts in 'scripts' subdir (like in BUILD_DIR).
237 #
238 # Please note that this function should be only used if package uses
239 # namespaces (and therefore proper install needs to be done to enforce
240 # PYTHONPATH) or tests rely on the results of install command.
241 # For most of the packages, tests built in BUILD_DIR are good enough.
242 distutils_install_for_testing() {
243 debug-print-function ${FUNCNAME} "${@}"
244
245 # A few notes:
246 # 1) because of namespaces, we can't use 'install --root',
247 # 2) 'install --home' is terribly broken on pypy, so we need
248 # to override --install-lib and --install-scripts,
249 # 3) non-root 'install' complains about PYTHONPATH and missing dirs,
250 # so we need to set it properly and mkdir them,
251 # 4) it runs a bunch of commands which write random files to cwd,
252 # in order to avoid that, we add the necessary path overrides
253 # in _distutils-r1_create_setup_cfg.
254
255 TEST_DIR=${BUILD_DIR}/test
256 local bindir=${TEST_DIR}/scripts
257 local libdir=${TEST_DIR}/lib
258 PYTHONPATH=${libdir}:${PYTHONPATH}
259
260 local add_args=(
261 install
262 --home="${TEST_DIR}"
263 --install-lib="${libdir}"
264 --install-scripts="${bindir}"
265 )
266
267 mkdir -p "${libdir}" || die
268 esetup.py "${add_args[@]}" "${@}"
269 }
270
271 # @FUNCTION: _distutils-r1_disable_ez_setup
272 # @INTERNAL
273 # @DESCRIPTION:
274 # Stub out ez_setup.py and distribute_setup.py to prevent packages
275 # from trying to download a local copy of setuptools.
276 _distutils-r1_disable_ez_setup() {
277 local stub="def use_setuptools(*args, **kwargs): pass"
278 if [[ -f ez_setup.py ]]; then
279 echo "${stub}" > ez_setup.py || die
280 fi
281 if [[ -f distribute_setup.py ]]; then
282 echo "${stub}" > distribute_setup.py || die
283 fi
284 }
285
286 # @FUNCTION: distutils-r1_python_prepare_all
287 # @DESCRIPTION:
288 # The default python_prepare_all(). It applies the patches from PATCHES
289 # array, then user patches and finally calls python_copy_sources to
290 # create copies of resulting sources for each Python implementation.
291 #
292 # At some point in the future, it may also apply eclass-specific
293 # distutils patches and/or quirks.
294 distutils-r1_python_prepare_all() {
295 debug-print-function ${FUNCNAME} "${@}"
296
297 [[ ${PATCHES} ]] && epatch "${PATCHES[@]}"
298
299 epatch_user
300
301 # by default, use in-source build if python_prepare() is used
302 if [[ ! ${DISTUTILS_IN_SOURCE_BUILD+1} ]]; then
303 if declare -f python_prepare >/dev/null; then
304 DISTUTILS_IN_SOURCE_BUILD=1
305 fi
306 fi
307
308 _distutils-r1_disable_ez_setup
309
310 if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
311 then
312 # create source copies for each implementation
313 python_copy_sources
314 fi
315
316 _DISTUTILS_DEFAULT_CALLED=1
317 }
318
319 # @FUNCTION: distutils-r1_python_prepare
320 # @DESCRIPTION:
321 # The default python_prepare(). A no-op.
322 distutils-r1_python_prepare() {
323 debug-print-function ${FUNCNAME} "${@}"
324
325 :
326 }
327
328 # @FUNCTION: distutils-r1_python_configure
329 # @DESCRIPTION:
330 # The default python_configure(). A no-op.
331 distutils-r1_python_configure() {
332 debug-print-function ${FUNCNAME} "${@}"
333
334 :
335 }
336
337 # @FUNCTION: _distutils-r1_create_setup_cfg
338 # @INTERNAL
339 # @DESCRIPTION:
340 # Create implementation-specific configuration file for distutils,
341 # setting proper build-dir paths.
342 _distutils-r1_create_setup_cfg() {
343 cat > "${HOME}"/.pydistutils.cfg <<-_EOF_ || die
344 [build]
345 build-base = ${BUILD_DIR}
346
347 # using a single directory for them helps us export
348 # ${PYTHONPATH} and ebuilds find the sources independently
349 # of whether the package installs extensions or not
350 #
351 # note: due to some packages (wxpython) relying on separate
352 # platlib & purelib dirs, we do not set --build-lib (which
353 # can not be overriden with --build-*lib)
354 build-platlib = %(build-base)s/lib
355 build-purelib = %(build-base)s/lib
356
357 # make the ebuild writer lives easier
358 build-scripts = %(build-base)s/scripts
359
360 [egg_info]
361 egg-base = ${BUILD_DIR}
362
363 # this is needed by distutils_install_for_testing since
364 # setuptools like to create .egg files for install --home.
365 [bdist_egg]
366 dist-dir = ${BUILD_DIR}/dist
367 _EOF_
368 }
369
370 # @FUNCTION: _distutils-r1_copy_egg_info
371 # @INTERNAL
372 # @DESCRIPTION:
373 # Copy egg-info files to the ${BUILD_DIR} (that's going to become
374 # egg-base in esetup.py). This way, we respect whatever's in upstream
375 # egg-info.
376 _distutils-r1_copy_egg_info() {
377 mkdir -p "${BUILD_DIR}" || die
378 # stupid freebsd can't do 'cp -t ${BUILD_DIR} {} +'
379 find -name '*.egg-info' -type d -exec cp -pr {} "${BUILD_DIR}"/ ';' || die
380 }
381
382 # @FUNCTION: distutils-r1_python_compile
383 # @USAGE: [additional-args...]
384 # @DESCRIPTION:
385 # The default python_compile(). Runs 'esetup.py build'. Any parameters
386 # passed to this function will be appended to setup.py invocation,
387 # i.e. passed as options to the 'build' command.
388 distutils-r1_python_compile() {
389 debug-print-function ${FUNCNAME} "${@}"
390
391 _distutils-r1_create_setup_cfg
392 _distutils-r1_copy_egg_info
393
394 esetup.py build "${@}"
395 }
396
397 # @FUNCTION: _distutils-r1_wrap_scripts
398 # @USAGE: <path> <bindir>
399 # @INTERNAL
400 # @DESCRIPTION:
401 # Moves and wraps all installed scripts/executables as necessary.
402 _distutils-r1_wrap_scripts() {
403 debug-print-function ${FUNCNAME} "${@}"
404
405 [[ ${#} -eq 2 ]] || die "usage: ${FUNCNAME} <path> <bindir>"
406 local path=${1}
407 local bindir=${2}
408
409 if ! _python_want_python_exec2; then
410 local PYTHON_SCRIPTDIR=${bindir}
411 fi
412
413 local f python_files=() non_python_files=()
414
415 if [[ -d ${path}${PYTHON_SCRIPTDIR} ]]; then
416 for f in "${path}${PYTHON_SCRIPTDIR}"/*; do
417 [[ -d ${f} ]] && die "Unexpected directory: ${f}"
418 debug-print "${FUNCNAME}: found executable at ${f#${path}/}"
419
420 local shebang
421 read -r shebang < "${f}"
422 if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then
423 debug-print "${FUNCNAME}: matching shebang: ${shebang}"
424 python_files+=( "${f}" )
425 elif _python_want_python_exec2; then
426 debug-print "${FUNCNAME}: non-matching shebang: ${shebang}"
427 non_python_files+=( "${f}" )
428 fi
429
430 mkdir -p "${path}${bindir}" || die
431 done
432
433 for f in "${python_files[@]}"; do
434 local basename=${f##*/}
435
436 if ! _python_want_python_exec2; then
437 local newf=${f%/*}/${basename}-${EPYTHON}
438 debug-print "${FUNCNAME}: renaming ${f#${path}/} to ${newf#${path}/}"
439 mv "${f}" "${newf}" || die
440 fi
441
442 debug-print "${FUNCNAME}: installing wrapper at ${bindir}/${basename}"
443 _python_ln_rel "${path}${EPREFIX}"$(_python_get_wrapper_path) \
444 "${path}${bindir}/${basename}" || die
445 done
446
447 # (non-empty only with python-exec:2)
448 for f in "${non_python_files[@]}"; do
449 local basename=${f##*/}
450
451 debug-print "${FUNCNAME}: moving ${f#${path}/} to ${bindir}/${basename}"
452 mv "${f}" "${path}${bindir}/${basename}" || die
453 done
454 fi
455 }
456
457 # @FUNCTION: distutils-r1_python_install
458 # @USAGE: [additional-args...]
459 # @DESCRIPTION:
460 # The default python_install(). Runs 'esetup.py install', appending
461 # the optimization flags. Then renames the installed scripts.
462 # Any parameters passed to this function will be appended
463 # to the setup.py invocation (i.e. as options to the 'install' command).
464 distutils-r1_python_install() {
465 debug-print-function ${FUNCNAME} "${@}"
466
467 local args=( "${@}" )
468 local flags
469
470 case "${EPYTHON}" in
471 jython*)
472 flags=(--compile);;
473 *)
474 flags=(--compile -O2);;
475 esac
476 debug-print "${FUNCNAME}: [${EPYTHON}] flags: ${flags}"
477
478 # enable compilation for the install phase.
479 local -x PYTHONDONTWRITEBYTECODE=
480
481 # python likes to compile any module it sees, which triggers sandbox
482 # failures if some packages haven't compiled their modules yet.
483 addpredict "$(python_get_sitedir)"
484 addpredict /usr/lib/portage/pym
485 addpredict /usr/local # bug 498232
486
487 local root=${D}/_${EPYTHON}
488 [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
489 flags+=( --root="${root}" )
490
491 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
492 # user may override --install-scripts
493 # note: this is poor but distutils argv parsing is dumb
494 local mydistutilsargs=( "${mydistutilsargs[@]}" )
495 local scriptdir=${EPREFIX}/usr/bin
496
497 # construct a list of mydistutilsargs[0] args[0] args[1]...
498 local arg arg_vars
499 [[ ${mydistutilsargs[@]} ]] && eval arg_vars+=(
500 'mydistutilsargs['{0..$(( ${#mydistutilsargs[@]} - 1 ))}']'
501 )
502 [[ ${args[@]} ]] && eval arg_vars+=(
503 'args['{0..$(( ${#args[@]} - 1 ))}']'
504 )
505
506 set -- "${arg_vars[@]}"
507 while [[ ${@} ]]; do
508 local arg_var=${1}
509 shift
510 local a=${!arg_var}
511
512 case "${a}" in
513 --install-scripts=*)
514 scriptdir=${a#--install-scripts=}
515 if _python_want_python_exec2; then
516 unset "${arg_var}"
517 fi
518 ;;
519 --install-scripts)
520 scriptdir=${!1}
521 if _python_want_python_exec2; then
522 unset "${arg_var}" "${1}"
523 fi
524 shift
525 ;;
526 esac
527 done
528
529 if _python_want_python_exec2; then
530 local PYTHON_SCRIPTDIR
531 python_export PYTHON_SCRIPTDIR
532 flags+=( --install-scripts="${PYTHON_SCRIPTDIR}" )
533 fi
534 fi
535
536 esetup.py install "${flags[@]}" "${args[@]}"
537
538 if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
539 die "Package installs 'tests' package, file collisions likely."
540 fi
541 if [[ -d ${root}/usr/$(get_libdir)/pypy/share ]]; then
542 die "Package installs 'share' in PyPy prefix, see bug #465546."
543 fi
544
545 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
546 _distutils-r1_wrap_scripts "${root}" "${scriptdir}"
547 multibuild_merge_root "${root}" "${D}"
548 fi
549 }
550
551 # @FUNCTION: distutils-r1_python_install_all
552 # @DESCRIPTION:
553 # The default python_install_all(). It installs the documentation.
554 distutils-r1_python_install_all() {
555 debug-print-function ${FUNCNAME} "${@}"
556
557 einstalldocs
558
559 if declare -p EXAMPLES &>/dev/null; then
560 local INSDESTTREE=/usr/share/doc/${PF}/examples
561 doins -r "${EXAMPLES[@]}"
562 docompress -x "${INSDESTTREE}"
563 fi
564
565 _DISTUTILS_DEFAULT_CALLED=1
566 }
567
568 # @FUNCTION: distutils-r1_run_phase
569 # @USAGE: [<argv>...]
570 # @INTERNAL
571 # @DESCRIPTION:
572 # Run the given command.
573 #
574 # If out-of-source builds are used, the phase function is run in source
575 # directory, with BUILD_DIR pointing at the build directory
576 # and PYTHONPATH having an entry for the module build directory.
577 #
578 # If in-source builds are used, the command is executed in the directory
579 # holding the per-implementation copy of sources. BUILD_DIR points
580 # to the 'build' subdirectory.
581 distutils-r1_run_phase() {
582 debug-print-function ${FUNCNAME} "${@}"
583
584 if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
585 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
586 pushd "${BUILD_DIR}" >/dev/null || die
587 fi
588 local BUILD_DIR=${BUILD_DIR}/build
589 fi
590 local -x PYTHONPATH="${BUILD_DIR}/lib:${PYTHONPATH}"
591
592 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
593 local -x TMPDIR=${T}/${EPYTHON}
594 local -x HOME=${TMPDIR}/home
595
596 mkdir -p "${TMPDIR}" "${HOME}" || die
597 fi
598
599 # Set up build environment, bug #513664.
600 local -x AR=${AR} CC=${CC} CPP=${CPP} CXX=${CXX}
601 tc-export AR CC CPP CXX
602
603 # How to build Python modules in different worlds...
604 local ldopts
605 case "${CHOST}" in
606 # provided by haubi, 2014-07-08
607 *-aix*) ldopts='-shared -Wl,-berok';; # good enough
608 # provided by grobian, 2014-06-22, bug #513664 c7
609 *-darwin*) ldopts='-bundle -undefined dynamic_lookup';;
610 *) ldopts='-shared';;
611 esac
612
613 local -x LDSHARED="${CC} ${ldopts}" LDCXXSHARED="${CXX} ${ldopts}"
614
615 "${@}"
616
617 if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
618 then
619 popd >/dev/null || die
620 fi
621 }
622
623 # @FUNCTION: _distutils-r1_run_common_phase
624 # @USAGE: [<argv>...]
625 # @INTERNAL
626 # @DESCRIPTION:
627 # Run the given command, restoring the best-implementation state.
628 #
629 # If in-source build is used, the command will be run in the copy
630 # of sources made for the best Python interpreter.
631 _distutils-r1_run_common_phase() {
632 local DISTUTILS_ORIG_BUILD_DIR=${BUILD_DIR}
633
634 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
635 local MULTIBUILD_VARIANTS
636 _python_obtain_impls
637
638 multibuild_for_best_variant _python_multibuild_wrapper \
639 distutils-r1_run_phase "${@}"
640 else
641 # semi-hack, be careful.
642 _distutils-r1_run_foreach_impl "${@}"
643 fi
644 }
645
646 # @FUNCTION: _distutils-r1_run_foreach_impl
647 # @INTERNAL
648 # @DESCRIPTION:
649 # Run the given phase for each implementation if multiple implementations
650 # are enabled, once otherwise.
651 _distutils-r1_run_foreach_impl() {
652 debug-print-function ${FUNCNAME} "${@}"
653
654 set -- distutils-r1_run_phase "${@}"
655
656 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
657 if [[ ${DISTUTILS_NO_PARALLEL_BUILD} || ${DISTUTILS_SINGLE_IMPL} ]]
658 then
659 python_foreach_impl "${@}"
660 else
661 python_parallel_foreach_impl "${@}"
662 fi
663 else
664 if [[ ! ${EPYTHON} ]]; then
665 die "EPYTHON unset, python-single-r1_pkg_setup not called?!"
666 fi
667 local BUILD_DIR=${BUILD_DIR:-${S}}
668 BUILD_DIR=${BUILD_DIR%%/}_${EPYTHON}
669
670 "${@}"
671 fi
672 }
673
674 distutils-r1_src_prepare() {
675 debug-print-function ${FUNCNAME} "${@}"
676
677 local _DISTUTILS_DEFAULT_CALLED
678
679 # common preparations
680 if declare -f python_prepare_all >/dev/null; then
681 python_prepare_all
682 else
683 distutils-r1_python_prepare_all
684 fi
685
686 if [[ ! ${_DISTUTILS_DEFAULT_CALLED} ]]; then
687 eqawarn "QA warning: python_prepare_all() didn't call distutils-r1_python_prepare_all"
688 fi
689
690 if declare -f python_prepare >/dev/null; then
691 _distutils-r1_run_foreach_impl python_prepare
692 fi
693 }
694
695 distutils-r1_src_configure() {
696 python_export_utf8_locale
697
698 if declare -f python_configure >/dev/null; then
699 _distutils-r1_run_foreach_impl python_configure
700 fi
701
702 if declare -f python_configure_all >/dev/null; then
703 _distutils-r1_run_common_phase python_configure_all
704 fi
705 }
706
707 distutils-r1_src_compile() {
708 debug-print-function ${FUNCNAME} "${@}"
709
710 if declare -f python_compile >/dev/null; then
711 _distutils-r1_run_foreach_impl python_compile
712 else
713 _distutils-r1_run_foreach_impl distutils-r1_python_compile
714 fi
715
716 if declare -f python_compile_all >/dev/null; then
717 _distutils-r1_run_common_phase python_compile_all
718 fi
719 }
720
721 distutils-r1_src_test() {
722 debug-print-function ${FUNCNAME} "${@}"
723
724 if declare -f python_test >/dev/null; then
725 _distutils-r1_run_foreach_impl python_test
726 fi
727
728 if declare -f python_test_all >/dev/null; then
729 _distutils-r1_run_common_phase python_test_all
730 fi
731 }
732
733 distutils-r1_src_install() {
734 debug-print-function ${FUNCNAME} "${@}"
735
736 if declare -f python_install >/dev/null; then
737 _distutils-r1_run_foreach_impl python_install
738 else
739 _distutils-r1_run_foreach_impl distutils-r1_python_install
740 fi
741
742 local _DISTUTILS_DEFAULT_CALLED
743
744 if declare -f python_install_all >/dev/null; then
745 _distutils-r1_run_common_phase python_install_all
746 else
747 _distutils-r1_run_common_phase distutils-r1_python_install_all
748 fi
749
750 if [[ ! ${_DISTUTILS_DEFAULT_CALLED} ]]; then
751 eqawarn "QA warning: python_install_all() didn't call distutils-r1_python_install_all"
752 fi
753 }
754
755 _DISTUTILS_R1=1
756 fi

  ViewVC Help
Powered by ViewVC 1.1.20