/[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.75
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.75 2009/10/02 17:32:23 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 python2_supported_versions python3_supported_versions 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 python2_supported_versions="2.4 2.5 2.6 2.7"
133 python3_supported_versions="3.0 3.1 3.2"
134
135 if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
136 local python2_enabled="0" python3_enabled="0"
137
138 if [[ -z "${USE_PYTHON}" ]]; then
139 die "USE_PYTHON variable is empty"
140 fi
141
133 for ABI in ${USE_PYTHON}; do 142 for ABI in ${USE_PYTHON}; do
134 if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then 143 if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
135 ewarn "Ignoring unsupported Python ABI '${ABI}'" 144 die "USE_PYTHON variable contains invalid value '${ABI}'"
136 continue
137 fi 145 fi
146
147 if has "${ABI}" ${python2_supported_versions}; then
148 python2_enabled="1"
149 fi
150 if has "${ABI}" ${python3_supported_versions}; then
151 python3_enabled="1"
152 fi
153
138 support_ABI="1" 154 support_ABI="1"
139 if [[ -z "${IGNORE_RESTRICT_PYTHON_ABIS}" ]]; then
140 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do 155 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
141 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then 156 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
142 support_ABI="0" 157 support_ABI="0"
143 break 158 break
144 fi 159 fi
145 done 160 done
146 fi
147 [[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${ABI}" 161 [[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${ABI}"
148 done 162 done
149 export PYTHON_ABIS="${supported_PYTHON_ABIS# }" 163 export PYTHON_ABIS="${supported_PYTHON_ABIS# }"
150 fi
151 164
152 if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then 165 if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
166 die "USE_PYTHON variable doesn't enable any version of Python supported by ${CATEGORY}/${PF}"
167 fi
168
169 if [[ "${python2_enabled}" == "0" ]]; then
170 ewarn "USE_PYTHON variable doesn't enable any version of Python 2. This configuration is unsupported."
171 fi
172 if [[ "${python3_enabled}" == "0" ]]; then
173 ewarn "USE_PYTHON variable doesn't enable any version of Python 3. This configuration is unsupported."
174 fi
175 else
176 local python2_version= python3_version= support_python_major_version
177
178 if has_version "=dev-lang/python-2*"; then
179 if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then
180 die "'/usr/bin/python2' isn't valid symlink"
181 fi
182
183 python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
184
185 for ABI in ${python2_supported_versions}; do
186 support_python_major_version="1"
187 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
188 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
189 support_python_major_version="0"
190 fi
191 done
192 [[ "${support_python_major_version}" == "1" ]] && break
193 done
194 if [[ "${support_python_major_version}" == "1" ]]; then
195 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
196 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python2_version}', '${restricted_ABI}'))"; then
197 die "Active version of Python 2 isn't supported by ${CATEGORY}/${PF}"
198 fi
199 done
200 else
153 python_version 201 python2_version=""
202 fi
203 fi
204
205 if has_version "=dev-lang/python-3*"; then
206 if [[ "$(readlink /usr/bin/python3)" != "python3."* ]]; then
207 die "'/usr/bin/python3' isn't valid symlink"
208 fi
209
210 python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
211
212 for ABI in ${python3_supported_versions}; do
213 support_python_major_version="1"
214 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
215 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
216 support_python_major_version="0"
217 fi
218 done
219 [[ "${support_python_major_version}" == "1" ]] && break
220 done
221 if [[ "${support_python_major_version}" == "1" ]]; then
222 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
223 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python3_version}', '${restricted_ABI}'))"; then
224 die "Active version of Python 3 isn't supported by ${CATEGORY}/${PF}"
225 fi
226 done
227 else
228 python3_version=""
229 fi
230 fi
231
232 PYTHON_ABIS="${python2_version} ${python3_version}"
233 PYTHON_ABIS="${PYTHON_ABIS# }"
154 export PYTHON_ABIS="${PYVER}" 234 export PYTHON_ABIS="${PYTHON_ABIS% }"
155 fi 235 fi
236 fi
156 237
157 # Ensure that EPYTHON variable is respected.
158 local PYTHON_ABI 238 local PYTHON_ABI
159 for PYTHON_ABI in ${PYTHON_ABIS}; do 239 for PYTHON_ABI in ${PYTHON_ABIS}; do
240 # Ensure that appropriate Python version is installed.
241 if ! has_version "dev-lang/python:${PYTHON_ABI}"; then
242 die "dev-lang/python:${PYTHON_ABI} isn't installed"
243 fi
244
245 # 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 246 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" 247 die "'python' doesn't respect EPYTHON variable"
162 fi 248 fi
163 done 249 done
164} 250}
165 251
166# @FUNCTION: python_copy_sources 252# @FUNCTION: python_copy_sources
167# @USAGE: [directory] 253# @USAGE: [--no-link] [--] [directory]
168# @DESCRIPTION: 254# @DESCRIPTION:
169# Copy unpacked sources of given package for each Python ABI. 255# Copy unpacked sources of given package for each Python ABI.
170python_copy_sources() { 256python_copy_sources() {
171 local dir dirs=() PYTHON_ABI 257 local dir dirs=() no_link="0" PYTHON_ABI
258
259 while (($#)); do
260 case "$1" in
261 --no-link)
262 no_link="1"
263 ;;
264 --)
265 break
266 ;;
267 -*)
268 die "${FUNCNAME}(): Unrecognized option '$1'"
269 ;;
270 *)
271 break
272 ;;
273 esac
274 shift
275 done
172 276
173 if [[ "$#" -eq "0" ]]; then 277 if [[ "$#" -eq "0" ]]; then
174 if [[ "${WORKDIR}" == "${S}" ]]; then 278 if [[ "${WORKDIR}" == "${S}" ]]; then
175 die "${FUNCNAME}() cannot be used" 279 die "${FUNCNAME}() cannot be used"
176 fi 280 fi
180 fi 284 fi
181 285
182 validate_PYTHON_ABIS 286 validate_PYTHON_ABIS
183 for PYTHON_ABI in ${PYTHON_ABIS}; do 287 for PYTHON_ABI in ${PYTHON_ABIS}; do
184 for dir in "${dirs[@]}"; do 288 for dir in "${dirs[@]}"; do
289 if [[ "${no_link}" == "1" ]]; then
290 cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
291 else
185 cp -lpr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed" 292 cp -lpr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
293 fi
186 done 294 done
187 done 295 done
188} 296}
189 297
190# @FUNCTION: python_set_build_dir_symlink 298# @FUNCTION: python_set_build_dir_symlink
201 rm -f "${dir}" || die "Deletion of '${dir}' failed" 309 rm -f "${dir}" || die "Deletion of '${dir}' failed"
202 ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed" 310 ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed"
203} 311}
204 312
205# @FUNCTION: python_execute_function 313# @FUNCTION: python_execute_function
206# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] <function> [arguments] 314# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--] <function> [arguments]
207# @DESCRIPTION: 315# @DESCRIPTION:
208# Execute specified function for each value of PYTHON_ABIS, optionally passing additional 316# Execute specified function for each value of PYTHON_ABIS, optionally passing additional
209# arguments. The specified function can use PYTHON_ABI and BUILDDIR variables. 317# arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
210python_execute_function() { 318python_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" 319 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 320
213 while (($#)); do 321 while (($#)); do
214 case "$1" in 322 case "$1" in
215 --action-message) 323 --action-message)
216 action_message_template="$2" 324 action_message_template="$2"
230 quiet="1" 338 quiet="1"
231 ;; 339 ;;
232 -s|--separate-build-dirs) 340 -s|--separate-build-dirs)
233 separate_build_dirs="1" 341 separate_build_dirs="1"
234 ;; 342 ;;
343 --)
344 break
345 ;;
235 -*) 346 -*)
236 die "${FUNCNAME}(): Unrecognized option $1" 347 die "${FUNCNAME}(): Unrecognized option '$1'"
237 ;; 348 ;;
238 *) 349 *)
239 break 350 break
240 ;; 351 ;;
241 esac 352 esac
246 if [[ "$#" -eq "0" ]]; then 357 if [[ "$#" -eq "0" ]]; then
247 die "${FUNCNAME}(): Missing function name" 358 die "${FUNCNAME}(): Missing function name"
248 fi 359 fi
249 function="$1" 360 function="$1"
250 shift 361 shift
362
363 if [[ -z "$(type -t "${function}")" ]]; then
364 die "${FUNCNAME}(): '${function}' function isn't defined"
365 fi
251 else 366 else
252 if [[ "$#" -ne "0" ]]; then 367 if [[ "$#" -ne "0" ]]; then
253 die "${FUNCNAME}(): --default-function option and function name cannot be specified simultaneously" 368 die "${FUNCNAME}(): '--default-function' option and function name cannot be specified simultaneously"
254 fi 369 fi
255 if has "${EAPI:-0}" 0 1; then 370 if has "${EAPI:-0}" 0 1; then
256 die "${FUNCNAME}(): --default-function option cannot be used in this EAPI" 371 die "${FUNCNAME}(): '--default-function' option cannot be used in this EAPI"
257 fi 372 fi
258 373
259 if [[ "${EBUILD_PHASE}" == "configure" ]]; then 374 if [[ "${EBUILD_PHASE}" == "configure" ]]; then
260 if has "${EAPI}" 2; then 375 if has "${EAPI}" 2; then
261 python_default_function() { 376 python_default_function() {
331 pushd "${BUILDDIR}" > /dev/null || die "pushd failed" 446 pushd "${BUILDDIR}" > /dev/null || die "pushd failed"
332 else 447 else
333 export BUILDDIR="${S}" 448 export BUILDDIR="${S}"
334 fi 449 fi
335 450
451 previous_directory="$(pwd)"
452 previous_directory_stack="$(dirs -p)"
453 previous_directory_stack_length="$(dirs -p | wc -l)"
454
336 if ! has "${EAPI}" 0 1 2 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then 455 if ! has "${EAPI}" 0 1 2 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
337 EPYTHON="$(PYTHON)" nonfatal "${function}" "$@" 456 EPYTHON="$(PYTHON)" nonfatal "${function}" "$@"
338 else 457 else
339 EPYTHON="$(PYTHON)" "${function}" "$@" 458 EPYTHON="$(PYTHON)" "${function}" "$@"
340 fi 459 fi
344 failure_message="$(eval echo -n "${failure_message_template}")" 463 failure_message="$(eval echo -n "${failure_message_template}")"
345 else 464 else
346 failure_message="${action} failed with Python ${PYTHON_ABI} in ${function}() function" 465 failure_message="${action} failed with Python ${PYTHON_ABI} in ${function}() function"
347 fi 466 fi
348 467
349 if [[ "${nonfatal}" == "1" ]] || has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then 468 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 469 if [[ "${quiet}" == "0" ]]; then
356 ewarn "${RED}${failure_message}${NORMAL}" 470 ewarn "${RED}${failure_message}${NORMAL}"
357 fi 471 fi
472 elif has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
473 if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then
474 local ABI enabled_PYTHON_ABIS=
475 for ABI in ${PYTHON_ABIS}; do
476 [[ "${ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=" ${ABI}"
477 done
478 export PYTHON_ABIS="${enabled_PYTHON_ABIS# }"
479 fi
480 if [[ "${quiet}" == "0" ]]; then
481 ewarn "${RED}${failure_message}${NORMAL}"
482 fi
483 if [[ -z "${PYTHON_ABIS}" ]]; then
484 die "${function}() function failed with all enabled versions of Python"
485 fi
358 else 486 else
359 die "${failure_message}" 487 die "${failure_message}"
360 fi 488 fi
489 fi
490
491 # Ensure that directory stack hasn't been decreased.
492 if [[ "$(dirs -p | wc -l)" -lt "${previous_directory_stack_length}" ]]; then
493 die "Directory stack decreased illegally"
494 fi
495
496 # Avoid side effects of earlier returning from the specified function.
497 while [[ "$(dirs -p | wc -l)" -gt "${previous_directory_stack_length}" ]]; do
498 popd > /dev/null || die "popd failed"
499 done
500
501 # Ensure that the bottom part of directory stack hasn't been changed. Restore
502 # previous directory (from before running of the specified function) before
503 # comparison of directory stacks to avoid mismatch of directory stacks after
504 # potential using of 'cd' to change current directory. Restoration of previous
505 # directory allows to safely use 'cd' to change current directory in the
506 # specified function without changing it back to original directory.
507 cd "${previous_directory}"
508 if [[ "$(dirs -p)" != "${previous_directory_stack}" ]]; then
509 die "Directory stack changed illegally"
361 fi 510 fi
362 511
363 if [[ "${separate_build_dirs}" == "1" ]]; then 512 if [[ "${separate_build_dirs}" == "1" ]]; then
364 popd > /dev/null || die "popd failed" 513 popd > /dev/null || die "popd failed"
365 fi 514 fi
390 539
391# @FUNCTION: python_pkg_setup 540# @FUNCTION: python_pkg_setup
392# @DESCRIPTION: 541# @DESCRIPTION:
393# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags 542# 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. 543# 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 544if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
545 python_pkg_setup() {
396 python_pkg_setup_fail() { 546 python_pkg_setup_fail() {
397 eerror "${1}" 547 eerror "${1}"
398 die "${1}" 548 die "${1}"
549 }
550
551 [[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
552
553 python_pkg_setup_check_USE_flags() {
554 local pyatom use
555 if [[ -n "${PYTHON_ABI}" ]]; then
556 pyatom="dev-lang/python:${PYTHON_ABI}"
557 else
558 python_version
559 pyatom="dev-lang/python:${PYVER}"
560 fi
561
562 for use in ${PYTHON_USE_WITH}; do
563 if ! has_version "${pyatom}[${use}]"; then
564 python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
565 fi
566 done
567
568 for use in ${PYTHON_USE_WITH_OR}; do
569 if has_version "${pyatom}[${use}]"; then
570 return
571 fi
572 done
573
574 if [[ ${PYTHON_USE_WITH_OR} ]]; then
575 python_pkg_setup_fail "Please rebuild ${pyatom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
576 fi
577 }
578
579 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
580 python_execute_function -q python_pkg_setup_check_USE_flags
581 else
582 python_pkg_setup_check_USE_flags
583 fi
399 } 584 }
400 585
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 586 EXPORT_FUNCTIONS pkg_setup
428 587
429 if [[ ${PYTHON_USE_WITH} ]]; then 588 if [[ -n "${PYTHON_USE_WITH}" ]]; then
430 PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]" 589 PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
431 elif [[ ${PYTHON_USE_WITH_OR} ]]; then 590 elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
432 PYTHON_USE_WITH_ATOM="|| ( " 591 PYTHON_USE_WITH_ATOM="|| ( "
433 for use in ${PYTHON_USE_WITH_OR}; do 592 for use in ${PYTHON_USE_WITH_OR}; do
434 PYTHON_USE_WITH_ATOM=" 593 PYTHON_USE_WITH_ATOM+=" ${PYTHON_ATOM}[${use}]"
435 ${PYTHON_USE_WITH_ATOM}
436 ${PYTHON_ATOM}[${use}]"
437 done 594 done
438 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_ATOM} )" 595 unset use
596 PYTHON_USE_WITH_ATOM+=" )"
439 fi 597 fi
440 if [[ ${PYTHON_USE_WITH_OPT} ]]; then 598 if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
441 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )" 599 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
442 fi 600 fi
443 DEPEND="${PYTHON_USE_WITH_ATOM}" 601 DEPEND+=" ${PYTHON_USE_WITH_ATOM}"
444 RDEPEND="${PYTHON_USE_WITH_ATOM}" 602 RDEPEND+=" ${PYTHON_USE_WITH_ATOM}"
603fi
604
605# @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS
606# @DESCRIPTION:
607# Set this to define default functions for the following ebuild phases:
608# src_prepare, src_configure, src_compile, src_test, src_install.
609if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_DEFINE_DEFAULT_FUNCTIONS}" ]]; then
610 python_src_prepare() {
611 python_copy_sources
612 }
613
614 for python_default_function in src_configure src_compile src_test src_install; do
615 eval "python_${python_default_function}() { python_execute_function -d -s; }"
616 done
617 unset python_default_function
618
619 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
445fi 620fi
446 621
447# @FUNCTION: python_disable_pyc 622# @FUNCTION: python_disable_pyc
448# @DESCRIPTION: 623# @DESCRIPTION:
449# Tell Python not to automatically recompile modules to .pyc/.pyo 624# Tell Python not to automatically recompile modules to .pyc/.pyo

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

  ViewVC Help
Powered by ViewVC 1.1.20