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 2/5] python-single-r1.eclass: Add python_gen_impl_dep, alike in python-r1
Date: Wed, 23 Dec 2015 16:46:38
Message-Id: 1450889080-1920-3-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 ---
2 eclass/python-single-r1.eclass | 58 ++++++++++++++++++++++++++++++++++++++++++
3 1 file changed, 58 insertions(+)
4
5 diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
6 index 4d5026f..9e80866 100644
7 --- a/eclass/python-single-r1.eclass
8 +++ b/eclass/python-single-r1.eclass
9 @@ -411,6 +411,64 @@ python_gen_cond_dep() {
10 echo "${matches[@]}"
11 }
12
13 +# @FUNCTION: python_gen_impl_dep
14 +# @USAGE: [<requested-use-flags> [<impl-pattern>...]]
15 +# @DESCRIPTION:
16 +# Output a dependency on Python implementations with the specified USE
17 +# dependency string appended, or no USE dependency string if called
18 +# without the argument (or with empty argument). If any implementation
19 +# patterns are passed, the output dependencies will be generated only
20 +# for the implementations matching them.
21 +#
22 +# Use this function when you need to request different USE flags
23 +# on the Python interpreter depending on package's USE flags. If you
24 +# only need a single set of interpreter USE flags, just set
25 +# PYTHON_REQ_USE and use ${PYTHON_DEPS} globally.
26 +#
27 +# Example:
28 +# @CODE
29 +# PYTHON_COMPAT=( python{2_7,3_{3,4}} pypy )
30 +# RDEPEND="foo? ( $(python_gen_impl_dep 'xml(+)') )"
31 +# @CODE
32 +#
33 +# It will cause the variable to look like:
34 +# @CODE
35 +# RDEPEND="foo? (
36 +# python_single_target_python2_7? (
37 +# dev-lang/python:2.7[xml(+)] )
38 +# python_single_target_pypy? (
39 +# dev-python/pypy[xml(+)] ) )"
40 +# @CODE
41 +python_gen_impl_dep() {
42 + debug-print-function ${FUNCNAME} "${@}"
43 +
44 + local impl pattern
45 + local matches=()
46 +
47 + if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
48 + flag_prefix=python_targets
49 + else
50 + flag_prefix=python_single_target
51 + fi
52 +
53 + local PYTHON_REQ_USE=${1}
54 + shift
55 +
56 + local patterns=( "${@-*}" )
57 + for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
58 + for pattern in "${patterns[@]}"; do
59 + if [[ ${impl} == ${pattern} ]]; then
60 + local PYTHON_PKG_DEP
61 + python_export "${impl}" PYTHON_PKG_DEP
62 + matches+=( "${flag_prefix}_${impl}? ( ${PYTHON_PKG_DEP} )" )
63 + break
64 + fi
65 + done
66 + done
67 +
68 + echo "${matches[@]}"
69 +}
70 +
71 # @FUNCTION: python_setup
72 # @DESCRIPTION:
73 # Determine what the selected Python implementation is and set
74 --
75 2.6.4