Gentoo Archives: gentoo-dev

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