Gentoo Archives: gentoo-python

From: "Michał Górny" <mgorny@g.o>
To: gentoo-python@l.g.o
Cc: python@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-python] [PATCH 1/3] Make python-single-r1 stand-alone.
Date: Wed, 28 Nov 2012 12:12:09
Message-Id: 1354104802-25167-1-git-send-email-mgorny@gentoo.org
1 It's not that good idea to inherit python-r1 there, so let's just make
2 it work on its own.
3
4 Also, duplicate the docs so that people could find them easily.
5 ---
6 gx86/eclass/python-r1.eclass | 11 ----
7 gx86/eclass/python-single-r1.eclass | 114 ++++++++++++++++++++++++++++--------
8 gx86/eclass/python-utils-r1.eclass | 11 ++++
9 3 files changed, 100 insertions(+), 36 deletions(-)
10
11 diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
12 index c989690..9a02df3 100644
13 --- a/gx86/eclass/python-r1.eclass
14 +++ b/gx86/eclass/python-r1.eclass
15 @@ -44,17 +44,6 @@ if [[ ! ${_PYTHON_R1} ]]; then
16
17 inherit python-utils-r1
18
19 -# @ECLASS-VARIABLE: _PYTHON_ALL_IMPLS
20 -# @INTERNAL
21 -# @DESCRIPTION:
22 -# All supported Python implementations, most preferred last.
23 -_PYTHON_ALL_IMPLS=(
24 - jython2_5
25 - pypy1_8 pypy1_9
26 - python3_1 python3_2 python3_3
27 - python2_5 python2_6 python2_7
28 -)
29 -
30 # @ECLASS-VARIABLE: PYTHON_COMPAT
31 # @REQUIRED
32 # @DESCRIPTION:
33 diff --git a/gx86/eclass/python-single-r1.eclass b/gx86/eclass/python-single-r1.eclass
34 index 1fdf803..3aa350b 100644
35 --- a/gx86/eclass/python-single-r1.eclass
36 +++ b/gx86/eclass/python-single-r1.eclass
37 @@ -23,9 +23,10 @@
38 # (using python-r1 eclass) can not depend on packages not supporting
39 # them (using this eclass).
40 #
41 -# Also, please note that python-single-r1 will always inherit python-r1
42 -# as well. Thus, all the variables defined there are relevant
43 -# to the packages using python-single-r1.
44 +# Please note that python-r1 will always inherit python-utils-r1 as
45 +# well. Thus, all the functions defined there can be used
46 +# in the packages using python-r1, and there is no need ever to inherit
47 +# both.
48 #
49 # For more information, please see the python-r1 Developer's Guide:
50 # http://www.gentoo.org/proj/en/Python/python-r1/dev-guide.xml
51 @@ -44,7 +45,7 @@ esac
52
53 if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
54
55 -inherit python-r1
56 +inherit python-utils-r1
57
58 fi
59
60 @@ -52,13 +53,89 @@ EXPORT_FUNCTIONS pkg_setup
61
62 if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
63
64 +# @ECLASS-VARIABLE: PYTHON_COMPAT
65 +# @REQUIRED
66 +# @DESCRIPTION:
67 +# This variable contains a list of Python implementations the package
68 +# supports. It must be set before the `inherit' call. It has to be
69 +# an array.
70 +#
71 +# Example:
72 +# @CODE
73 +# PYTHON_COMPAT=( python{2_5,2_6,2_7} )
74 +# @CODE
75 +if ! declare -p PYTHON_COMPAT &>/dev/null; then
76 + die 'PYTHON_COMPAT not declared.'
77 +fi
78 +
79 +# @ECLASS-VARIABLE: PYTHON_REQ_USE
80 +# @DEFAULT_UNSET
81 +# @DESCRIPTION:
82 +# The list of USEflags required to be enabled on the chosen Python
83 +# implementations, formed as a USE-dependency string. It should be valid
84 +# for all implementations in PYTHON_COMPAT, so it may be necessary to
85 +# use USE defaults.
86 +#
87 +# Example:
88 +# @CODE
89 +# PYTHON_REQ_USE="gdbm,ncurses(-)?"
90 +# @CODE
91 +#
92 +# It will cause the Python dependencies to look like:
93 +# @CODE
94 +# python_single_target_pythonX_Y? ( dev-lang/python:X.Y[gdbm,ncurses(-)?] )
95 +# @CODE
96 +
97 +# @ECLASS-VARIABLE: PYTHON_DEPS
98 +# @DESCRIPTION:
99 +# This is an eclass-generated Python dependency string for all
100 +# implementations listed in PYTHON_COMPAT.
101 +#
102 +# The dependency string is conditional on PYTHON_SINGLE_TARGET.
103 +#
104 +# Example use:
105 +# @CODE
106 +# RDEPEND="${PYTHON_DEPS}
107 +# dev-foo/mydep"
108 +# DEPEND="${RDEPEND}"
109 +# @CODE
110 +#
111 +# Example value:
112 +# @CODE
113 +# dev-python/python-exec
114 +# python_single_target_python2_6? ( dev-lang/python:2.6[gdbm] )
115 +# python_single_target_python2_7? ( dev-lang/python:2.7[gdbm] )
116 +# @CODE
117 +
118 +# @ECLASS-VARIABLE: PYTHON_USEDEP
119 +# @DESCRIPTION:
120 +# This is an eclass-generated USE-dependency string which can be used to
121 +# depend on another Python package being built for the same Python
122 +# implementations.
123 +#
124 +# The generate USE-flag list is compatible with packages using python-r1,
125 +# python-single-r1 and python-distutils-ng eclasses. It must not be used
126 +# on packages using python.eclass.
127 +#
128 +# Example use:
129 +# @CODE
130 +# RDEPEND="dev-python/foo[${PYTHON_USEDEP}]"
131 +# @CODE
132 +#
133 +# Example value:
134 +# @CODE
135 +# python_targets_python2_7?,python_single_target_python2_7(+)?
136 +# @CODE
137 +
138 _python_single_set_globals() {
139 + local flags_mt=( "${PYTHON_COMPAT[@]/#/python_targets_}" )
140 local flags=( "${PYTHON_COMPAT[@]/#/python_single_target_}" )
141 - local optflags=${flags[@]/%/(+)?}
142 + local optflags=${flags_mt[@]/%/?}
143 + optflags+=,${flags[@]/%/(+)?}
144
145 - IUSE=${flags[*]}
146 - REQUIRED_USE="^^ ( ${flags[*]} )"
147 - PYTHON_USEDEP+=,${optflags// /,}
148 + IUSE="${flags_mt[*]} ${flags[*]}"
149 + REQUIRED_USE="|| ( ${flags_mt[*]} ) ^^ ( ${flags[*]} )"
150 + PYTHON_USEDEP=${optflags// /,}
151
152 local usestr
153 [[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]"
154 @@ -88,6 +165,10 @@ _python_single_set_globals() {
155 }
156 _python_single_set_globals
157
158 +# @FUNCTION: python-single-r1_pkg_setup
159 +# @DESCRIPTION:
160 +# Determine what the selected Python implementation is and set EPYTHON
161 +# and PYTHON accordingly.
162 python-single-r1_pkg_setup() {
163 debug-print-function ${FUNCNAME} "${@}"
164
165 @@ -101,20 +182,3 @@ python-single-r1_pkg_setup() {
166 fi
167 done
168 }
169 -
170 -# Incompatible python-r1 functions.
171 -
172 -python_copy_sources() {
173 - die "${FUNCNAME} must not be used with python-single-r1 eclass."
174 -}
175 -
176 -python_foreach_impl() {
177 - die "${FUNCNAME} must not be used with python-single-r1 eclass."
178 -}
179 -
180 -python_export_best() {
181 - die "${FUNCNAME} must not be used with python-single-r1 eclass."
182 -}
183 -
184 -_PYTHON_SINGLE_R1=1
185 -fi
186 diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
187 index d8e4b81..113e977 100644
188 --- a/gx86/eclass/python-utils-r1.eclass
189 +++ b/gx86/eclass/python-utils-r1.eclass
190 @@ -40,6 +40,17 @@ if [[ ! ${_PYTHON_UTILS_R1} ]]; then
191
192 inherit multilib
193
194 +# @ECLASS-VARIABLE: _PYTHON_ALL_IMPLS
195 +# @INTERNAL
196 +# @DESCRIPTION:
197 +# All supported Python implementations, most preferred last.
198 +_PYTHON_ALL_IMPLS=(
199 + jython2_5
200 + pypy1_8 pypy1_9
201 + python3_1 python3_2 python3_3
202 + python2_5 python2_6 python2_7
203 +)
204 +
205 # @ECLASS-VARIABLE: PYTHON
206 # @DESCRIPTION:
207 # The absolute path to the current Python interpreter.
208 --
209 1.8.0

Replies