diff options
author | Michał Górny <mgorny@gentoo.org> | 2012-10-29 09:25:04 +0000 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2012-10-29 09:25:04 +0000 |
commit | 218391da6354c10bbc9e463932b6f44ddda500b6 (patch) | |
tree | 74c983a3014c1bbbef53ca8a74ccb6a080c1c8f9 /eclass | |
parent | Add getters for common Python variables. (diff) | |
download | gentoo-2-218391da6354c10bbc9e463932b6f44ddda500b6.tar.gz gentoo-2-218391da6354c10bbc9e463932b6f44ddda500b6.tar.bz2 gentoo-2-218391da6354c10bbc9e463932b6f44ddda500b6.zip |
Introduce python_export_best() to obtain variables for the most preferred Python implementation enabled.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/ChangeLog | 6 | ||||
-rw-r--r-- | eclass/python-r1.eclass | 27 |
2 files changed, 31 insertions, 2 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog index c4081f1626b0..753a175e9c03 100644 --- a/eclass/ChangeLog +++ b/eclass/ChangeLog @@ -1,6 +1,10 @@ # ChangeLog for eclass directory # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.475 2012/10/29 09:23:58 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.476 2012/10/29 09:25:04 mgorny Exp $ + + 29 Oct 2012; Michał Górny <mgorny@gentoo.org> python-r1.eclass: + Introduce python_export_best() to obtain variables for the most preferred + Python implementation enabled. 29 Oct 2012; Michał Górny <mgorny@gentoo.org> python-r1.eclass: Add getters for common Python variables. diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass index 4ce32bd092d9..eb54c74b7d06 100644 --- a/eclass/python-r1.eclass +++ b/eclass/python-r1.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.9 2012/10/29 09:23:58 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.10 2012/10/29 09:25:04 mgorny Exp $ # @ECLASS: python-r1 # @MAINTAINER: @@ -387,3 +387,28 @@ python_foreach_impl() { fi done } + +# @FUNCTION: python_export_best +# @USAGE: [<variable>...] +# @DESCRIPTION: +# Find the best (most preferred) Python implementation enabled +# and export given variables for it. If no variables are provided, +# EPYTHON & PYTHON will be exported. +python_export_best() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${#} -gt 0 ]] || set -- EPYTHON PYTHON + + local impl best + for impl in "${_PYTHON_ALL_IMPLS[@]}"; do + if has "${impl}" "${PYTHON_COMPAT[@]}" && use "python_targets_${impl}" + then + best=${impl} + fi + done + + [[ ${best+1} ]] || die "python_export_best(): no implementation found!" + + debug-print "${FUNCNAME}: Best implementation is: ${impl}" + python_export "${impl}" "${@}" +} |