Gentoo Archives: gentoo-python

From: Mike Gilbert <floppym@g.o>
To: "Michał Górny" <mgorny@g.o>
Cc: gentoo-python@l.g.o, python@g.o, maksbotan@g.o, sterkrig@×××××××.com
Subject: [gentoo-python] Re: [PATCH 3/3] Support requesting single implementation only (python-single-r1).
Date: Sun, 20 Jan 2013 18:30:51
Message-Id: 50FC37D6.9060308@gentoo.org
In Reply to: [gentoo-python] [PATCH 3/3] Support requesting single implementation only (python-single-r1). by "Michał Górny"
1 On 01/20/2013 05:18 AM, Michał Górny wrote:
2 > ---
3 > gx86/eclass/distutils-r1.eclass | 98 ++++++++++++++++++++++++++++++++---------
4 > 1 file changed, 76 insertions(+), 22 deletions(-)
5 >
6 > diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
7 > index 71c2e67..7c6ace4 100644
8 > --- a/gx86/eclass/distutils-r1.eclass
9 > +++ b/gx86/eclass/distutils-r1.eclass
10 > @@ -66,9 +66,26 @@ esac
11 > # distutils-r1 default phase functions or call the build system
12 > # manually.
13 >
14 > +# @ECLASS-VARIABLE: DISTUTILS_SINGLE_IMPL
15 > +# @DEFAULT_UNSET
16 > +# @DESCRIPTION:
17 > +# If set to a non-null value, the ebuild will support setting a single
18 > +# Python implementation only. It will effectively replace the python-r1
19 > +# eclass inherit with python-single-r1.
20 > +#
21 > +# Note that inheriting python-single-r1 will cause pkg_setup()
22 > +# to be exported. It must be run in order for the eclass functions
23 > +# to function properly.
24 > +
25 > if [[ ! ${_DISTUTILS_R1} ]]; then
26 >
27 > -inherit eutils multiprocessing python-r1
28 > +inherit eutils
29 > +
30 > +if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
31 > + inherit multiprocessing python-r1
32 > +else
33 > + inherit python-single-r1
34 > +fi
35 >
36 > fi
37 >
38 > @@ -237,7 +254,8 @@ distutils-r1_python_prepare_all() {
39 > fi
40 > fi
41 >
42 > - if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
43 > + if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
44 > + then
45 > # create source copies for each implementation
46 > python_copy_sources
47 > fi
48 > @@ -345,11 +363,14 @@ distutils-r1_python_install() {
49 > addpredict /usr/lib/portage/pym
50 >
51 > local root=${D}/_${EPYTHON}
52 > + [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
53 >
54 > esetup.py install "${flags[@]}" --root="${root}" "${@}"
55 > - _distutils-r1_rename_scripts "${root}"
56 >
57 > - _distutils-r1_merge_root "${root}" "${D}"
58 > + if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
59 > + _distutils-r1_rename_scripts "${root}"
60 > + _distutils-r1_merge_root "${root}" "${D}"
61 > + fi
62 > }
63 >
64 > # @FUNCTION: distutils-r1_merge_root
65 > @@ -431,7 +452,9 @@ distutils-r1_run_phase() {
66 > debug-print-function ${FUNCNAME} "${@}"
67 >
68 > if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
69 > - pushd "${BUILD_DIR}" &>/dev/null || die
70 > + if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
71 > + pushd "${BUILD_DIR}" &>/dev/null || die
72 > + fi
73 > else
74 > local PYTHONPATH="${BUILD_DIR}/lib:${PYTHONPATH}"
75 > export PYTHONPATH
76 > @@ -441,7 +464,8 @@ distutils-r1_run_phase() {
77 >
78 > mkdir -p "${TMPDIR}" || die
79 >
80 > - if [[ ${DISTUTILS_NO_PARALLEL_BUILD} ]]; then
81 > + if [[ ${DISTUTILS_NO_PARALLEL_BUILD} || ${DISTUTILS_SINGLE_IMPL} ]]
82 > + then
83 > "${@}" 2>&1 | tee -a "${T}/build-${EPYTHON}.log"
84 > else
85 > (
86 > @@ -451,7 +475,8 @@ distutils-r1_run_phase() {
87 > multijob_post_fork
88 > fi
89 >
90 > - if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
91 > + if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
92 > + then
93 > popd &>/dev/null || die
94 > fi
95 >
96 > @@ -487,14 +512,17 @@ _distutils-r1_run_common_phase() {
97 > _distutils-r1_multijob_init() {
98 > debug-print-function ${FUNCNAME} "${@}"
99 >
100 > - local opts
101 > - if [[ ${DISTUTILS_JOBS} ]]; then
102 > - opts=-j${DISTUTILS_JOBS}
103 > - else
104 > - opts=${MAKEOPTS}
105 > - fi
106 > + if [[ ! ${DISTUTILS_NO_PARALLEL_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
107 > + then
108 > + local opts
109 > + if [[ ${DISTUTILS_JOBS} ]]; then
110 > + opts=-j${DISTUTILS_JOBS}
111 > + else
112 > + opts=${MAKEOPTS}
113 > + fi
114 >
115 > - multijob_init "${opts}"
116 > + multijob_init "${opts}"
117 > + fi
118 > }
119 >
120 > # @FUNCTION: _distutils-r1_multijob_finish
121 > @@ -504,7 +532,33 @@ _distutils-r1_multijob_init() {
122 > _distutils-r1_multijob_finish() {
123 > debug-print-function ${FUNCNAME} "${@}"
124 >
125 > - multijob_finish
126 > + if [[ ! ${DISTUTILS_NO_PARALLEL_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
127 > + then
128 > + multijob_finish
129 > + fi
130 > +}
131 > +
132 > +# @FUNCTION: _distutils-r1_run_foreach_impl
133 > +# @INTERNAL
134 > +# @DESCRIPTION:
135 > +# Run the given phase for each implementation if multiple implementations
136 > +# are enabled, once otherwise.
137 > +_distutils-r1_run_foreach_impl() {
138 > + debug-print-function ${FUNCNAME} "${@}"
139 > +
140 > + set -- distutils-r1_run_phase "${@}"
141 > +
142 > + if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
143 > + python_foreach_impl "${@}"
144 > + else
145 > + if [[ ! ${EPYTHON} ]]; then
146 > + die "EPYTHON unset, python-single-r1_pkg_setup not called?!"
147 > + fi
148 > + local BUILD_DIR=${BUILD_DIR:-${S}}
149 > + BUILD_DIR=${BUILD_DIR%%/}_${EPYTHON}
150 > +
151 > + "${@}"
152 > + fi
153 > }
154 >
155 > distutils-r1_src_prepare() {
156 > @@ -519,7 +573,7 @@ distutils-r1_src_prepare() {
157 >
158 > _distutils-r1_multijob_init
159 > if declare -f python_prepare >/dev/null; then
160 > - python_foreach_impl distutils-r1_run_phase python_prepare
161 > + _distutils-r1_run_foreach_impl python_prepare
162 > fi
163 > _distutils-r1_multijob_finish
164 > }
165 > @@ -527,7 +581,7 @@ distutils-r1_src_prepare() {
166 > distutils-r1_src_configure() {
167 > _distutils-r1_multijob_init
168 > if declare -f python_configure >/dev/null; then
169 > - python_foreach_impl distutils-r1_run_phase python_configure
170 > + _distutils-r1_run_foreach_impl python_configure
171 > fi
172 > _distutils-r1_multijob_finish
173 >
174 > @@ -541,9 +595,9 @@ distutils-r1_src_compile() {
175 >
176 > _distutils-r1_multijob_init
177 > if declare -f python_compile >/dev/null; then
178 > - python_foreach_impl distutils-r1_run_phase python_compile
179 > + _distutils-r1_run_foreach_impl python_compile
180 > else
181 > - python_foreach_impl distutils-r1_run_phase distutils-r1_python_compile
182 > + _distutils-r1_run_foreach_impl distutils-r1_python_compile
183 > fi
184 > _distutils-r1_multijob_finish
185 >
186 > @@ -557,7 +611,7 @@ distutils-r1_src_test() {
187 >
188 > _distutils-r1_multijob_init
189 > if declare -f python_test >/dev/null; then
190 > - python_foreach_impl distutils-r1_run_phase python_test
191 > + _distutils-r1_run_foreach_impl python_test
192 > fi
193 > _distutils-r1_multijob_finish
194 >
195 > @@ -571,9 +625,9 @@ distutils-r1_src_install() {
196 >
197 > _distutils-r1_multijob_init
198 > if declare -f python_install >/dev/null; then
199 > - python_foreach_impl distutils-r1_run_phase python_install
200 > + _distutils-r1_run_foreach_impl python_install
201 > else
202 > - python_foreach_impl distutils-r1_run_phase distutils-r1_python_install
203 > + _distutils-r1_run_foreach_impl distutils-r1_python_install
204 > fi
205 > _distutils-r1_multijob_finish
206 >
207 >
208
209 This seems reasonable. The obvious pitfall is that we will have to be
210 careful about using functions from either python-r1 or python-single-r1.
211
212 Nit: vapier mentioned in another review that redirecting stderr on pushd
213 is wrong, and I'm inclined to agree.

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies