# 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 <mgorny@gentoo.org> python-r1.eclass:
+ Support restricting accepted implementation list for python_setup.
12 Jan 2015; Lars Wendler <polynomial-c@gentoo.org> autotools.eclass:
Attempt to fix bug #536428.
-# 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:
}
# @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
}