mgorny      15/01/13 21:34:22

  Modified:             ChangeLog python-r1.eclass
  Log:
  Support restricting accepted implementation list for python_setup.

Revision  Changes    Path
1.1508               eclass/ChangeLog

file : 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1508&view=markup
plain: 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1508&content-type=text/plain
diff : 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.1507&r2=1.1508

Index: ChangeLog
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v
retrieving revision 1.1507
retrieving revision 1.1508
diff -u -r1.1507 -r1.1508
--- ChangeLog   12 Jan 2015 23:17:14 -0000      1.1507
+++ ChangeLog   13 Jan 2015 21:34:22 -0000      1.1508
@@ -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 <mgo...@gentoo.org> python-r1.eclass:
+  Support restricting accepted implementation list for python_setup.
 
   12 Jan 2015; Lars Wendler <polynomia...@gentoo.org> autotools.eclass:
   Attempt to fix bug #536428.



1.83                 eclass/python-r1.eclass

file : 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python-r1.eclass?rev=1.83&view=markup
plain: 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python-r1.eclass?rev=1.83&content-type=text/plain
diff : 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python-r1.eclass?r1=1.82&r2=1.83

Index: python-r1.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- python-r1.eclass    28 Dec 2014 22:45:47 -0000      1.82
+++ python-r1.eclass    13 Jan 2015 21:34:22 -0000      1.83
@@ -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 @@
 }
 
 # @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
 }
 




Reply via email to