/[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.68
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.68 2009/08/31 00:07:37 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# 8#
128 128
129 # USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4. 129 # 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 130 if [[ -z "${PYTHON_ABIS}" ]] && has "${EAPI:-0}" 0 1 2 3; then
131 local ABI support_ABI supported_PYTHON_ABIS= restricted_ABI 131 local ABI support_ABI supported_PYTHON_ABIS= restricted_ABI
132 PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2" 132 PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
133
134 if declare -p | grep "^declare -x USE_PYTHON=" > /dev/null; then
135 if [[ -z "${USE_PYTHON}" ]]; then
136 die "USE_PYTHON variable is empty"
137 fi
138
133 for ABI in ${USE_PYTHON}; do 139 for ABI in ${USE_PYTHON}; do
134 if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then 140 if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
135 ewarn "Ignoring unsupported Python ABI '${ABI}'" 141 die "USE_PYTHON variable contains invalid value '${ABI}'"
136 continue
137 fi 142 fi
138 support_ABI="1" 143 support_ABI="1"
139 if [[ -z "${IGNORE_RESTRICT_PYTHON_ABIS}" ]]; then
140 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do 144 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
141 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then 145 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
142 support_ABI="0" 146 support_ABI="0"
143 break 147 break
144 fi 148 fi
145 done 149 done
146 fi
147 [[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${ABI}" 150 [[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${ABI}"
148 done 151 done
149 export PYTHON_ABIS="${supported_PYTHON_ABIS# }" 152 export PYTHON_ABIS="${supported_PYTHON_ABIS# }"
150 fi
151 153
152 if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then 154 if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
155 die "USE_PYTHON variable doesn't enable any Python version supported by ${CATEGORY}/${PF}"
156 fi
157 else
158 local restricted_ABI
153 python_version 159 python_version
160
161 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
162 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${PYVER}', '${restricted_ABI}'))"; then
163 die "Active Python version isn't supported by ${CATEGORY}/${PF}"
164 fi
165 done
154 export PYTHON_ABIS="${PYVER}" 166 export PYTHON_ABIS="${PYVER}"
167 fi
155 fi 168 fi
156 169
157 # Ensure that EPYTHON variable is respected. 170 # Ensure that EPYTHON variable is respected.
158 local PYTHON_ABI 171 local PYTHON_ABI
159 for PYTHON_ABI in ${PYTHON_ABIS}; do 172 for PYTHON_ABI in ${PYTHON_ABIS}; do
231 ;; 244 ;;
232 -s|--separate-build-dirs) 245 -s|--separate-build-dirs)
233 separate_build_dirs="1" 246 separate_build_dirs="1"
234 ;; 247 ;;
235 -*) 248 -*)
236 die "${FUNCNAME}(): Unrecognized option $1" 249 die "${FUNCNAME}(): Unrecognized option '$1'"
237 ;; 250 ;;
238 *) 251 *)
239 break 252 break
240 ;; 253 ;;
241 esac 254 esac
246 if [[ "$#" -eq "0" ]]; then 259 if [[ "$#" -eq "0" ]]; then
247 die "${FUNCNAME}(): Missing function name" 260 die "${FUNCNAME}(): Missing function name"
248 fi 261 fi
249 function="$1" 262 function="$1"
250 shift 263 shift
264
265 if [[ -z "$(type -t "${function}")" ]]; then
266 die "${FUNCNAME}(): '${function}' function isn't defined"
267 fi
251 else 268 else
252 if [[ "$#" -ne "0" ]]; then 269 if [[ "$#" -ne "0" ]]; then
253 die "${FUNCNAME}(): --default-function option and function name cannot be specified simultaneously" 270 die "${FUNCNAME}(): '--default-function' option and function name cannot be specified simultaneously"
254 fi 271 fi
255 if has "${EAPI:-0}" 0 1; then 272 if has "${EAPI:-0}" 0 1; then
256 die "${FUNCNAME}(): --default-function option cannot be used in this EAPI" 273 die "${FUNCNAME}(): '--default-function' option cannot be used in this EAPI"
257 fi 274 fi
258 275
259 if [[ "${EBUILD_PHASE}" == "configure" ]]; then 276 if [[ "${EBUILD_PHASE}" == "configure" ]]; then
260 if has "${EAPI}" 2; then 277 if has "${EAPI}" 2; then
261 python_default_function() { 278 python_default_function() {
390 407
391# @FUNCTION: python_pkg_setup 408# @FUNCTION: python_pkg_setup
392# @DESCRIPTION: 409# @DESCRIPTION:
393# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags 410# 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. 411# 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 412if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
396 python_pkg_setup_fail() { 413 python_pkg_setup_fail() {
397 eerror "${1}" 414 eerror "${1}"
398 die "${1}" 415 die "${1}"
399 } 416 }
400 417
440 if [[ ${PYTHON_USE_WITH_OPT} ]]; then 457 if [[ ${PYTHON_USE_WITH_OPT} ]]; then
441 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )" 458 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
442 fi 459 fi
443 DEPEND="${PYTHON_USE_WITH_ATOM}" 460 DEPEND="${PYTHON_USE_WITH_ATOM}"
444 RDEPEND="${PYTHON_USE_WITH_ATOM}" 461 RDEPEND="${PYTHON_USE_WITH_ATOM}"
462fi
463
464# @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS
465# @DESCRIPTION:
466# Set this to define default functions for the following ebuild phases:
467# src_prepare, src_configure, src_compile, src_test, src_install.
468if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_DEFINE_DEFAULT_FUNCTIONS}" ]]; then
469 python_src_prepare() {
470 python_copy_sources
471 }
472
473 for python_default_function in src_configure src_compile src_test src_install; do
474 eval "python_${python_default_function}() { python_execute_function -d -s; }"
475 done
476 unset python_default_function
477
478 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
445fi 479fi
446 480
447# @FUNCTION: python_disable_pyc 481# @FUNCTION: python_disable_pyc
448# @DESCRIPTION: 482# @DESCRIPTION:
449# Tell Python not to automatically recompile modules to .pyc/.pyo 483# Tell Python not to automatically recompile modules to .pyc/.pyo

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

  ViewVC Help
Powered by ViewVC 1.1.20