diff options
author | Michał Górny <mgorny@gentoo.org> | 2012-12-07 18:00:08 +0000 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2012-12-07 18:00:08 +0000 |
commit | 63dc8af7be38f099bcdf57225e1eac24002b4ecb (patch) | |
tree | d635a0bdd9f9e747dfe48847d7a97c78d69732cc /eclass | |
parent | Stable for x86, wrt bug #441164 (diff) | |
download | gentoo-2-63dc8af7be38f099bcdf57225e1eac24002b4ecb.tar.gz gentoo-2-63dc8af7be38f099bcdf57225e1eac24002b4ecb.tar.bz2 gentoo-2-63dc8af7be38f099bcdf57225e1eac24002b4ecb.zip |
Respect user preferences in python-any-r1 (EPYTHON, eselect-python).
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/ChangeLog | 5 | ||||
-rw-r--r-- | eclass/python-any-r1.eclass | 57 |
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[@]}" ) |