Dnia 2014-12-27, o godz. 14:50:43 Michał Górny <mgo...@gentoo.org> napisał(a):
> 2. python_setup changes API to: > > python_setup [<impl-wildcard>...] > > alike python_gen_* functions, defaulting to '*'. Now it chooses > the best impl from implementations matching the specified patterns, > e.g.: > > python_setup 'python2*' > > would get the best version of CPython 2. Patch for this one attached. -- Best regards, Michał Górny
Index: python-r1.eclass =================================================================== RCS file: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v retrieving revision 1.81 diff -u -B -r1.81 python-r1.eclass --- python-r1.eclass 28 Dec 2014 10:56:55 -0000 1.81 +++ python-r1.eclass 28 Dec 2014 12:00:02 -0000 @@ -737,17 +737,56 @@ } # @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 }
pgpJ9FCZglRpd.pgp
Description: OpenPGP digital signature