Gentoo Archives: gentoo-python

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

Replies