From: Michał Górny Date: Tue, 13 Jan 2015 21:34:22 +0000 (+0000) Subject: Support restricting accepted implementation list for python_setup. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bbcde346a55fc947764bb00565ac281e159826a6;p=gentoo.git Support restricting accepted implementation list for python_setup. --- diff --git a/eclass/ChangeLog b/eclass/ChangeLog index d4dc9d5e628b..15e5a93b77e1 100644 --- a/eclass/ChangeLog +++ b/eclass/ChangeLog @@ -1,6 +1,9 @@ # ChangeLog for eclass directory # Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1507 2015/01/12 23:17:14 polynomial-c Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1508 2015/01/13 21:34:22 mgorny Exp $ + + 13 Jan 2015; Michał Górny python-r1.eclass: + Support restricting accepted implementation list for python_setup. 12 Jan 2015; Lars Wendler autotools.eclass: Attempt to fix bug #536428. 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: [...] # @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 }