Gentoo Archives: gentoo-commits

From: "Mike Gilbert (floppym)" <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-lang/python: python-2.5.4-r6.ebuild python-2.6.8-r2.ebuild ChangeLog
Date: Sun, 30 Jun 2013 16:08:12
Message-Id: 20130630160808.E5D4A2171C@flycatcher.gentoo.org
1 floppym 13/06/30 16:08:08
2
3 Modified: ChangeLog
4 Added: python-2.5.4-r6.ebuild python-2.6.8-r2.ebuild
5 Log:
6 Apply patch to allow old python versions to use tk-8.6, bug 454342. Also fix the python shebang in idle2.5 and pydoc2.5, bugs 275241 and 383009.
7
8 (Portage version: 2.2.0_alpha186/cvs/Linux x86_64, signed Manifest commit with key 0BBEEA1FEA4843A4)
9
10 Revision Changes Path
11 1.662 dev-lang/python/ChangeLog
12
13 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/ChangeLog?rev=1.662&view=markup
14 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/ChangeLog?rev=1.662&content-type=text/plain
15 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/ChangeLog?r1=1.661&r2=1.662
16
17 Index: ChangeLog
18 ===================================================================
19 RCS file: /var/cvsroot/gentoo-x86/dev-lang/python/ChangeLog,v
20 retrieving revision 1.661
21 retrieving revision 1.662
22 diff -u -r1.661 -r1.662
23 --- ChangeLog 30 Jun 2013 03:36:01 -0000 1.661
24 +++ ChangeLog 30 Jun 2013 16:08:08 -0000 1.662
25 @@ -1,6 +1,14 @@
26 # ChangeLog for dev-lang/python
27 # Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
28 -# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/ChangeLog,v 1.661 2013/06/30 03:36:01 floppym Exp $
29 +# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/ChangeLog,v 1.662 2013/06/30 16:08:08 floppym Exp $
30 +
31 +*python-2.6.8-r2 (30 Jun 2013)
32 +*python-2.5.4-r6 (30 Jun 2013)
33 +
34 + 30 Jun 2013; Mike Gilbert <floppym@g.o> +files/python-2.5-tcl86.patch,
35 + +python-2.5.4-r6.ebuild, +python-2.6.8-r2.ebuild:
36 + Apply patch to allow old python versions to use tk-8.6, bug 454342. Also fix
37 + the python shebang in idle2.5 and pydoc2.5, bugs 275241 and 383009.
38
39 30 Jun 2013; Mike Gilbert <floppym@g.o> -python-2.5.4-r4.ebuild,
40 -python-2.6.8.ebuild, python-2.5.4-r5.ebuild, python-2.6.8-r1.ebuild:
41
42
43
44 1.1 dev-lang/python/python-2.5.4-r6.ebuild
45
46 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/python-2.5.4-r6.ebuild?rev=1.1&view=markup
47 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/python-2.5.4-r6.ebuild?rev=1.1&content-type=text/plain
48
49 Index: python-2.5.4-r6.ebuild
50 ===================================================================
51 # Copyright 1999-2013 Gentoo Foundation
52 # Distributed under the terms of the GNU General Public License v2
53 # $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.5.4-r6.ebuild,v 1.1 2013/06/30 16:08:08 floppym Exp $
54
55 EAPI="1"
56
57 inherit autotools eutils flag-o-matic multilib pax-utils python-utils-r1 toolchain-funcs
58
59 MY_P="Python-${PV}"
60
61 PATCHSET_REVISION="3"
62
63 DESCRIPTION="An interpreted, interactive, object-oriented programming language"
64 HOMEPAGE="http://www.python.org/"
65 SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.bz2
66 mirror://gentoo/python-gentoo-patches-${PV}$([[ "${PATCHSET_REVISION}" != "0" ]] && echo "-r${PATCHSET_REVISION}").tar.bz2"
67
68 LICENSE="PSF-2.2"
69 SLOT="2.5"
70 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
71 IUSE="-berkdb build doc elibc_uclibc examples gdbm hardened ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
72
73 # Do not add a dependency on dev-lang/python to this ebuild.
74 # If you need to apply a patch which requires python for bootstrapping, please
75 # run the bootstrap code on your dev box and include the results in the
76 # patchset. See bug 447752.
77
78 # NOTE: dev-python/{elementtree,celementtree,pysqlite}
79 # do not conflict with the ones in python proper. - liquidx
80
81 RDEPEND=">=sys-libs/zlib-1.1.3
82 virtual/libffi
83 virtual/libintl
84 !build? (
85 berkdb? ( || (
86 sys-libs/db:4.5
87 sys-libs/db:4.4
88 sys-libs/db:4.3
89 sys-libs/db:4.2
90 ) )
91 gdbm? ( sys-libs/gdbm )
92 ncurses? (
93 >=sys-libs/ncurses-5.2
94 readline? ( >=sys-libs/readline-4.1 )
95 )
96 sqlite? ( >=dev-db/sqlite-3 )
97 ssl? ( dev-libs/openssl )
98 tk? ( >=dev-lang/tk-8.0 )
99 xml? ( >=dev-libs/expat-2 )
100 )
101 doc? ( dev-python/python-docs:${SLOT} )"
102 DEPEND="${RDEPEND}
103 virtual/pkgconfig"
104 RDEPEND+=" !build? ( app-misc/mime-types )"
105 PDEPEND="app-admin/eselect-python
106 app-admin/python-updater"
107
108 S="${WORKDIR}/${MY_P}"
109
110 pkg_setup() {
111 if use berkdb; then
112 ewarn "'bsddb' module is out-of-date and no longer maintained inside"
113 ewarn "dev-lang/python. 'bsddb' and 'dbhash' modules have been additionally"
114 ewarn "removed in Python 3. A maintained alternative of 'bsddb3' module"
115 ewarn "is provided by dev-python/bsddb3."
116 fi
117 }
118
119 src_unpack() {
120 unpack ${A}
121 cd "${S}"
122
123 # Ensure that internal copies of expat, libffi and zlib are not used.
124 rm -fr Modules/expat
125 rm -fr Modules/_ctypes/libffi*
126 rm -fr Modules/zlib
127
128 if tc-is-cross-compiler; then
129 epatch "${FILESDIR}/python-2.5-cross-printf.patch"
130 else
131 rm "${WORKDIR}/${PV}"/*_all_crosscompile.patch
132 fi
133
134 EPATCH_SUFFIX="patch" epatch "${WORKDIR}/${PV}"
135
136 epatch "${FILESDIR}/python-2.5-tcl86.patch"
137
138 sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
139 Lib/distutils/command/install.py \
140 Lib/distutils/sysconfig.py \
141 Lib/site.py \
142 Makefile.pre.in \
143 Modules/Setup.dist \
144 Modules/getpath.c \
145 setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
146
147 # Fix os.utime() on hppa. utimes it not supported but unfortunately reported as working - gmsoft (22 May 04)
148 # PLEASE LEAVE THIS FIX FOR NEXT VERSIONS AS IT'S A CRITICAL FIX !!!
149 [[ "${ARCH}" == "hppa" ]] && sed -e "s/utimes //" -i "${S}/configure"
150
151 if ! use wininst; then
152 # Remove Microsoft Windows executables.
153 rm Lib/distutils/command/wininst-*.exe
154 fi
155
156 # Linux-3 compat. Bug #374579 (upstream issue12571)
157 cp -r "${S}/Lib/plat-linux2" "${S}/Lib/plat-linux3" || die
158
159 epatch_user
160
161 eautoreconf
162 }
163
164 src_configure() {
165 # Disable extraneous modules with extra dependencies.
166 if use build; then
167 export PYTHON_DISABLE_MODULES="dbm _bsddb gdbm _curses _curses_panel readline _sqlite3 _tkinter pyexpat"
168 export PYTHON_DISABLE_SSL="1"
169 else
170 # dbm module can be linked against berkdb or gdbm.
171 # Defaults to gdbm when both are enabled, #204343.
172 local disable
173 use berkdb || use gdbm || disable+=" dbm"
174 use berkdb || disable+=" _bsddb"
175 use gdbm || disable+=" gdbm"
176 use ncurses || disable+=" _curses _curses_panel"
177 use readline || disable+=" readline"
178 use sqlite || disable+=" _sqlite3"
179 use ssl || export PYTHON_DISABLE_SSL="1"
180 use tk || disable+=" _tkinter"
181 use xml || disable+=" pyexpat"
182 export PYTHON_DISABLE_MODULES="${disable}"
183
184 if ! use xml; then
185 ewarn "You have configured Python without XML support."
186 ewarn "This is NOT a recommended configuration as you"
187 ewarn "may face problems parsing any XML documents."
188 fi
189 fi
190
191 if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
192 einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
193 fi
194
195 if [[ "$(gcc-major-version)" -ge 4 ]]; then
196 append-flags -fwrapv
197 fi
198
199 export OPT="${CFLAGS}"
200
201 filter-flags -malign-double
202
203 [[ "${ARCH}" == "alpha" ]] && append-flags -fPIC
204
205 # https://bugs.gentoo.org/show_bug.cgi?id=50309
206 if is-flagq -O3; then
207 is-flagq -fstack-protector-all && replace-flags -O3 -O2
208 use hardened && replace-flags -O3 -O2
209 fi
210
211 if tc-is-cross-compiler; then
212 OPT="-O1" CFLAGS="" LDFLAGS="" CC="" \
213 ./configure --{build,host}=${CBUILD} || die "cross-configure failed"
214 emake python Parser/pgen || die "cross-make failed"
215 mv python hostpython
216 mv Parser/pgen Parser/hostpgen
217 make distclean
218 sed -i \
219 -e "/^HOSTPYTHON/s:=.*:=./hostpython:" \
220 -e "/^HOSTPGEN/s:=.*:=./Parser/hostpgen:" \
221 Makefile.pre.in || die "sed failed"
222 fi
223
224 # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.
225 tc-export CXX
226 # The configure script fails to use pkg-config correctly.
227 # http://bugs.python.org/issue15506
228 export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG)
229
230 # Set LDFLAGS so we link modules with -lpython2.5 correctly.
231 # Needed on FreeBSD unless Python 2.5 is already installed.
232 # Please query BSD team before removing this!
233 append-ldflags "-L."
234
235 econf \
236 --with-fpectl \
237 --enable-shared \
238 $(use_enable ipv6) \
239 $(use_with threads) \
240 $(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2") \
241 --infodir='${prefix}/share/info' \
242 --mandir='${prefix}/share/man' \
243 --with-libc="" \
244 --with-system-ffi
245 }
246
247 src_compile() {
248 src_configure
249 emake || die "emake failed"
250 }
251
252 src_test() {
253 # Tests will not work when cross compiling.
254 if tc-is-cross-compiler; then
255 elog "Disabling tests due to crosscompiling."
256 return
257 fi
258
259 # Skip failing tests.
260 local skip_tests="distutils global mimetools minidom mmap posix pyexpat sax strptime subprocess syntax tcl time urllib urllib2 xml_etree"
261
262 # test_ctypes fails with PAX kernel (bug #234498).
263 host-is-pax && skip_tests+=" ctypes"
264
265 for test in ${skip_tests}; do
266 mv "${S}/Lib/test/test_${test}.py" "${T}"
267 done
268
269 # Redirect stdin from /dev/tty as a workaround for bug #248081.
270 # Rerun failed tests in verbose mode (regrtest -w).
271 EXTRATESTOPTS="-w" emake test < /dev/tty
272 local result="$?"
273
274 for test in ${skip_tests}; do
275 mv "${T}/test_${test}.py" "${S}/Lib/test/test_${test}.py"
276 done
277
278 elog "The following tests have been skipped:"
279 for test in ${skip_tests}; do
280 elog "test_${test}.py"
281 done
282
283 elog "If you would like to run them, you may:"
284 elog "cd '${EPREFIX}/usr/$(get_libdir)/python${SLOT}/test'"
285 elog "and run the tests separately."
286
287 if [[ "${result}" -ne 0 ]]; then
288 die "emake test failed"
289 fi
290 }
291
292 src_install() {
293 [[ -z "${ED}" ]] && ED="${D%/}${EPREFIX}/"
294
295 local libdir=${ED}/usr/$(get_libdir)/python${SLOT}
296
297 emake DESTDIR="${D}" altinstall maninstall || die "emake altinstall maninstall failed"
298
299 # Backwards compat with Gentoo divergence.
300 dosym python${SLOT}-config /usr/bin/python-config-${SLOT} || die
301
302 # Fix collisions between different slots of Python.
303 mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}"
304 _python_rewrite_shebang python${SLOT} "${ED}usr/bin/pydoc${SLOT}"
305 mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}"
306 _python_rewrite_shebang python${SLOT} "${ED}usr/bin/idle${SLOT}"
307 mv "${ED}usr/share/man/man1/python.1" "${ED}usr/share/man/man1/python${SLOT}.1"
308 rm -f "${ED}usr/bin/smtpd.py"
309
310 # Fix the OPT variable so that it doesn't have any flags listed in it.
311 # Prevents the problem with compiling things with conflicting flags later.
312 sed -e "s:^OPT=.*:OPT=\t\t-DNDEBUG:" -i "${libdir}/config/Makefile"
313
314 if use build; then
315 rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{bsddb,idlelib,lib-tk,sqlite3,test}
316 else
317 use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test}
318 use berkdb || rm -fr "${libdir}/"{bsddb,test/test_bsddb*}
319 use sqlite || rm -fr "${libdir}/"{sqlite3,test/test_sqlite*}
320 use tk || rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{idlelib,lib-tk}
321 fi
322
323 dodoc Misc/{ACKS,HISTORY,NEWS} || die "dodoc failed"
324
325 if use examples; then
326 insinto /usr/share/doc/${PF}/examples
327 doins -r "${S}/Tools" || die "doins failed"
328 fi
329
330 newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} || die "newconfd failed"
331 newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} || die "newinitd failed"
332 sed \
333 -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${SLOT/./_}_PORT:" \
334 -e "s:@PYDOC@:pydoc${SLOT}:" \
335 -i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" || die "sed failed"
336
337 # for python-exec
338 python_export python${SLOT} EPYTHON PYTHON PYTHON_SITEDIR
339
340 # if not using a cross-compiler, use the fresh binary
341 if ! tc-is-cross-compiler; then
342 local PYTHON=./python \
343 LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}.
344 export LD_LIBRARY_PATH
345 fi
346
347 echo "EPYTHON='${EPYTHON}'" > epython.py
348 python_domodule epython.py
349 }
350
351 pkg_preinst() {
352 if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.5" && ! has_version "${CATEGORY}/${PN}:2.6" && ! has_version "${CATEGORY}/${PN}:2.7"; then
353 python_updater_warning="1"
354 fi
355 }
356
357 eselect_python_update() {
358 [[ -z "${EROOT}" || (! -d "${EROOT}" && -d "${ROOT}") ]] && EROOT="${ROOT%/}${EPREFIX}/"
359
360 if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
361 eselect python update
362 fi
363
364 if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
365 eselect python update --python${PV%%.*}
366 fi
367 }
368
369 pkg_postinst() {
370 eselect_python_update
371
372 if [[ "${python_updater_warning}" == "1" ]]; then
373 ewarn "You have just upgraded from an older version of Python."
374 ewarn "You should switch active version of Python ${PV%%.*} and run"
375 ewarn "'python-updater [options]' to rebuild Python modules."
376 fi
377 }
378
379 pkg_postrm() {
380 eselect_python_update
381 }
382
383
384
385 1.1 dev-lang/python/python-2.6.8-r2.ebuild
386
387 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/python-2.6.8-r2.ebuild?rev=1.1&view=markup
388 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/python-2.6.8-r2.ebuild?rev=1.1&content-type=text/plain
389
390 Index: python-2.6.8-r2.ebuild
391 ===================================================================
392 # Copyright 1999-2013 Gentoo Foundation
393 # Distributed under the terms of the GNU General Public License v2
394 # $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.6.8-r2.ebuild,v 1.1 2013/06/30 16:08:08 floppym Exp $
395
396 EAPI="2"
397 WANT_AUTOMAKE="none"
398 WANT_LIBTOOL="none"
399
400 inherit autotools eutils flag-o-matic multilib pax-utils python-utils-r1 toolchain-funcs multiprocessing
401
402 MY_P="Python-${PV}"
403 PATCHSET_REVISION="0"
404
405 DESCRIPTION="An interpreted, interactive, object-oriented programming language"
406 HOMEPAGE="http://www.python.org/"
407 SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.bz2
408 mirror://gentoo/python-gentoo-patches-${PV}-${PATCHSET_REVISION}.tar.bz2"
409
410 LICENSE="PSF-2"
411 SLOT="2.6"
412 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
413 IUSE="-berkdb build doc elibc_uclibc examples gdbm hardened ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
414
415 # Do not add a dependency on dev-lang/python to this ebuild.
416 # If you need to apply a patch which requires python for bootstrapping, please
417 # run the bootstrap code on your dev box and include the results in the
418 # patchset. See bug 447752.
419
420 RDEPEND="app-arch/bzip2
421 >=sys-libs/zlib-1.1.3
422 virtual/libffi
423 virtual/libintl
424 !build? (
425 berkdb? ( || (
426 sys-libs/db:4.7
427 sys-libs/db:4.6
428 sys-libs/db:4.5
429 sys-libs/db:4.4
430 sys-libs/db:4.3
431 sys-libs/db:4.2
432 ) )
433 gdbm? ( sys-libs/gdbm[berkdb] )
434 ncurses? (
435 >=sys-libs/ncurses-5.2
436 readline? ( >=sys-libs/readline-4.1 )
437 )
438 sqlite? ( >=dev-db/sqlite-3.3.3:3 )
439 ssl? ( dev-libs/openssl )
440 tk? (
441 >=dev-lang/tk-8.0
442 dev-tcltk/blt
443 )
444 xml? ( >=dev-libs/expat-2.1 )
445 )
446 !!<sys-apps/portage-2.1.9"
447 DEPEND="${RDEPEND}
448 virtual/pkgconfig
449 >=sys-devel/autoconf-2.61
450 !sys-devel/gcc[libffi]"
451 RDEPEND+=" !build? ( app-misc/mime-types )
452 doc? ( dev-python/python-docs:${SLOT} )"
453 PDEPEND="app-admin/eselect-python
454 app-admin/python-updater"
455
456 S="${WORKDIR}/${MY_P}"
457
458 pkg_setup() {
459 if use berkdb; then
460 ewarn "'bsddb' module is out-of-date and no longer maintained inside"
461 ewarn "dev-lang/python. 'bsddb' and 'dbhash' modules have been additionally"
462 ewarn "removed in Python 3. A maintained alternative of 'bsddb3' module"
463 ewarn "is provided by dev-python/bsddb3."
464 else
465 if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then
466 ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"
467 ewarn "to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
468 ewarn "You might need to migrate your databases."
469 fi
470 fi
471 }
472
473 src_prepare() {
474 # Ensure that internal copies of expat, libffi and zlib are not used.
475 rm -fr Modules/expat
476 rm -fr Modules/_ctypes/libffi*
477 rm -fr Modules/zlib
478
479 local excluded_patches
480 if ! tc-is-cross-compiler; then
481 excluded_patches="*_all_crosscompile.patch"
482 fi
483
484 EPATCH_EXCLUDE="${excluded_patches}" EPATCH_SUFFIX="patch" \
485 epatch "${WORKDIR}/${PV}-${PATCHSET_REVISION}"
486
487 epatch "${FILESDIR}/python-2.5-tcl86.patch"
488
489 sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
490 Lib/distutils/command/install.py \
491 Lib/distutils/sysconfig.py \
492 Lib/site.py \
493 Makefile.pre.in \
494 Modules/Setup.dist \
495 Modules/getpath.c \
496 setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
497
498 epatch_user
499
500 eautoconf
501 eautoheader
502 }
503
504 src_configure() {
505 if use build; then
506 # Disable extraneous modules with extra dependencies.
507 export PYTHON_DISABLE_MODULES="dbm _bsddb gdbm _curses _curses_panel readline _sqlite3 _tkinter _elementtree pyexpat"
508 export PYTHON_DISABLE_SSL="1"
509 else
510 # dbm module can be linked against berkdb or gdbm.
511 # Defaults to gdbm when both are enabled, #204343.
512 local disable
513 use berkdb || use gdbm || disable+=" dbm"
514 use berkdb || disable+=" _bsddb"
515 use gdbm || disable+=" gdbm"
516 use ncurses || disable+=" _curses _curses_panel"
517 use readline || disable+=" readline"
518 use sqlite || disable+=" _sqlite3"
519 use ssl || export PYTHON_DISABLE_SSL="1"
520 use tk || disable+=" _tkinter"
521 use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
522 export PYTHON_DISABLE_MODULES="${disable}"
523
524 if ! use xml; then
525 ewarn "You have configured Python without XML support."
526 ewarn "This is NOT a recommended configuration as you"
527 ewarn "may face problems parsing any XML documents."
528 fi
529 fi
530
531 if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
532 einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
533 fi
534
535 if [[ "$(gcc-major-version)" -ge 4 ]]; then
536 append-flags -fwrapv
537 fi
538
539 filter-flags -malign-double
540
541 [[ "${ARCH}" == "alpha" ]] && append-flags -fPIC
542
543 # https://bugs.gentoo.org/show_bug.cgi?id=50309
544 if is-flagq -O3; then
545 is-flagq -fstack-protector-all && replace-flags -O3 -O2
546 use hardened && replace-flags -O3 -O2
547 fi
548
549 # Run the configure scripts in parallel.
550 multijob_init
551
552 mkdir -p "${WORKDIR}"/{${CBUILD},${CHOST}}
553
554 if tc-is-cross-compiler; then
555 (
556 multijob_child_init
557 cd "${WORKDIR}"/${CBUILD} >/dev/null
558 OPT="-O1" CFLAGS="" CPPFLAGS="" LDFLAGS="" CC="" \
559 "${S}"/configure \
560 --{build,host}=${CBUILD} \
561 || die "cross-configure failed"
562 ) &
563 multijob_post_fork
564 fi
565
566 # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.
567 tc-export CXX
568 # The configure script fails to use pkg-config correctly.
569 # http://bugs.python.org/issue15506
570 export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG)
571
572 # Set LDFLAGS so we link modules with -lpython2.6 correctly.
573 # Needed on FreeBSD unless Python 2.6 is already installed.
574 # Please query BSD team before removing this!
575 append-ldflags "-L."
576
577 cd "${WORKDIR}"/${CHOST}
578 ECONF_SOURCE=${S} OPT="" \
579 econf \
580 --with-fpectl \
581 --enable-shared \
582 $(use_enable ipv6) \
583 $(use_with threads) \
584 $(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2") \
585 --infodir='${prefix}/share/info' \
586 --mandir='${prefix}/share/man' \
587 --with-libc="" \
588 --with-system-ffi
589
590 if tc-is-cross-compiler; then
591 # Modify the Makefile.pre so we don't regen for the host/ one.
592 # We need to link the host python programs into $PWD and run
593 # them from here because the distutils sysconfig module will
594 # parse Makefile/etc... from argv[0], and we need it to pick
595 # up the target settings, not the host ones.
596 sed -i \
597 -e '1iHOSTPYTHONPATH = ./hostpythonpath:' \
598 -e '/^HOSTPYTHON/s:=.*:= ./hostpython:' \
599 -e '/^HOSTPGEN/s:=.*:= ./Parser/hostpgen:' \
600 Makefile{.pre,} || die "sed failed"
601 fi
602
603 multijob_finish
604 }
605
606 src_compile() {
607 if tc-is-cross-compiler; then
608 cd "${WORKDIR}"/${CBUILD}
609 # Disable as many modules as possible -- but we need a few to install.
610 PYTHON_DISABLE_MODULES=$(
611 sed -n "/Extension('/{s:^.*Extension('::;s:'.*::;p}" "${S}"/setup.py | \
612 egrep -v '(unicodedata|time|cStringIO|_struct|binascii)'
613 ) \
614 PTHON_DISABLE_SSL="1" \
615 SYSROOT= \
616 emake || die "cross-make failed"
617 # See comment in src_configure about these.
618 ln python ../${CHOST}/hostpython || die
619 ln Parser/pgen ../${CHOST}/Parser/hostpgen || die
620 ln -s ../${CBUILD}/build/lib.*/ ../${CHOST}/hostpythonpath || die
621 fi
622
623 cd "${WORKDIR}"/${CHOST}
624 default
625
626 # Work around bug 329499. See also bug 413751.
627 pax-mark m python
628 }
629
630 src_test() {
631 # Tests will not work when cross compiling.
632 if tc-is-cross-compiler; then
633 elog "Disabling tests due to crosscompiling."
634 return
635 fi
636
637 cd "${WORKDIR}"/${CHOST}
638
639 # Skip failing tests.
640 local skipped_tests="distutils tcl"
641
642 for test in ${skipped_tests}; do
643 mv "${S}"/Lib/test/test_${test}.py "${T}"
644 done
645
646 # Rerun failed tests in verbose mode (regrtest -w).
647 PYTHONDONTWRITEBYTECODE="" emake test EXTRATESTOPTS="-w" < /dev/tty
648 local result="$?"
649
650 for test in ${skipped_tests}; do
651 mv "${T}/test_${test}.py" "${S}"/Lib/test
652 done
653
654 elog "The following tests have been skipped:"
655 for test in ${skipped_tests}; do
656 elog "test_${test}.py"
657 done
658
659 elog "If you would like to run them, you may:"
660 elog "cd '${EPREFIX}/usr/$(get_libdir)/python${SLOT}/test'"
661 elog "and run the tests separately."
662
663 if [[ "${result}" -ne 0 ]]; then
664 die "emake test failed"
665 fi
666 }
667
668 src_install() {
669 [[ -z "${ED}" ]] && ED="${D%/}${EPREFIX}/"
670
671 local libdir=${ED}/usr/$(get_libdir)/python${SLOT}
672
673 cd "${WORKDIR}"/${CHOST}
674 emake DESTDIR="${D}" altinstall maninstall || die "emake altinstall maninstall failed"
675
676 # Backwards compat with Gentoo divergence.
677 dosym python${SLOT}-config /usr/bin/python-config-${SLOT} || die
678
679 # Fix collisions between different slots of Python.
680 mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}"
681 mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}"
682 mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}"
683 mv "${ED}usr/share/man/man1/python.1" "${ED}usr/share/man/man1/python${SLOT}.1"
684 rm -f "${ED}usr/bin/smtpd.py"
685
686 if use build; then
687 rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{bsddb,dbhash.py,idlelib,lib-tk,sqlite3,test}
688 else
689 use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test}
690 use berkdb || rm -fr "${libdir}/"{bsddb,dbhash.py,test/test_bsddb*}
691 use sqlite || rm -fr "${libdir}/"{sqlite3,test/test_sqlite*}
692 use tk || rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{idlelib,lib-tk}
693 fi
694
695 use threads || rm -fr "${libdir}/multiprocessing"
696 use wininst || rm -f "${libdir}/distutils/command/"wininst-*.exe
697
698 dodoc "${S}"/Misc/{ACKS,HISTORY,NEWS} || die "dodoc failed"
699
700 if use examples; then
701 insinto /usr/share/doc/${PF}/examples
702 doins -r "${S}"/Tools || die "doins failed"
703 fi
704
705 newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} || die "newconfd failed"
706 newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} || die "newinitd failed"
707 sed \
708 -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${SLOT/./_}_PORT:" \
709 -e "s:@PYDOC@:pydoc${SLOT}:" \
710 -i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" || die "sed failed"
711
712 # for python-exec
713 python_export python${SLOT} EPYTHON PYTHON PYTHON_SITEDIR
714
715 # if not using a cross-compiler, use the fresh binary
716 if ! tc-is-cross-compiler; then
717 local PYTHON=./python \
718 LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}.
719 export LD_LIBRARY_PATH
720 fi
721
722 echo "EPYTHON='${EPYTHON}'" > epython.py
723 python_domodule epython.py
724 }
725
726 pkg_preinst() {
727 if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.6" && ! has_version "${CATEGORY}/${PN}:2.7"; then
728 python_updater_warning="1"
729 fi
730 }
731
732 eselect_python_update() {
733 [[ -z "${EROOT}" || (! -d "${EROOT}" && -d "${ROOT}") ]] && EROOT="${ROOT%/}${EPREFIX}/"
734
735 if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
736 eselect python update
737 fi
738
739 if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
740 eselect python update --python${PV%%.*}
741 fi
742 }
743
744 pkg_postinst() {
745 eselect_python_update
746
747 if [[ "${python_updater_warning}" == "1" ]]; then
748 ewarn "You have just upgraded from an older version of Python."
749 ewarn "You should switch active version of Python ${PV%%.*} and run"
750 ewarn "'python-updater [options]' to rebuild Python modules."
751 fi
752 }
753
754 pkg_postrm() {
755 eselect_python_update
756 }