Gentoo Archives: gentoo-python

From: "Michał Górny" <mgorny@g.o>
To: "Michał Górny" <mgorny@g.o>
Cc: gentoo-python@l.g.o, python@g.o
Subject: Re: [gentoo-python] [PATCH python-ebuilds] python2.7: first ebuild converted to python-utils-r1.
Date: Wed, 21 Nov 2012 20:49:44
Message-Id: 20121121215049.79b7cc38@pomiocik.lan
In Reply to: [gentoo-python] [PATCH python-ebuilds] python2.7: first ebuild converted to python-utils-r1. by "Michał Górny"
1 And here are the detailed changes...
2
3 On Wed, 21 Nov 2012 21:36:18 +0100
4 Michał Górny <mgorny@g.o> wrote:
5
6 > diff --git a/gx86/dev-lang/python/python-2.7.3-r2.ebuild b/gx86/dev-lang/python/python-2.7.3-r3.ebuild
7 > similarity index 68%
8 > copy from gx86/dev-lang/python/python-2.7.3-r2.ebuild
9 > copy to gx86/dev-lang/python/python-2.7.3-r3.ebuild
10 > index e9112a4..0368c65 100644
11 > --- a/gx86/dev-lang/python/python-2.7.3-r2.ebuild
12 > +++ b/gx86/dev-lang/python/python-2.7.3-r3.ebuild
13 > @@ -2,11 +2,11 @@
14 > # Distributed under the terms of the GNU General Public License v2
15 > # $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.7.3-r2.ebuild,v 1.12 2012/07/30 18:09:26 vapier Exp $
16 >
17 > -EAPI="2"
18 > +EAPI=4
19 > WANT_AUTOMAKE="none"
20 > WANT_LIBTOOL="none"
21 >
22 > -inherit autotools eutils flag-o-matic multilib pax-utils python toolchain-funcs
23 > +inherit autotools eutils flag-o-matic multilib pax-utils python-utils-r1 toolchain-funcs
24 >
25 > MY_P="Python-${PV}"
26 > PATCHSET_REVISION="1"
27 > @@ -18,11 +18,11 @@ SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.bz2
28 >
29 > LICENSE="PSF-2"
30 > SLOT="2.7"
31 > -PYTHON_ABI="${SLOT}"
32
33 The PYTHON_ABI variable triggered some random magic in python.eclass,
34 not really relevant anymore.
35
36 > -KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
37 > +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
38 > IUSE="-berkdb build doc elibc_uclibc examples gdbm ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
39 >
40 > RDEPEND="app-arch/bzip2
41 > + app-admin/eselect-python
42 > >=sys-libs/zlib-1.1.3
43 > virtual/libffi
44 > virtual/libintl
45 > @@ -56,20 +56,20 @@ DEPEND="${RDEPEND}
46 > !sys-devel/gcc[libffi]"
47 > RDEPEND+=" !build? ( app-misc/mime-types )
48 > doc? ( dev-python/python-docs:${SLOT} )"
49 > +PDEPEND="app-admin/python-updater"
50
51 The dependencies appended implicitly by python.eclass. Quite a bad idea
52 to append eselect-python dep from an eclass while the code calling it
53 is inlined in the ebuild...
54
55 >
56 > S="${WORKDIR}/${MY_P}"
57 >
58 > pkg_setup() {
59 > - python_pkg_setup
60 > -
61
62 Well, this one didn't do anything really specific. Mostly set EPYTHON
63 which wasn't used anywhere else...
64
65 > if use berkdb; then
66 > - ewarn "\"bsddb\" module is out-of-date and no longer maintained inside dev-lang/python."
67 > - ewarn "\"bsddb\" and \"dbhash\" modules have been additionally removed in Python 3."
68 > - ewarn "You should use external, still maintained \"bsddb3\" module provided by dev-python/bsddb3,"
69 > - ewarn "which supports both Python 2 and Python 3."
70 > + ewarn "'bsddb' module is out-of-date and no longer maintained inside"
71 > + ewarn "dev-lang/python. 'bsddb' and 'dbhash' modules have been additionally"
72 > + ewarn "removed in Python 3. A maintained alternative of 'bsddb3' module"
73 > + ewarn "is provided by dev-python/bsddb3."
74
75 Re-wrapped with a useful line width, and a few improvements inspired
76 and checked by idella4.
77
78 > else
79 > if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then
80 > - ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb] to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
81 > + ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"
82 > + ewarn "to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
83 > ewarn "You might need to migrate your databases."
84 > fi
85 > fi
86 > @@ -152,7 +152,7 @@ src_configure() {
87 > if tc-is-cross-compiler; then
88 > OPT="-O1" CFLAGS="" LDFLAGS="" CC="" \
89 > ./configure --{build,host}=${CBUILD} || die "cross-configure failed"
90 > - emake python Parser/pgen || die "cross-make failed"
91 > + emake python Parser/pgen
92
93 EAPI 4.
94
95 > mv python hostpython
96 > mv Parser/pgen Parser/hostpgen
97 > make distclean
98 > @@ -197,7 +197,7 @@ src_configure() {
99 > }
100 >
101 > src_compile() {
102 > - emake EPYTHON="python${PV%%.*}" || die "emake failed"
103 > + default
104
105 I have no idea what this 'EPYTHON' was supposed to be. Seems that it
106 was supposed to be 'python2' here but it ain't used anywhere
107 in the sources or the patches.
108
109 >
110 > # Work around bug 329499. See also bug 413751.
111 > pax-mark m python
112 > @@ -210,23 +210,18 @@ src_test() {
113 > return
114 > fi
115 >
116 > - # Byte compiling should be enabled here.
117 > - # Otherwise test_import fails.
118 > - python_enable_pyc
119 > -
120
121 Have no idea if this is relevant to anything. From my tests it seems
122 that the same tests fail without this.
123
124 > # Skip failing tests.
125 > local skipped_tests="distutils gdb"
126 >
127 > for test in ${skipped_tests}; do
128 > - mv Lib/test/test_${test}.py "${T}"
129 > + mv Lib/test/test_${test}.py "${T}" || die
130
131 Missing ||die.
132
133 > done
134 >
135 > # Rerun failed tests in verbose mode (regrtest -w).
136 > emake test EXTRATESTOPTS="-w" < /dev/tty
137 > - local result="$?"
138
139 emake dies in EAPI 4, so no point in trying to delay it.
140
141 >
142 > for test in ${skipped_tests}; do
143 > - mv "${T}/test_${test}.py" Lib/test
144 > + mv "${T}/test_${test}.py" Lib/test || die
145 > done
146 >
147 > elog "The following tests have been skipped:"
148 > @@ -235,73 +230,69 @@ src_test() {
149 > done
150 >
151 > elog "If you would like to run them, you may:"
152 > - elog "cd '${EPREFIX}$(python_get_libdir)/test'"
153 > + elog "cd '${EPREFIX}/usr/$(get_libdir)/python${SLOT}/test'"
154
155 python_get_libdir is a really bad function. Especially that the result
156 is implementation-dependent, and it doesn't work in pypy.
157
158 > elog "and run the tests separately."
159 > -
160 > - python_disable_pyc
161 > -
162 > - if [[ "${result}" -ne 0 ]]; then
163 > - die "emake test failed"
164 > - fi
165 > }
166 >
167 > src_install() {
168 > - [[ -z "${ED}" ]] && ED="${D%/}${EPREFIX}/"
169 > + local libdir=${ED}/usr/$(get_libdir)/python${SLOT}
170
171 Like above + 'retrieve' it once for the whole phase.
172
173 >
174 > - emake DESTDIR="${D}" altinstall maninstall || die "emake altinstall maninstall failed"
175 > - python_clean_installation_image -q
176
177 This one was supposed to remove compiled files which the ebuild just
178 compiled... Now the compiled files are installed as a part
179 of the package.
180
181 > + emake DESTDIR="${D}" altinstall maninstall
182 >
183 > - sed -e "s/\(LDFLAGS=\).*/\1/" -i "${ED}$(python_get_libdir)/config/Makefile" || die "sed failed"
184 > + sed -e "s/\(LDFLAGS=\).*/\1/" \
185 > + -i "${libdir}/config/Makefile" || die "sed failed"
186 >
187 > - mv "${ED}usr/bin/python${SLOT}-config" "${ED}usr/bin/python-config-${SLOT}"
188 > + mv "${ED}usr/bin/python${SLOT}-config" \
189 > + "${ED}usr/bin/python-config-${SLOT}" || die
190 >
191 > # Fix collisions between different slots of Python.
192 > - mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}"
193 > - mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}"
194 > - mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}"
195 > + mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}" || die
196 > + mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}" || die
197 > + mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}" || die
198
199 Wrapping and missing ||die.
200
201 > rm -f "${ED}usr/bin/smtpd.py"
202 >
203 > if use build; then
204 > - rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{bsddb,dbhash.py,idlelib,lib-tk,sqlite3,test}
205 > + rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{bsddb,dbhash.py,idlelib,lib-tk,sqlite3,test}
206 > else
207 > - use elibc_uclibc && rm -fr "${ED}$(python_get_libdir)/"{bsddb/test,test}
208 > - use berkdb || rm -fr "${ED}$(python_get_libdir)/"{bsddb,dbhash.py,test/test_bsddb*}
209 > - use sqlite || rm -fr "${ED}$(python_get_libdir)/"{sqlite3,test/test_sqlite*}
210 > - use tk || rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{idlelib,lib-tk}
211 > + use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test}
212 > + use berkdb || rm -fr "${libdir}/"{bsddb,dbhash.py,test/test_bsddb*}
213 > + use sqlite || rm -fr "${libdir}/"{sqlite3,test/test_sqlite*}
214 > + use tk || rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{idlelib,lib-tk}
215 > fi
216 >
217 > - use threads || rm -fr "${ED}$(python_get_libdir)/multiprocessing"
218 > - use wininst || rm -f "${ED}$(python_get_libdir)/distutils/command/"wininst-*.exe
219 > + use threads || rm -fr "${libdir}/multiprocessing"
220 > + use wininst || rm -f "${libdir}/distutils/command/"wininst-*.exe
221 >
222 > - dodoc Misc/{ACKS,HISTORY,NEWS} || die "dodoc failed"
223 > + dodoc Misc/{ACKS,HISTORY,NEWS}
224 >
225 > if use examples; then
226 > insinto /usr/share/doc/${PF}/examples
227 > - doins -r Tools || die "doins failed"
228 > + doins -r Tools
229 > fi
230 >
231 > - newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} || die "newconfd failed"
232 > - newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} || die "newinitd failed"
233 > + newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT}
234 > + newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT}
235 > sed \
236 > -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${SLOT/./_}_PORT:" \
237 > -e "s:@PYDOC@:pydoc${SLOT}:" \
238 > - -i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" || die "sed failed"
239 > -}
240 > + -i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" \
241 > + || die "pydoc initscript sed failed"
242 >
243 > -pkg_preinst() {
244 > - if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.7"; then
245 > - python_updater_warning="1"
246 > - fi
247
248 See below.
249
250 > + # for python-exec
251 > + local EPYTHON=python${SLOT}
252 > + echo "EPYTHON='${EPYTHON}'" > epython.py
253 > + python_domodule epython.py
254
255 A little trick which allows us to get a definitely correct EPYTHON
256 value from the Python interpreter without resorting to ugly hackery:
257
258 from epython import EPYTHON
259
260 > }
261 >
262 > eselect_python_update() {
263 > - [[ -z "${EROOT}" || (! -d "${EROOT}" && -d "${ROOT}") ]] && EROOT="${ROOT%/}${EPREFIX}/"
264
265 Ugly pre-EAPI3 Prefix hackery.
266
267 > -
268 > - if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
269 > + if [[ -z "$(eselect python show)"
270 > + || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
271 > eselect python update
272 > fi
273 >
274 > - if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
275 > + if [[ -z "$(eselect python show --python${PV%%.*})"
276 > + || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]
277 > + then
278 > eselect python update --python${PV%%.*}
279 > fi
280 > }
281 > @@ -309,9 +300,8 @@ eselect_python_update() {
282 > pkg_postinst() {
283 > eselect_python_update
284 >
285 > - python_mod_optimize -f -x "/(site-packages|test|tests)/" $(python_get_libdir)
286
287 Optimization was done during install.
288
289 > -
290 > - if [[ "${python_updater_warning}" == "1" ]]; then
291 > + if has_version "<${CATEGORY}/${PN}-${SLOT}" && [[ ! ${REPLACING_VERSIONS} ]]
292 > + then
293
294 Instead of preinst checks, let's just use EAPI4 REPLACING_VERSIONS. I'm
295 not sure if this is 100% correct/equal. PMS mentions something about
296 'pathological' (who wrote that spec?!) uses for it, so I'm not sure if
297 it is really supposed to list packages in the same slot only...
298
299 > ewarn "You have just upgraded from an older version of Python."
300 > ewarn "You should switch active version of Python ${PV%%.*} and run"
301 > ewarn "'python-updater [options]' to rebuild Python modules."
302 > @@ -320,6 +310,4 @@ pkg_postinst() {
303 >
304 > pkg_postrm() {
305 > eselect_python_update
306 > -
307 > - python_mod_cleanup $(python_get_libdir)
308 > }
309
310 --
311 Best regards,
312 Michał Górny

Attachments

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