diff options
author | 2015-01-13 21:34:22 +0000 | |
---|---|---|
committer | 2015-01-13 21:34:22 +0000 | |
commit | 78f266d651a2790cd04c9b766cb03e149d9a69f0 (patch) | |
tree | 312177bde3fb470b2301b59a2eed3acdb1024331 /eclass/python-r1.eclass | |
parent | really fixing it this time (diff) | |
download | gentoo-2-78f266d651a2790cd04c9b766cb03e149d9a69f0.tar.gz gentoo-2-78f266d651a2790cd04c9b766cb03e149d9a69f0.tar.bz2 gentoo-2-78f266d651a2790cd04c9b766cb03e149d9a69f0.zip |
Support restricting accepted implementation list for python_setup.
Diffstat (limited to 'eclass/python-r1.eclass')
-rw-r--r-- | eclass/python-r1.eclass | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass index 713167d4c038..c0c066359c98 100644 --- a/eclass/python-r1.eclass +++ b/eclass/python-r1.eclass @@ -1,6 +1,6 @@ -# Copyright 1999-2014 Gentoo Foundation +# Copyright 1999-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.82 2014/12/28 22:45:47 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.83 2015/01/13 21:34:22 mgorny Exp $ # @ECLASS: python-r1 # @MAINTAINER: @@ -737,17 +737,56 @@ python_parallel_foreach_impl() { } # @FUNCTION: python_setup +# @USAGE: [<impl-pattern>...] # @DESCRIPTION: -# Find the best (most preferred) Python implementation enabled -# and set the Python build environment up for it. +# Find the best (most preferred) Python implementation that is enabled +# and matches at least one of the patterns passed (or '*' if no patterns +# passed). Set the Python build environment up for that implementation. # # This function needs to be used when Python is being called outside # of python_foreach_impl calls (e.g. for shared processes like doc # building). python_foreach_impl sets up the build environment itself. +# +# If the specific commands support only a subset of Python +# implementations, patterns need to be passed to restrict the allowed +# implementations. +# +# Example: +# @CODE +# DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )" +# +# src_compile() { +# #... +# if use doc; then +# python_setup 'python2*' +# make doc +# fi +# } +# @CODE python_setup() { debug-print-function ${FUNCNAME} "${@}" - python_export_best + local best_impl patterns=( "${@-*}" ) + _python_try_impl() { + local pattern + for pattern in "${patterns[@]}"; do + if [[ ${EPYTHON} == ${pattern} ]]; then + best_impl=${EPYTHON} + fi + done + } + python_foreach_impl _python_try_impl + + if [[ ! ${best_impl} ]]; then + eerror "${FUNCNAME}: none of the enabled implementation matched the patterns." + eerror " patterns: ${@-'(*)'}" + eerror "Likely a REQUIRED_USE constraint (possibly USE-conditional) is missing." + eerror " suggested: || ( \$(python_gen_useflags ${@}) )" + eerror "(remember to quote all the patterns with '')" + die "${FUNCNAME}: no enabled implementation satisfy requirements" + fi + + python_export "${best_impl}" EPYTHON PYTHON python_wrapper_setup } |