Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Thu, 31 Dec 2015 14:52:40
Message-Id: 1451573523.f202e56a0ead3feba43041ee4d5cc45f93c86d85.mgorny@gentoo
1 commit: f202e56a0ead3feba43041ee4d5cc45f93c86d85
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 17 22:23:53 2015 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Thu Dec 31 14:52:03 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f202e56a
7
8 python-r1.eclass: Introduce python_gen_impl_dep
9
10 Add a python_gen_impl_dep() that serves the purpose of generating custom
11 dependencies on the Python interpreter (like PYTHON_DEPS). The function
12 provides ability to request dependencies with another USE dependency
13 string (different than global PYTHON_REQ_USE) and limit the dependencies
14 to subset of supported implementations.
15
16 eclass/python-r1.eclass | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
17 1 file changed, 52 insertions(+)
18
19 diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
20 index 76fd944..6106577 100644
21 --- a/eclass/python-r1.eclass
22 +++ b/eclass/python-r1.eclass
23 @@ -383,6 +383,58 @@ python_gen_cond_dep() {
24 echo "${matches[@]}"
25 }
26
27 +# @FUNCTION: python_gen_impl_dep
28 +# @USAGE: [<requested-use-flags> [<impl-pattern>...]]
29 +# @DESCRIPTION:
30 +# Output a dependency on Python implementations with the specified USE
31 +# dependency string appended, or no USE dependency string if called
32 +# without the argument (or with empty argument). If any implementation
33 +# patterns are passed, the output dependencies will be generated only
34 +# for the implementations matching them.
35 +#
36 +# Use this function when you need to request different USE flags
37 +# on the Python interpreter depending on package's USE flags. If you
38 +# only need a single set of interpreter USE flags, just set
39 +# PYTHON_REQ_USE and use ${PYTHON_DEPS} globally.
40 +#
41 +# Example:
42 +# @CODE
43 +# PYTHON_COMPAT=( python{2_7,3_{3,4}} pypy )
44 +# RDEPEND="foo? ( $(python_gen_impl_dep 'xml(+)') )"
45 +# @CODE
46 +#
47 +# It will cause the variable to look like:
48 +# @CODE
49 +# RDEPEND="foo? (
50 +# python_targets_python2_7? (
51 +# dev-lang/python:2.7[xml(+)] )
52 +# python_targets_pypy? (
53 +# dev-python/pypy[xml(+)] ) )"
54 +# @CODE
55 +python_gen_impl_dep() {
56 + debug-print-function ${FUNCNAME} "${@}"
57 +
58 + local impl pattern
59 + local matches=()
60 +
61 + local PYTHON_REQ_USE=${1}
62 + shift
63 +
64 + local patterns=( "${@-*}" )
65 + for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
66 + for pattern in "${patterns[@]}"; do
67 + if [[ ${impl} == ${pattern} ]]; then
68 + local PYTHON_PKG_DEP
69 + python_export "${impl}" PYTHON_PKG_DEP
70 + matches+=( "python_targets_${impl}? ( ${PYTHON_PKG_DEP} )" )
71 + break
72 + fi
73 + done
74 + done
75 +
76 + echo "${matches[@]}"
77 +}
78 +
79 # @ECLASS-VARIABLE: BUILD_DIR
80 # @DESCRIPTION:
81 # The current build directory. In global scope, it is supposed to