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

Diff of /eclass/python.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.66 Revision 1.74
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.66 2009/08/28 16:08:51 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.74 2009/10/02 02:02:24 arfrever Exp $
4 4
5# @ECLASS: python.eclass 5# @ECLASS: python.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# python@gentoo.org 7# python@gentoo.org
8#
9# original author: Alastair Tse <liquidx@gentoo.org>
10# @BLURB: A Utility Eclass that should be inherited by anything that deals with Python or Python modules. 8# @BLURB: A utility eclass that should be inherited by anything that deals with Python or Python modules.
11# @DESCRIPTION: 9# @DESCRIPTION:
12# Some useful functions for dealing with Python. 10# Some useful functions for dealing with Python.
13 11
14inherit multilib 12inherit multilib
15 13
19 RDEPEND="${DEPEND}" 17 RDEPEND="${DEPEND}"
20else 18else
21 PYTHON_ATOM="dev-lang/python" 19 PYTHON_ATOM="dev-lang/python"
22fi 20fi
23 21
24DEPEND="${DEPEND} >=app-shells/bash-3.2"
25if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
26 DEPEND="${DEPEND} >=app-admin/eselect-python-20090804" 22DEPEND+=" >=app-admin/eselect-python-20090804
27fi 23 >=app-shells/bash-3.2"
28 24
29__python_eclass_test() { 25__python_eclass_test() {
30 __python_version_extract 2.3 26 __python_version_extract 2.3
31 echo -n "2.3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR" 27 echo -n "2.3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
32 echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO" 28 echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
66 export PYVER_ALL="${tmpstr#Python }" 62 export PYVER_ALL="${tmpstr#Python }"
67 __python_version_extract $PYVER_ALL 63 __python_version_extract $PYVER_ALL
68} 64}
69 65
70# @FUNCTION: PYTHON 66# @FUNCTION: PYTHON
71# @USAGE: [-a|--absolute-path] <Python_ABI="${PYTHON_ABI}"> 67# @USAGE: [-a|--absolute-path] [--] <Python_ABI="${PYTHON_ABI}">
72# @DESCRIPTION: 68# @DESCRIPTION:
73# Get Python interpreter filename for specified Python ABI. If Python_ABI argument 69# Get Python interpreter filename for specified Python ABI. If Python_ABI argument
74# is ommitted, then PYTHON_ABI environment variable must be set and is used. 70# is ommitted, then PYTHON_ABI environment variable must be set and is used.
75PYTHON() { 71PYTHON() {
76 local absolute_path="0" slot= 72 local absolute_path="0" slot=
77 73
78 while (($#)); do 74 while (($#)); do
79 case "$1" in 75 case "$1" in
80 -a|--absolute-path) 76 -a|--absolute-path)
81 absolute_path="1" 77 absolute_path="1"
78 ;;
79 --)
80 break
82 ;; 81 ;;
83 -*) 82 -*)
84 die "${FUNCNAME}(): Unrecognized option $1" 83 die "${FUNCNAME}(): Unrecognized option $1"
85 ;; 84 ;;
86 *) 85 *)
125 if [[ "$(</usr/bin/python-config)" != *"Gentoo python-config wrapper script"* ]]; then 124 if [[ "$(</usr/bin/python-config)" != *"Gentoo python-config wrapper script"* ]]; then
126 die "'/usr/bin/python-config' isn't valid script" 125 die "'/usr/bin/python-config' isn't valid script"
127 fi 126 fi
128 127
129 # USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4. 128 # USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4.
130 if [[ -z "${PYTHON_ABIS}" ]] && has "${EAPI:-0}" 0 1 2 3; then 129 if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then
131 local ABI support_ABI supported_PYTHON_ABIS= restricted_ABI 130 local ABI restricted_ABI support_ABI supported_PYTHON_ABIS=
132 PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2" 131 PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
132
133 if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
134 if [[ -z "${USE_PYTHON}" ]]; then
135 die "USE_PYTHON variable is empty"
136 fi
137
133 for ABI in ${USE_PYTHON}; do 138 for ABI in ${USE_PYTHON}; do
134 if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then 139 if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
135 ewarn "Ignoring unsupported Python ABI '${ABI}'" 140 die "USE_PYTHON variable contains invalid value '${ABI}'"
136 continue
137 fi 141 fi
138 support_ABI="1" 142 support_ABI="1"
139 if [[ -z "${IGNORE_RESTRICT_PYTHON_ABIS}" ]]; then
140 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do 143 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
141 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then 144 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
142 support_ABI="0" 145 support_ABI="0"
143 break 146 break
144 fi 147 fi
145 done 148 done
146 fi
147 [[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${ABI}" 149 [[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${ABI}"
148 done 150 done
149 export PYTHON_ABIS="${supported_PYTHON_ABIS# }" 151 export PYTHON_ABIS="${supported_PYTHON_ABIS# }"
150 fi
151 152
152 if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then 153 if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
154 die "USE_PYTHON variable doesn't enable any version of Python supported by ${CATEGORY}/${PF}"
155 fi
156 else
157 local ABI python2_version= python2_supported_versions python3_version= python3_supported_versions restricted_ABI support_python_major_version
158
159 if has_version "=dev-lang/python-2*"; then
160 if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then
161 die "'/usr/bin/python2' isn't valid symlink"
162 fi
163
164 python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
165 python2_supported_versions="2.4 2.5 2.6 2.7"
166
167 for ABI in ${python2_supported_versions}; do
168 support_python_major_version="1"
169 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
170 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
171 support_python_major_version="0"
172 fi
173 done
174 [[ "${support_python_major_version}" == "1" ]] && break
175 done
176 if [[ "${support_python_major_version}" == "1" ]]; then
177 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
178 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python2_version}', '${restricted_ABI}'))"; then
179 die "Active version of Python 2 isn't supported by ${CATEGORY}/${PF}"
180 fi
181 done
182 else
153 python_version 183 python2_version=""
184 fi
185 fi
186
187 if has_version "=dev-lang/python-3*"; then
188 if [[ "$(readlink /usr/bin/python3)" != "python3."* ]]; then
189 die "'/usr/bin/python3' isn't valid symlink"
190 fi
191
192 python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
193 python3_supported_versions="3.0 3.1 3.2"
194
195 for ABI in ${python3_supported_versions}; do
196 support_python_major_version="1"
197 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
198 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
199 support_python_major_version="0"
200 fi
201 done
202 [[ "${support_python_major_version}" == "1" ]] && break
203 done
204 if [[ "${support_python_major_version}" == "1" ]]; then
205 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
206 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python3_version}', '${restricted_ABI}'))"; then
207 die "Active version of Python 3 isn't supported by ${CATEGORY}/${PF}"
208 fi
209 done
210 else
211 python3_version=""
212 fi
213 fi
214
215 PYTHON_ABIS="${python2_version} ${python3_version}"
216 PYTHON_ABIS="${PYTHON_ABIS# }"
154 export PYTHON_ABIS="${PYVER}" 217 export PYTHON_ABIS="${PYTHON_ABIS% }"
155 fi 218 fi
219 fi
156 220
157 # Ensure that EPYTHON variable is respected.
158 local PYTHON_ABI 221 local PYTHON_ABI
159 for PYTHON_ABI in ${PYTHON_ABIS}; do 222 for PYTHON_ABI in ${PYTHON_ABIS}; do
223 # Ensure that appropriate Python version is installed.
224 if ! has_version "dev-lang/python:${PYTHON_ABI}"; then
225 die "dev-lang/python:${PYTHON_ABI} isn't installed"
226 fi
227
228 # Ensure that EPYTHON variable is respected.
160 if [[ "$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" != "${PYTHON_ABI}" ]]; then 229 if [[ "$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" != "${PYTHON_ABI}" ]]; then
161 die "'python' doesn't respect EPYTHON variable" 230 die "'python' doesn't respect EPYTHON variable"
162 fi 231 fi
163 done 232 done
164} 233}
165 234
166# @FUNCTION: python_copy_sources 235# @FUNCTION: python_copy_sources
167# @USAGE: [directory] 236# @USAGE: [--no-link] [--] [directory]
168# @DESCRIPTION: 237# @DESCRIPTION:
169# Copy unpacked sources of given package for each Python ABI. 238# Copy unpacked sources of given package for each Python ABI.
170python_copy_sources() { 239python_copy_sources() {
171 local dir dirs=() PYTHON_ABI 240 local dir dirs=() no_link="0" PYTHON_ABI
241
242 while (($#)); do
243 case "$1" in
244 --no-link)
245 no_link="1"
246 ;;
247 --)
248 break
249 ;;
250 -*)
251 die "${FUNCNAME}(): Unrecognized option '$1'"
252 ;;
253 *)
254 break
255 ;;
256 esac
257 shift
258 done
172 259
173 if [[ "$#" -eq "0" ]]; then 260 if [[ "$#" -eq "0" ]]; then
174 if [[ "${WORKDIR}" == "${S}" ]]; then 261 if [[ "${WORKDIR}" == "${S}" ]]; then
175 die "${FUNCNAME}() cannot be used" 262 die "${FUNCNAME}() cannot be used"
176 fi 263 fi
180 fi 267 fi
181 268
182 validate_PYTHON_ABIS 269 validate_PYTHON_ABIS
183 for PYTHON_ABI in ${PYTHON_ABIS}; do 270 for PYTHON_ABI in ${PYTHON_ABIS}; do
184 for dir in "${dirs[@]}"; do 271 for dir in "${dirs[@]}"; do
272 if [[ "${no_link}" == "1" ]]; then
273 cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
274 else
185 cp -lpr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed" 275 cp -lpr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
276 fi
186 done 277 done
187 done 278 done
188} 279}
189 280
190# @FUNCTION: python_set_build_dir_symlink 281# @FUNCTION: python_set_build_dir_symlink
201 rm -f "${dir}" || die "Deletion of '${dir}' failed" 292 rm -f "${dir}" || die "Deletion of '${dir}' failed"
202 ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed" 293 ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed"
203} 294}
204 295
205# @FUNCTION: python_execute_function 296# @FUNCTION: python_execute_function
206# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] <function> [arguments] 297# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--] <function> [arguments]
207# @DESCRIPTION: 298# @DESCRIPTION:
208# Execute specified function for each value of PYTHON_ABIS, optionally passing additional 299# Execute specified function for each value of PYTHON_ABIS, optionally passing additional
209# arguments. The specified function can use PYTHON_ABI and BUILDDIR variables. 300# arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
210python_execute_function() { 301python_execute_function() {
211 local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" PYTHON_ABI quiet="0" separate_build_dirs="0" 302 local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0"
212 303
213 while (($#)); do 304 while (($#)); do
214 case "$1" in 305 case "$1" in
215 --action-message) 306 --action-message)
216 action_message_template="$2" 307 action_message_template="$2"
230 quiet="1" 321 quiet="1"
231 ;; 322 ;;
232 -s|--separate-build-dirs) 323 -s|--separate-build-dirs)
233 separate_build_dirs="1" 324 separate_build_dirs="1"
234 ;; 325 ;;
326 --)
327 break
328 ;;
235 -*) 329 -*)
236 die "${FUNCNAME}(): Unrecognized option $1" 330 die "${FUNCNAME}(): Unrecognized option '$1'"
237 ;; 331 ;;
238 *) 332 *)
239 break 333 break
240 ;; 334 ;;
241 esac 335 esac
246 if [[ "$#" -eq "0" ]]; then 340 if [[ "$#" -eq "0" ]]; then
247 die "${FUNCNAME}(): Missing function name" 341 die "${FUNCNAME}(): Missing function name"
248 fi 342 fi
249 function="$1" 343 function="$1"
250 shift 344 shift
345
346 if [[ -z "$(type -t "${function}")" ]]; then
347 die "${FUNCNAME}(): '${function}' function isn't defined"
348 fi
251 else 349 else
252 if [[ "$#" -ne "0" ]]; then 350 if [[ "$#" -ne "0" ]]; then
253 die "${FUNCNAME}(): --default-function option and function name cannot be specified simultaneously" 351 die "${FUNCNAME}(): '--default-function' option and function name cannot be specified simultaneously"
254 fi 352 fi
255 if has "${EAPI:-0}" 0 1; then 353 if has "${EAPI:-0}" 0 1; then
256 die "${FUNCNAME}(): --default-function option cannot be used in this EAPI" 354 die "${FUNCNAME}(): '--default-function' option cannot be used in this EAPI"
257 fi 355 fi
258 356
259 if [[ "${EBUILD_PHASE}" == "configure" ]]; then 357 if [[ "${EBUILD_PHASE}" == "configure" ]]; then
260 if has "${EAPI}" 2; then 358 if has "${EAPI}" 2; then
261 python_default_function() { 359 python_default_function() {
331 pushd "${BUILDDIR}" > /dev/null || die "pushd failed" 429 pushd "${BUILDDIR}" > /dev/null || die "pushd failed"
332 else 430 else
333 export BUILDDIR="${S}" 431 export BUILDDIR="${S}"
334 fi 432 fi
335 433
434 previous_directory="$(pwd)"
435 previous_directory_stack="$(dirs -p)"
436 previous_directory_stack_length="$(dirs -p | wc -l)"
437
336 if ! has "${EAPI}" 0 1 2 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then 438 if ! has "${EAPI}" 0 1 2 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
337 EPYTHON="$(PYTHON)" nonfatal "${function}" "$@" 439 EPYTHON="$(PYTHON)" nonfatal "${function}" "$@"
338 else 440 else
339 EPYTHON="$(PYTHON)" "${function}" "$@" 441 EPYTHON="$(PYTHON)" "${function}" "$@"
340 fi 442 fi
344 failure_message="$(eval echo -n "${failure_message_template}")" 446 failure_message="$(eval echo -n "${failure_message_template}")"
345 else 447 else
346 failure_message="${action} failed with Python ${PYTHON_ABI} in ${function}() function" 448 failure_message="${action} failed with Python ${PYTHON_ABI} in ${function}() function"
347 fi 449 fi
348 450
349 if [[ "${nonfatal}" == "1" ]] || has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then 451 if [[ "${nonfatal}" == "1" ]]; then
350 local ABI enabled_PYTHON_ABIS
351 for ABI in ${PYTHON_ABIS}; do
352 [[ "${ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=" ${ABI}"
353 done
354 export PYTHON_ABIS="${enabled_PYTHON_ABIS# }"
355 if [[ "${quiet}" == "0" ]]; then 452 if [[ "${quiet}" == "0" ]]; then
356 ewarn "${RED}${failure_message}${NORMAL}" 453 ewarn "${RED}${failure_message}${NORMAL}"
357 fi 454 fi
455 elif has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
456 if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then
457 local ABI enabled_PYTHON_ABIS=
458 for ABI in ${PYTHON_ABIS}; do
459 [[ "${ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=" ${ABI}"
460 done
461 export PYTHON_ABIS="${enabled_PYTHON_ABIS# }"
462 fi
463 if [[ "${quiet}" == "0" ]]; then
464 ewarn "${RED}${failure_message}${NORMAL}"
465 fi
466 if [[ -z "${PYTHON_ABIS}" ]]; then
467 die "${function}() function failed with all enabled versions of Python"
468 fi
358 else 469 else
359 die "${failure_message}" 470 die "${failure_message}"
360 fi 471 fi
472 fi
473
474 # Ensure that directory stack hasn't been decreased.
475 if [[ "$(dirs -p | wc -l)" -lt "${previous_directory_stack_length}" ]]; then
476 die "Directory stack decreased illegally"
477 fi
478
479 # Avoid side effects of earlier returning from the specified function.
480 while [[ "$(dirs -p | wc -l)" -gt "${previous_directory_stack_length}" ]]; do
481 popd > /dev/null || die "popd failed"
482 done
483
484 # Ensure that the bottom part of directory stack hasn't been changed. Restore
485 # previous directory (from before running of the specified function) before
486 # comparison of directory stacks to avoid mismatch of directory stacks after
487 # potential using of 'cd' to change current directory. Restoration of previous
488 # directory allows to safely use 'cd' to change current directory in the
489 # specified function without changing it back to original directory.
490 cd "${previous_directory}"
491 if [[ "$(dirs -p)" != "${previous_directory_stack}" ]]; then
492 die "Directory stack changed illegally"
361 fi 493 fi
362 494
363 if [[ "${separate_build_dirs}" == "1" ]]; then 495 if [[ "${separate_build_dirs}" == "1" ]]; then
364 popd > /dev/null || die "popd failed" 496 popd > /dev/null || die "popd failed"
365 fi 497 fi
390 522
391# @FUNCTION: python_pkg_setup 523# @FUNCTION: python_pkg_setup
392# @DESCRIPTION: 524# @DESCRIPTION:
393# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags 525# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
394# are respected. Only exported if one of those variables is set. 526# are respected. Only exported if one of those variables is set.
395if ! has ${EAPI:-0} 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then 527if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
528 python_pkg_setup() {
396 python_pkg_setup_fail() { 529 python_pkg_setup_fail() {
397 eerror "${1}" 530 eerror "${1}"
398 die "${1}" 531 die "${1}"
532 }
533
534 [[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
535
536 python_pkg_setup_check_USE_flags() {
537 local pyatom use
538 if [[ -n "${PYTHON_ABI}" ]]; then
539 pyatom="dev-lang/python:${PYTHON_ABI}"
540 else
541 python_version
542 pyatom="dev-lang/python:${PYVER}"
543 fi
544
545 for use in ${PYTHON_USE_WITH}; do
546 if ! has_version "${pyatom}[${use}]"; then
547 python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
548 fi
549 done
550
551 for use in ${PYTHON_USE_WITH_OR}; do
552 if has_version "${pyatom}[${use}]"; then
553 return
554 fi
555 done
556
557 if [[ ${PYTHON_USE_WITH_OR} ]]; then
558 python_pkg_setup_fail "Please rebuild ${pyatom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
559 fi
560 }
561
562 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
563 python_execute_function -q python_pkg_setup_check_USE_flags
564 else
565 python_pkg_setup_check_USE_flags
566 fi
399 } 567 }
400 568
401 python_pkg_setup() {
402 [[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
403
404 python_version
405 local failed
406 local pyatom="dev-lang/python:${PYVER}"
407
408 for use in ${PYTHON_USE_WITH}; do
409 if ! has_version "${pyatom}[${use}]"; then
410 python_pkg_setup_fail \
411 "Please rebuild ${pyatom} with use flags: ${PYTHON_USE_WITH}"
412 fi
413 done
414
415 for use in ${PYTHON_USE_WITH_OR}; do
416 if has_version "${pyatom}[${use}]"; then
417 return
418 fi
419 done
420
421 if [[ ${PYTHON_USE_WITH_OR} ]]; then
422 python_pkg_setup_fail \
423 "Please rebuild ${pyatom} with one of: ${PYTHON_USE_WITH_OR}"
424 fi
425 }
426
427 EXPORT_FUNCTIONS pkg_setup 569 EXPORT_FUNCTIONS pkg_setup
428 570
429 if [[ ${PYTHON_USE_WITH} ]]; then 571 if [[ -n "${PYTHON_USE_WITH}" ]]; then
430 PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]" 572 PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
431 elif [[ ${PYTHON_USE_WITH_OR} ]]; then 573 elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
432 PYTHON_USE_WITH_ATOM="|| ( " 574 PYTHON_USE_WITH_ATOM="|| ( "
433 for use in ${PYTHON_USE_WITH_OR}; do 575 for use in ${PYTHON_USE_WITH_OR}; do
434 PYTHON_USE_WITH_ATOM=" 576 PYTHON_USE_WITH_ATOM+=" ${PYTHON_ATOM}[${use}]"
435 ${PYTHON_USE_WITH_ATOM}
436 ${PYTHON_ATOM}[${use}]"
437 done 577 done
438 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_ATOM} )" 578 unset use
579 PYTHON_USE_WITH_ATOM+=" )"
439 fi 580 fi
440 if [[ ${PYTHON_USE_WITH_OPT} ]]; then 581 if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
441 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )" 582 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
442 fi 583 fi
443 DEPEND="${PYTHON_USE_WITH_ATOM}" 584 DEPEND+=" ${PYTHON_USE_WITH_ATOM}"
444 RDEPEND="${PYTHON_USE_WITH_ATOM}" 585 RDEPEND+=" ${PYTHON_USE_WITH_ATOM}"
586fi
587
588# @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS
589# @DESCRIPTION:
590# Set this to define default functions for the following ebuild phases:
591# src_prepare, src_configure, src_compile, src_test, src_install.
592if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_DEFINE_DEFAULT_FUNCTIONS}" ]]; then
593 python_src_prepare() {
594 python_copy_sources
595 }
596
597 for python_default_function in src_configure src_compile src_test src_install; do
598 eval "python_${python_default_function}() { python_execute_function -d -s; }"
599 done
600 unset python_default_function
601
602 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
445fi 603fi
446 604
447# @FUNCTION: python_disable_pyc 605# @FUNCTION: python_disable_pyc
448# @DESCRIPTION: 606# @DESCRIPTION:
449# Tell Python not to automatically recompile modules to .pyc/.pyo 607# Tell Python not to automatically recompile modules to .pyc/.pyo

Legend:
Removed from v.1.66  
changed lines
  Added in v.1.74

  ViewVC Help
Powered by ViewVC 1.1.20