/[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.70
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.70 2009/09/05 17:30:08 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#
125 if [[ "$(</usr/bin/python-config)" != *"Gentoo python-config wrapper script"* ]]; then 125 if [[ "$(</usr/bin/python-config)" != *"Gentoo python-config wrapper script"* ]]; then
126 die "'/usr/bin/python-config' isn't valid script" 126 die "'/usr/bin/python-config' isn't valid script"
127 fi 127 fi
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 [[ "$(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 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 USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; 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() {
344 failure_message="$(eval echo -n "${failure_message_template}")" 361 failure_message="$(eval echo -n "${failure_message_template}")"
345 else 362 else
346 failure_message="${action} failed with Python ${PYTHON_ABI} in ${function}() function" 363 failure_message="${action} failed with Python ${PYTHON_ABI} in ${function}() function"
347 fi 364 fi
348 365
349 if [[ "${nonfatal}" == "1" ]] || has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then 366 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 367 if [[ "${quiet}" == "0" ]]; then
356 ewarn "${RED}${failure_message}${NORMAL}" 368 ewarn "${RED}${failure_message}${NORMAL}"
369 fi
370 elif has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
371 if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then
372 local ABI enabled_PYTHON_ABIS=
373 for ABI in ${PYTHON_ABIS}; do
374 [[ "${ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=" ${ABI}"
375 done
376 export PYTHON_ABIS="${enabled_PYTHON_ABIS# }"
377 fi
378 if [[ "${quiet}" == "0" ]]; then
379 ewarn "${RED}${failure_message}${NORMAL}"
380 fi
381 if [[ -z "${PYTHON_ABIS}" ]]; then
382 die "${function}() function failed with all enabled versions of Python"
357 fi 383 fi
358 else 384 else
359 die "${failure_message}" 385 die "${failure_message}"
360 fi 386 fi
361 fi 387 fi
390 416
391# @FUNCTION: python_pkg_setup 417# @FUNCTION: python_pkg_setup
392# @DESCRIPTION: 418# @DESCRIPTION:
393# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags 419# 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. 420# 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 421if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
396 python_pkg_setup_fail() { 422 python_pkg_setup_fail() {
397 eerror "${1}" 423 eerror "${1}"
398 die "${1}" 424 die "${1}"
399 } 425 }
400 426
440 if [[ ${PYTHON_USE_WITH_OPT} ]]; then 466 if [[ ${PYTHON_USE_WITH_OPT} ]]; then
441 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )" 467 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
442 fi 468 fi
443 DEPEND="${PYTHON_USE_WITH_ATOM}" 469 DEPEND="${PYTHON_USE_WITH_ATOM}"
444 RDEPEND="${PYTHON_USE_WITH_ATOM}" 470 RDEPEND="${PYTHON_USE_WITH_ATOM}"
471fi
472
473# @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS
474# @DESCRIPTION:
475# Set this to define default functions for the following ebuild phases:
476# src_prepare, src_configure, src_compile, src_test, src_install.
477if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_DEFINE_DEFAULT_FUNCTIONS}" ]]; then
478 python_src_prepare() {
479 python_copy_sources
480 }
481
482 for python_default_function in src_configure src_compile src_test src_install; do
483 eval "python_${python_default_function}() { python_execute_function -d -s; }"
484 done
485 unset python_default_function
486
487 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
445fi 488fi
446 489
447# @FUNCTION: python_disable_pyc 490# @FUNCTION: python_disable_pyc
448# @DESCRIPTION: 491# @DESCRIPTION:
449# Tell Python not to automatically recompile modules to .pyc/.pyo 492# Tell Python not to automatically recompile modules to .pyc/.pyo

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

  ViewVC Help
Powered by ViewVC 1.1.20