Gentoo Archives: gentoo-commits

From: "Michal Gorny (mgorny)" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: ChangeLog python-single-r1.eclass
Date: Sun, 28 Dec 2014 22:50:27
Message-Id: 20141228225020.64FCCE614@oystercatcher.gentoo.org
1 mgorny 14/12/28 22:50:20
2
3 Modified: ChangeLog python-single-r1.eclass
4 Log:
5 Add python_gen_usedep, python_gen_useflags and python_gen_cond_dep to python-single-r1.
6
7 Revision Changes Path
8 1.1488 eclass/ChangeLog
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1488&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1488&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.1487&r2=1.1488
13
14 Index: ChangeLog
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v
17 retrieving revision 1.1487
18 retrieving revision 1.1488
19 diff -u -r1.1487 -r1.1488
20 --- ChangeLog 28 Dec 2014 22:45:47 -0000 1.1487
21 +++ ChangeLog 28 Dec 2014 22:50:20 -0000 1.1488
22 @@ -1,6 +1,10 @@
23 # ChangeLog for eclass directory
24 # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
25 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1487 2014/12/28 22:45:47 mgorny Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1488 2014/12/28 22:50:20 mgorny Exp $
27 +
28 + 28 Dec 2014; Michał Górny <mgorny@g.o> python-single-r1.eclass:
29 + Add python_gen_usedep, python_gen_useflags and python_gen_cond_dep to
30 + python-single-r1.
31
32 28 Dec 2014; Michał Górny <mgorny@g.o> python-r1.eclass:
33 Spelling, pointed out by floppym.
34
35
36
37 1.30 eclass/python-single-r1.eclass
38
39 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python-single-r1.eclass?rev=1.30&view=markup
40 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python-single-r1.eclass?rev=1.30&content-type=text/plain
41 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python-single-r1.eclass?r1=1.29&r2=1.30
42
43 Index: python-single-r1.eclass
44 ===================================================================
45 RCS file: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v
46 retrieving revision 1.29
47 retrieving revision 1.30
48 diff -u -r1.29 -r1.30
49 --- python-single-r1.eclass 7 Nov 2014 18:11:58 -0000 1.29
50 +++ python-single-r1.eclass 28 Dec 2014 22:50:20 -0000 1.30
51 @@ -1,6 +1,6 @@
52 # Copyright 1999-2014 Gentoo Foundation
53 # Distributed under the terms of the GNU General Public License v2
54 -# $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.29 2014/11/07 18:11:58 axs Exp $
55 +# $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.30 2014/12/28 22:50:20 mgorny Exp $
56
57 # @ECLASS: python-single-r1
58 # @MAINTAINER:
59 @@ -228,6 +228,150 @@
60 }
61 _python_single_set_globals
62
63 +# @FUNCTION: python_gen_usedep
64 +# @USAGE: <pattern> [...]
65 +# @DESCRIPTION:
66 +# Output a USE dependency string for Python implementations which
67 +# are both in PYTHON_COMPAT and match any of the patterns passed
68 +# as parameters to the function.
69 +#
70 +# Remember to escape or quote the patterns to prevent shell filename
71 +# expansion.
72 +#
73 +# When all implementations are requested, please use ${PYTHON_USEDEP}
74 +# instead. Please also remember to set an appropriate REQUIRED_USE
75 +# to avoid ineffective USE flags.
76 +#
77 +# Example:
78 +# @CODE
79 +# PYTHON_COMPAT=( python{2_7,3_4} )
80 +# DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )"
81 +# @CODE
82 +#
83 +# It will cause the dependency to look like:
84 +# @CODE
85 +# DEPEND="doc? ( dev-python/epydoc[python_targets_python2_7(-)?,...] )"
86 +# @CODE
87 +python_gen_usedep() {
88 + debug-print-function ${FUNCNAME} "${@}"
89 +
90 + local impl pattern
91 + local matches=()
92 +
93 + for impl in "${PYTHON_COMPAT[@]}"; do
94 + _python_impl_supported "${impl}" || continue
95 +
96 + for pattern; do
97 + if [[ ${impl} == ${pattern} ]]; then
98 + matches+=(
99 + "python_targets_${impl}(-)?"
100 + "python_single_target_${impl}(+)?"
101 + )
102 + break
103 + fi
104 + done
105 + done
106 +
107 + [[ ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}"
108 +
109 + local out=${matches[@]}
110 + echo "${out// /,}"
111 +}
112 +
113 +# @FUNCTION: python_gen_useflags
114 +# @USAGE: <pattern> [...]
115 +# @DESCRIPTION:
116 +# Output a list of USE flags for Python implementations which
117 +# are both in PYTHON_COMPAT and match any of the patterns passed
118 +# as parameters to the function.
119 +#
120 +# Example:
121 +# @CODE
122 +# PYTHON_COMPAT=( python{2_7,3_4} )
123 +# REQUIRED_USE="doc? ( ^^ ( $(python_gen_useflags 'python2*') ) )"
124 +# @CODE
125 +#
126 +# It will cause the variable to look like:
127 +# @CODE
128 +# REQUIRED_USE="doc? ( ^^ ( python_single_target_python2_7 ) )"
129 +# @CODE
130 +python_gen_useflags() {
131 + debug-print-function ${FUNCNAME} "${@}"
132 +
133 + local impl pattern
134 + local matches=()
135 +
136 + for impl in "${PYTHON_COMPAT[@]}"; do
137 + _python_impl_supported "${impl}" || continue
138 +
139 + for pattern; do
140 + if [[ ${impl} == ${pattern} ]]; then
141 + matches+=( "python_single_target_${impl}" )
142 + break
143 + fi
144 + done
145 + done
146 +
147 + echo "${matches[@]}"
148 +}
149 +
150 +# @FUNCTION: python_gen_cond_dep
151 +# @USAGE: <dependency> <pattern> [...]
152 +# @DESCRIPTION:
153 +# Output a list of <dependency>-ies made conditional to USE flags
154 +# of Python implementations which are both in PYTHON_COMPAT and match
155 +# any of the patterns passed as the remaining parameters.
156 +#
157 +# In order to enforce USE constraints on the packages, verbatim
158 +# '${PYTHON_USEDEP}' (quoted!) may be placed in the dependency
159 +# specification. It will get expanded within the function into a proper
160 +# USE dependency string.
161 +#
162 +# Example:
163 +# @CODE
164 +# PYTHON_COMPAT=( python{2_5,2_6,2_7} )
165 +# RDEPEND="$(python_gen_cond_dep \
166 +# 'dev-python/unittest2[${PYTHON_USEDEP}]' python{2_5,2_6})"
167 +# @CODE
168 +#
169 +# It will cause the variable to look like:
170 +# @CODE
171 +# RDEPEND="python_single_target_python2_5? (
172 +# dev-python/unittest2[python_targets_python2_5(-)?,...] )
173 +# python_single_target_python2_6? (
174 +# dev-python/unittest2[python_targets_python2_6(-)?,...] )"
175 +# @CODE
176 +python_gen_cond_dep() {
177 + debug-print-function ${FUNCNAME} "${@}"
178 +
179 + local impl pattern
180 + local matches=()
181 +
182 + local dep=${1}
183 + shift
184 +
185 + for impl in "${PYTHON_COMPAT[@]}"; do
186 + _python_impl_supported "${impl}" || continue
187 +
188 + for pattern; do
189 + if [[ ${impl} == ${pattern} ]]; then
190 + # substitute ${PYTHON_USEDEP} if used
191 + # (since python_gen_usedep() will not return ${PYTHON_USEDEP}
192 + # the code is run at most once)
193 + if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
194 + local PYTHON_USEDEP=$(python_gen_usedep "${@}")
195 + dep=${dep//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}}
196 + fi
197 +
198 + matches+=( "python_single_target_${impl}? ( ${dep} )" )
199 + break
200 + fi
201 + done
202 + done
203 +
204 + echo "${matches[@]}"
205 +}
206 +
207 # @FUNCTION: python_setup
208 # @DESCRIPTION:
209 # Determine what the selected Python implementation is and set