| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2011 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.127 2011/07/08 07:49:36 djc Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.128 2011/08/19 10:10:03 lxnay Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: python.eclass |
5 | # @ECLASS: python.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Gentoo Python Project <python@gentoo.org> |
7 | # Gentoo Python Project <python@gentoo.org> |
| 8 | # @BLURB: Eclass for Python packages |
8 | # @BLURB: Eclass for Python packages |
| … | |
… | |
| 398 | |
398 | |
| 399 | # @FUNCTION: python_pkg_setup |
399 | # @FUNCTION: python_pkg_setup |
| 400 | # @DESCRIPTION: |
400 | # @DESCRIPTION: |
| 401 | # Perform sanity checks and initialize environment. |
401 | # Perform sanity checks and initialize environment. |
| 402 | # |
402 | # |
| 403 | # This function is exported in EAPI 2 and 3 when PYTHON_USE_WITH or PYTHON_USE_WITH_OR variable |
403 | # This function is exported in EAPI 2 and 3. Calling of this function is mandatory in EAPI >=4. |
| 404 | # is set and always in EAPI >=4. Calling of this function is mandatory in EAPI >=4. |
|
|
| 405 | python_pkg_setup() { |
404 | python_pkg_setup() { |
| 406 | if [[ "${EBUILD_PHASE}" != "setup" ]]; then |
405 | if [[ "${EBUILD_PHASE}" != "setup" ]]; then |
| 407 | die "${FUNCNAME}() can be used only in pkg_setup() phase" |
406 | die "${FUNCNAME}() can be used only in pkg_setup() phase" |
| 408 | fi |
407 | fi |
| 409 | |
408 | |
| … | |
… | |
| 417 | if _python_package_supporting_installation_for_multiple_python_abis; then |
416 | if _python_package_supporting_installation_for_multiple_python_abis; then |
| 418 | _python_calculate_PYTHON_ABIS |
417 | _python_calculate_PYTHON_ABIS |
| 419 | export EPYTHON="$(PYTHON -f)" |
418 | export EPYTHON="$(PYTHON -f)" |
| 420 | else |
419 | else |
| 421 | PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}" |
420 | PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}" |
| 422 | fi |
|
|
| 423 | |
|
|
| 424 | if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then |
|
|
| 425 | if [[ "${PYTHON_USE_WITH_OPT}" ]]; then |
|
|
| 426 | if [[ "${PYTHON_USE_WITH_OPT}" == !* ]]; then |
|
|
| 427 | use ${PYTHON_USE_WITH_OPT#!} && return |
|
|
| 428 | else |
|
|
| 429 | use !${PYTHON_USE_WITH_OPT} && return |
|
|
| 430 | fi |
|
|
| 431 | fi |
|
|
| 432 | |
|
|
| 433 | python_pkg_setup_check_USE_flags() { |
|
|
| 434 | local python_atom USE_flag |
|
|
| 435 | python_atom="$(python_get_implementational_package)" |
|
|
| 436 | |
|
|
| 437 | for USE_flag in ${PYTHON_USE_WITH}; do |
|
|
| 438 | if ! has_version "${python_atom}[${USE_flag}]"; then |
|
|
| 439 | eerror "Please rebuild ${python_atom} with the following USE flags enabled: ${PYTHON_USE_WITH}" |
|
|
| 440 | die "Please rebuild ${python_atom} with the following USE flags enabled: ${PYTHON_USE_WITH}" |
|
|
| 441 | fi |
|
|
| 442 | done |
|
|
| 443 | |
|
|
| 444 | for USE_flag in ${PYTHON_USE_WITH_OR}; do |
|
|
| 445 | if has_version "${python_atom}[${USE_flag}]"; then |
|
|
| 446 | return |
|
|
| 447 | fi |
|
|
| 448 | done |
|
|
| 449 | |
|
|
| 450 | if [[ ${PYTHON_USE_WITH_OR} ]]; then |
|
|
| 451 | eerror "Please rebuild ${python_atom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}" |
|
|
| 452 | die "Please rebuild ${python_atom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}" |
|
|
| 453 | fi |
|
|
| 454 | } |
|
|
| 455 | |
|
|
| 456 | if _python_package_supporting_installation_for_multiple_python_abis; then |
|
|
| 457 | PYTHON_SKIP_SANITY_CHECKS="1" python_execute_function -q python_pkg_setup_check_USE_flags |
|
|
| 458 | else |
|
|
| 459 | python_pkg_setup_check_USE_flags |
|
|
| 460 | fi |
|
|
| 461 | |
|
|
| 462 | unset -f python_pkg_setup_check_USE_flags |
|
|
| 463 | fi |
421 | fi |
| 464 | |
422 | |
| 465 | PYTHON_PKG_SETUP_EXECUTED="1" |
423 | PYTHON_PKG_SETUP_EXECUTED="1" |
| 466 | } |
424 | } |
| 467 | |
425 | |