summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2012-10-29 09:25:04 +0000
committerMichał Górny <mgorny@gentoo.org>2012-10-29 09:25:04 +0000
commit218391da6354c10bbc9e463932b6f44ddda500b6 (patch)
tree74c983a3014c1bbbef53ca8a74ccb6a080c1c8f9 /eclass/python-r1.eclass
parentAdd getters for common Python variables. (diff)
downloadgentoo-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/python-r1.eclass')
-rw-r--r--eclass/python-r1.eclass27
1 files changed, 26 insertions, 1 deletions
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}" "${@}"
+}