summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2012-12-07 18:00:08 +0000
committerMichał Górny <mgorny@gentoo.org>2012-12-07 18:00:08 +0000
commite4e6ba0a0004a77c067f151a09cea26b5b6bd43c (patch)
tree4c61054bc0acf7e5e820b1448db78c1db5c56815 /eclass
parentStable for x86, wrt bug #441164 (diff)
downloadhistorical-e4e6ba0a0004a77c067f151a09cea26b5b6bd43c.tar.gz
historical-e4e6ba0a0004a77c067f151a09cea26b5b6bd43c.tar.bz2
historical-e4e6ba0a0004a77c067f151a09cea26b5b6bd43c.zip
Respect user preferences in python-any-r1 (EPYTHON, eselect-python).
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog5
-rw-r--r--eclass/python-any-r1.eclass57
2 files changed, 59 insertions, 3 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index 59a52e700d4c..2e36d2a30d73 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,9 @@
# ChangeLog for eclass directory
# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.550 2012/12/07 17:59:12 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.551 2012/12/07 18:00:08 mgorny Exp $
+
+ 07 Dec 2012; Michał Górny <mgorny@gentoo.org> python-any-r1.eclass:
+ Respect user preferences in python-any-r1 (EPYTHON, eselect-python).
07 Dec 2012; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass:
Write split build logs for easier debugging.
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index 7f48f20a0e19..ad56dc7520e2 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-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-any-r1.eclass,v 1.1 2012/12/01 09:29:24 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-any-r1.eclass,v 1.2 2012/12/07 18:00:08 mgorny Exp $
# @ECLASS: python-any-r1
# @MAINTAINER:
@@ -135,6 +135,36 @@ _python_build_set_globals() {
}
_python_build_set_globals
+# @FUNCTION: _python_impl_supported
+# @USAGE: <epython>
+# @INTERNAL
+# @DESCRIPTION:
+# Check whether the specified implementation is supported by package
+# (specified in PYTHON_COMPAT).
+_python_impl_supported() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local i=${1/./_}
+
+ case "${i}" in
+ python*|jython*)
+ ;;
+ pypy-c*)
+ i=${i/-c/}
+ ;;
+ *)
+ ewarn "Invalid EPYTHON: ${EPYTHON}"
+ ;;
+ esac
+
+ if has "${i}" "${PYTHON_COMPAT[@]}"; then
+ return 0
+ elif ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then
+ ewarn "Invalid EPYTHON: ${EPYTHON}"
+ fi
+ return 1
+}
+
# @FUNCTION: python-any-r1_pkg_setup
# @DESCRIPTION:
# Determine what the best installed (and supported) Python
@@ -142,7 +172,30 @@ _python_build_set_globals
python-any-r1_pkg_setup() {
debug-print-function ${FUNCNAME} "${@}"
- local i rev_impls=()
+ # first, try ${EPYTHON}... maybe it's good enough for us.
+ if [[ ${EPYTHON} ]]; then
+ if _python_impl_supported "${EPYTHON}"; then
+ python_export EPYTHON PYTHON
+ return
+ fi
+ fi
+
+ # then, try eselect-python
+ local variant i
+ for variant in '' '--python2' '--python3'; do
+ i=$(eselect python --show ${variant} 2>/dev/null)
+
+ if [[ ! ${i} ]]; then
+ # no eselect-python?
+ break
+ elif _python_impl_supported "${i}"; then
+ python_export "${i}" EPYTHON PYTHON
+ return
+ fi
+ done
+
+ # fallback to best installed impl.
+ local rev_impls=()
for i in "${_PYTHON_ALL_IMPLS[@]}"; do
if has "${i}" "${PYTHON_COMPAT[@]}"; then
rev_impls=( "${i}" "${rev_impls[@]}" )