Gentoo Archives: gentoo-commits

From: "Arfrever Frehtes Taifersar Arahesis (arfrever)" <arfrever@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-lang/python: python-2.7.1.ebuild ChangeLog python-3.1.3.ebuild
Date: Sun, 28 Nov 2010 19:05:56
Message-Id: 20101128190549.5808920051@flycatcher.gentoo.org
1 arfrever 10/11/28 19:05:49
2
3 Modified: ChangeLog
4 Added: python-2.7.1.ebuild python-3.1.3.ebuild
5 Log:
6 Version bumps.
7 2.7: Enable loadable sqlite extensions (bug #335505).
8
9 (Portage version: 2.2.0_alpha6/cvs/Linux x86_64)
10
11 Revision Changes Path
12 1.502 dev-lang/python/ChangeLog
13
14 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/ChangeLog?rev=1.502&view=markup
15 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/ChangeLog?rev=1.502&content-type=text/plain
16 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/ChangeLog?r1=1.501&r2=1.502
17
18 Index: ChangeLog
19 ===================================================================
20 RCS file: /var/cvsroot/gentoo-x86/dev-lang/python/ChangeLog,v
21 retrieving revision 1.501
22 retrieving revision 1.502
23 diff -u -r1.501 -r1.502
24 --- ChangeLog 27 Nov 2010 12:50:14 -0000 1.501
25 +++ ChangeLog 28 Nov 2010 19:05:49 -0000 1.502
26 @@ -1,6 +1,13 @@
27 # ChangeLog for dev-lang/python
28 # Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
29 -# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/ChangeLog,v 1.501 2010/11/27 12:50:14 sping Exp $
30 +# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/ChangeLog,v 1.502 2010/11/28 19:05:49 arfrever Exp $
31 +
32 +*python-3.1.3 (28 Nov 2010)
33 +*python-2.7.1 (28 Nov 2010)
34 +
35 + 28 Nov 2010; Arfrever Frehtes Taifersar Arahesis <arfrever@g.o>
36 + +python-2.7.1.ebuild, +python-3.1.3.ebuild:
37 + Version bumps. 2.7: Enable loadable sqlite extensions (bug #335505).
38
39 27 Nov 2010; Sebastian Pipping <sping@g.o> python-2.4.6.ebuild,
40 python-2.5.4-r4.ebuild, python-2.6.5-r3.ebuild, python-2.6.6-r1.ebuild,
41
42
43
44 1.1 dev-lang/python/python-2.7.1.ebuild
45
46 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/python-2.7.1.ebuild?rev=1.1&view=markup
47 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/python-2.7.1.ebuild?rev=1.1&content-type=text/plain
48
49 Index: python-2.7.1.ebuild
50 ===================================================================
51 # Copyright 1999-2010 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.7.1.ebuild,v 1.1 2010/11/28 19:05:49 arfrever Exp $
54
55 EAPI="2"
56 WANT_AUTOMAKE="none"
57
58 inherit autotools eutils flag-o-matic multilib pax-utils python toolchain-funcs
59
60 if [[ "${PV}" == *_pre* ]]; then
61 inherit subversion
62
63 ESVN_PROJECT="python"
64 ESVN_REPO_URI="http://svn.python.org/projects/python/branches/release27-maint"
65 ESVN_REVISION=""
66 else
67 MY_PV="${PV%_p*}"
68 MY_P="Python-${MY_PV}"
69 fi
70
71 PATCHSET_REVISION="0"
72
73 DESCRIPTION="Python is an interpreted, interactive, object-oriented programming language."
74 HOMEPAGE="http://www.python.org/"
75 if [[ "${PV}" == *_pre* ]]; then
76 SRC_URI=""
77 else
78 SRC_URI="http://www.python.org/ftp/python/${MY_PV}/${MY_P}.tar.bz2
79 mirror://gentoo/python-gentoo-patches-${MY_PV}$([[ "${PATCHSET_REVISION}" != "0" ]] && echo "-r${PATCHSET_REVISION}").tar.bz2"
80 fi
81
82 LICENSE="PSF-2.2"
83 SLOT="2.7"
84 PYTHON_ABI="${SLOT}"
85 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
86 IUSE="-berkdb build doc elibc_uclibc examples gdbm ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
87
88 RDEPEND=">=app-admin/eselect-python-20091230
89 >=sys-libs/zlib-1.1.3
90 virtual/libffi
91 virtual/libintl
92 !build? (
93 berkdb? ( || (
94 sys-libs/db:4.8
95 sys-libs/db:4.7
96 sys-libs/db:4.6
97 sys-libs/db:4.5
98 sys-libs/db:4.4
99 sys-libs/db:4.3
100 sys-libs/db:4.2
101 ) )
102 gdbm? ( sys-libs/gdbm )
103 ncurses? (
104 >=sys-libs/ncurses-5.2
105 readline? ( >=sys-libs/readline-4.1 )
106 )
107 sqlite? ( >=dev-db/sqlite-3.3.8:3[extensions] )
108 ssl? ( dev-libs/openssl )
109 tk? ( >=dev-lang/tk-8.0 )
110 xml? ( >=dev-libs/expat-2 )
111 )
112 !!<sys-apps/portage-2.1.9"
113 DEPEND="${RDEPEND}
114 $([[ "${PV}" == *_pre* ]] && echo "=${CATEGORY}/${PN}-${PV%%.*}*")
115 dev-util/pkgconfig
116 $([[ "${PV}" =~ ^[[:digit:]]+\.[[:digit:]]+_pre ]] && echo "doc? ( dev-python/sphinx )")
117 !sys-devel/gcc[libffi]"
118 RDEPEND+=" !build? ( app-misc/mime-types )
119 $([[ "${PV}" =~ ^[[:digit:]]+\.[[:digit:]]+_pre ]] || echo "doc? ( dev-python/python-docs:${SLOT} )")"
120 PDEPEND="app-admin/python-updater"
121
122 PROVIDE="virtual/python"
123
124 if [[ "${PV}" != *_pre* ]]; then
125 S="${WORKDIR}/${MY_P}"
126 fi
127
128 pkg_setup() {
129 python_pkg_setup
130
131 if use berkdb; then
132 ewarn "\"bsddb\" module is out-of-date and no longer maintained inside dev-lang/python. It has"
133 ewarn "been additionally removed in Python 3. You should use external, still maintained \"bsddb3\""
134 ewarn "module provided by dev-python/bsddb3 which supports both Python 2 and Python 3."
135 fi
136 }
137
138 src_prepare() {
139 # Ensure that internal copies of expat, libffi and zlib are not used.
140 rm -fr Modules/expat
141 rm -fr Modules/_ctypes/libffi*
142 rm -fr Modules/zlib
143
144 if [[ "${PV}" =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+_pre ]]; then
145 if grep -Eq '#define PY_RELEASE_LEVEL[[:space:]]+PY_RELEASE_LEVEL_FINAL' Include/patchlevel.h; then
146 # Update micro version, release level and version string.
147 local micro_version="${PV%_pre*}"
148 micro_version="${micro_version##*.}"
149 local version_string="${PV%.*}.$((${micro_version} - 1))+"
150 sed \
151 -e "s/\(#define PY_MICRO_VERSION[[:space:]]\+\)[^[:space:]]\+/\1${micro_version}/" \
152 -e "s/\(#define PY_RELEASE_LEVEL[[:space:]]\+\)[^[:space:]]\+/\1PY_RELEASE_LEVEL_ALPHA/" \
153 -e "s/\(#define PY_VERSION[[:space:]]\+\"\)[^\"]\+\(\"\)/\1${version_string}\2/" \
154 -i Include/patchlevel.h || die "sed failed"
155 fi
156 fi
157
158 local excluded_patches
159 if ! tc-is-cross-compiler; then
160 excluded_patches="*_all_crosscompile.patch"
161 fi
162
163 local patchset_dir
164 if [[ "${PV}" == *_pre* ]]; then
165 patchset_dir="${FILESDIR}/${SLOT}-${PATCHSET_REVISION}"
166 else
167 patchset_dir="${WORKDIR}/${MY_PV}"
168 fi
169
170 EPATCH_EXCLUDE="${excluded_patches}" EPATCH_SUFFIX="patch" epatch "${patchset_dir}"
171
172 sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
173 Lib/distutils/command/install.py \
174 Lib/distutils/sysconfig.py \
175 Lib/site.py \
176 Lib/sysconfig.py \
177 Lib/test/test_site.py \
178 Makefile.pre.in \
179 Modules/Setup.dist \
180 Modules/getpath.c \
181 setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
182
183 if ! use wininst; then
184 # Remove Microsoft Windows executables.
185 rm Lib/distutils/command/wininst-*.exe
186 fi
187
188 # Fix OtherFileTests.testStdin() not to assume
189 # that stdin is a tty for bug #248081.
190 sed -e "s:'osf1V5':'osf1V5' and sys.stdin.isatty():" -i Lib/test/test_file.py || die "sed failed"
191
192 # Support versions of Autoconf other than 2.65.
193 sed -e "/version_required(2\.65)/d" -i configure.in || die "sed failed"
194
195 if [[ "${PV}" == *_pre* ]]; then
196 sed -e "s/\(-DSVNVERSION=\).*\( -o\)/\1\\\\\"${ESVN_REVISION}\\\\\"\2/" -i Makefile.pre.in || die "sed failed"
197 fi
198
199 eautoreconf
200 }
201
202 src_configure() {
203 if use build; then
204 # Disable extraneous modules with extra dependencies.
205 export PYTHON_DISABLE_MODULES="dbm _bsddb gdbm _curses _curses_panel readline _sqlite3 _tkinter _elementtree pyexpat"
206 export PYTHON_DISABLE_SSL="1"
207 else
208 # dbm module can be linked against berkdb or gdbm.
209 # Defaults to gdbm when both are enabled, #204343.
210 local disable
211 use berkdb || use gdbm || disable+=" dbm"
212 use berkdb || disable+=" _bsddb"
213 use gdbm || disable+=" gdbm"
214 use ncurses || disable+=" _curses _curses_panel"
215 use readline || disable+=" readline"
216 use sqlite || disable+=" _sqlite3"
217 use ssl || export PYTHON_DISABLE_SSL="1"
218 use tk || disable+=" _tkinter"
219 use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
220 export PYTHON_DISABLE_MODULES="${disable}"
221
222 if ! use xml; then
223 ewarn "You have configured Python without XML support."
224 ewarn "This is NOT a recommended configuration as you"
225 ewarn "may face problems parsing any XML documents."
226 fi
227 fi
228
229 if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
230 einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
231 fi
232
233 if [[ "$(gcc-major-version)" -ge 4 ]]; then
234 append-flags -fwrapv
235 fi
236
237 filter-flags -malign-double
238
239 [[ "${ARCH}" == "alpha" ]] && append-flags -fPIC
240
241 # https://bugs.gentoo.org/show_bug.cgi?id=50309
242 if is-flagq -O3; then
243 is-flagq -fstack-protector-all && replace-flags -O3 -O2
244 use hardened && replace-flags -O3 -O2
245 fi
246
247 if tc-is-cross-compiler; then
248 OPT="-O1" CFLAGS="" LDFLAGS="" CC="" \
249 ./configure --{build,host}=${CBUILD} || die "cross-configure failed"
250 emake python Parser/pgen || die "cross-make failed"
251 mv python hostpython
252 mv Parser/pgen Parser/hostpgen
253 make distclean
254 sed -i \
255 -e "/^HOSTPYTHON/s:=.*:=./hostpython:" \
256 -e "/^HOSTPGEN/s:=.*:=./Parser/hostpgen:" \
257 Makefile.pre.in || die "sed failed"
258 fi
259
260 # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.
261 tc-export CXX
262
263 # Set LDFLAGS so we link modules with -lpython2.7 correctly.
264 # Needed on FreeBSD unless Python 2.7 is already installed.
265 # Please query BSD team before removing this!
266 append-ldflags "-L."
267
268 local dbmliborder
269 if use gdbm; then
270 dbmliborder+="${dbmliborder:+:}gdbm"
271 fi
272 if use berkdb; then
273 dbmliborder+="${dbmliborder:+:}bdb"
274 fi
275
276 OPT="" econf \
277 --with-fpectl \
278 --enable-shared \
279 $(use_enable ipv6) \
280 $(use_with threads) \
281 $(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2") \
282 --infodir='${prefix}/share/info' \
283 --mandir='${prefix}/share/man' \
284 --with-dbmliborder="${dbmliborder}" \
285 --with-libc="" \
286 --enable-loadable-sqlite-extensions \
287 --with-system-expat \
288 --with-system-ffi
289 }
290
291 src_compile() {
292 emake EPYTHON="python${PV%%.*}" || die "emake failed"
293 }
294
295 src_test() {
296 # Tests will not work when cross compiling.
297 if tc-is-cross-compiler; then
298 elog "Disabling tests due to crosscompiling."
299 return
300 fi
301
302 # Byte compiling should be enabled here.
303 # Otherwise test_import fails.
304 python_enable_pyc
305
306 # Skip failing tests.
307 local skip_tests="distutils gdb minidom pyexpat sax"
308
309 # test_ctypes fails with PAX kernel (bug #234498).
310 host-is-pax && skip_tests+=" ctypes"
311
312 for test in ${skip_tests}; do
313 mv "${S}/Lib/test/test_${test}.py" "${T}"
314 done
315
316 # Rerun failed tests in verbose mode (regrtest -w).
317 EXTRATESTOPTS="-w" emake test
318 local result="$?"
319
320 for test in ${skip_tests}; do
321 mv "${T}/test_${test}.py" "${S}/Lib/test/test_${test}.py"
322 done
323
324 elog "The following tests have been skipped:"
325 for test in ${skip_tests}; do
326 elog "test_${test}.py"
327 done
328
329 elog "If you would like to run them, you may:"
330 elog "cd '${EPREFIX}$(python_get_libdir)/test'"
331 elog "and run the tests separately."
332
333 python_disable_pyc
334
335 if [[ "${result}" -ne 0 ]]; then
336 die "emake test failed"
337 fi
338 }
339
340 src_install() {
341 [[ -z "${ED}" ]] && ED="${D%/}${EPREFIX}/"
342
343 emake DESTDIR="${D}" altinstall maninstall || die "emake altinstall maninstall failed"
344 python_clean_installation_image -q
345
346 sed -e "s/\(LDFLAGS=\).*/\1/" -i "${ED}$(python_get_libdir)/config/Makefile" || die "sed failed"
347
348 mv "${ED}usr/bin/python${SLOT}-config" "${ED}usr/bin/python-config-${SLOT}"
349
350 # Fix collisions between different slots of Python.
351 mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}"
352 mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}"
353 mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}"
354 rm -f "${ED}usr/bin/smtpd.py"
355
356 if use build; then
357 rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{bsddb,idlelib,lib-tk,sqlite3,test}
358 else
359 use elibc_uclibc && rm -fr "${ED}$(python_get_libdir)/"{bsddb/test,test}
360 use berkdb || rm -fr "${ED}$(python_get_libdir)/"{bsddb,test/test_bsddb*}
361 use sqlite || rm -fr "${ED}$(python_get_libdir)/"{sqlite3,test/test_sqlite*}
362 use tk || rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{idlelib,lib-tk}
363 fi
364
365 use threads || rm -fr "${ED}$(python_get_libdir)/multiprocessing"
366
367 prep_ml_includes $(python_get_includedir)
368
369 dodoc Misc/{ACKS,HISTORY,NEWS} || die "dodoc failed"
370
371 if use examples; then
372 insinto /usr/share/doc/${PF}/examples
373 doins -r "${S}/Tools" || die "doins failed"
374 fi
375
376 newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} || die "newinitd failed"
377 newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} || die "newconfd failed"
378
379 # Do not install empty directories.
380 rmdir "${ED}$(python_get_libdir)/lib-old"
381 rmdir "${ED}$(python_get_libdir)/test/data"
382 }
383
384 pkg_preinst() {
385 if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.7"; then
386 python_updater_warning="1"
387 fi
388 }
389
390 eselect_python_update() {
391 if [[ -z "$(eselect python show --python${PV%%.*})" ]]; then
392 eselect python update --python${PV%%.*}
393 fi
394 }
395
396 pkg_postinst() {
397 eselect_python_update
398
399 python_mod_optimize -f -x "/(site-packages|test|tests)/" $(python_get_libdir)
400
401 if [[ "${python_updater_warning}" == "1" ]]; then
402 ewarn
403 ewarn "\e[1;31m************************************************************************\e[0m"
404 ewarn
405 ewarn "You have just upgraded from an older version of Python."
406 ewarn "You should run 'python-updater \${options}' to rebuild Python modules."
407 ewarn
408 ewarn "\e[1;31m************************************************************************\e[0m"
409 ewarn
410 ebeep 12
411 fi
412 }
413
414 pkg_postrm() {
415 eselect_python_update
416
417 python_mod_cleanup $(python_get_libdir)
418 }
419
420
421
422 1.1 dev-lang/python/python-3.1.3.ebuild
423
424 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/python-3.1.3.ebuild?rev=1.1&view=markup
425 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/python/python-3.1.3.ebuild?rev=1.1&content-type=text/plain
426
427 Index: python-3.1.3.ebuild
428 ===================================================================
429 # Copyright 1999-2010 Gentoo Foundation
430 # Distributed under the terms of the GNU General Public License v2
431 # $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-3.1.3.ebuild,v 1.1 2010/11/28 19:05:49 arfrever Exp $
432
433 EAPI="3"
434 WANT_AUTOMAKE="none"
435
436 inherit autotools eutils flag-o-matic multilib pax-utils python toolchain-funcs
437
438 if [[ "${PV}" == *_pre* ]]; then
439 inherit subversion
440
441 ESVN_PROJECT="python"
442 ESVN_REPO_URI="http://svn.python.org/projects/python/branches/release31-maint"
443 ESVN_REVISION=""
444 else
445 MY_PV="${PV%_p*}"
446 MY_P="Python-${MY_PV}"
447 fi
448
449 PATCHSET_REVISION="0"
450
451 DESCRIPTION="Python is an interpreted, interactive, object-oriented programming language."
452 HOMEPAGE="http://www.python.org/"
453 if [[ "${PV}" == *_pre* ]]; then
454 SRC_URI=""
455 else
456 SRC_URI="http://www.python.org/ftp/python/${MY_PV}/${MY_P}.tar.bz2
457 mirror://gentoo/python-gentoo-patches-${MY_PV}$([[ "${PATCHSET_REVISION}" != "0" ]] && echo "-r${PATCHSET_REVISION}").tar.bz2"
458 fi
459
460 LICENSE="PSF-2.2"
461 SLOT="3.1"
462 PYTHON_ABI="${SLOT}"
463 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
464 IUSE="build doc elibc_uclibc examples gdbm ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
465
466 RDEPEND=">=app-admin/eselect-python-20091230
467 >=sys-libs/zlib-1.1.3
468 virtual/libffi
469 virtual/libintl
470 !build? (
471 gdbm? ( sys-libs/gdbm )
472 ncurses? (
473 >=sys-libs/ncurses-5.2
474 readline? ( >=sys-libs/readline-4.1 )
475 )
476 sqlite? ( >=dev-db/sqlite-3.3.3:3 )
477 ssl? ( dev-libs/openssl )
478 tk? ( >=dev-lang/tk-8.0 )
479 xml? ( >=dev-libs/expat-2 )
480 )"
481 DEPEND="${RDEPEND}
482 $([[ "${PV}" == *_pre* ]] && echo "=${CATEGORY}/${PN}-${PV%%.*}*")
483 dev-util/pkgconfig
484 $([[ "${PV}" =~ ^[[:digit:]]+\.[[:digit:]]+_pre ]] && echo "doc? ( dev-python/sphinx )")
485 !sys-devel/gcc[libffi]"
486 RDEPEND+=" !build? ( app-misc/mime-types )
487 $([[ "${PV}" =~ ^[[:digit:]]+\.[[:digit:]]+_pre ]] || echo "doc? ( dev-python/python-docs:${SLOT} )")"
488 PDEPEND=">=app-admin/python-updater-0.8
489 || (
490 ${CATEGORY}/${PN}:2.7[gdbm?,ipv6?,ncurses?,readline?,sqlite?,ssl?,threads?,tk?,xml?]
491 ${CATEGORY}/${PN}:2.6[gdbm?,ipv6?,ncurses?,readline?,sqlite?,ssl?,threads?,tk?,xml?]
492 )"
493
494 PROVIDE="virtual/python"
495
496 if [[ "${PV}" != *_pre* ]]; then
497 S="${WORKDIR}/${MY_P}"
498 fi
499
500 pkg_setup() {
501 python_pkg_setup
502 }
503
504 src_prepare() {
505 # Ensure that internal copies of expat, libffi and zlib are not used.
506 rm -fr Modules/expat
507 rm -fr Modules/_ctypes/libffi*
508 rm -fr Modules/zlib
509
510 if [[ "${PV}" =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+_pre ]]; then
511 if grep -Eq '#define PY_RELEASE_LEVEL[[:space:]]+PY_RELEASE_LEVEL_FINAL' Include/patchlevel.h; then
512 # Update micro version, release level and version string.
513 local micro_version="${PV%_pre*}"
514 micro_version="${micro_version##*.}"
515 local version_string="${PV%.*}.$((${micro_version} - 1))+"
516 sed \
517 -e "s/\(#define PY_MICRO_VERSION[[:space:]]\+\)[^[:space:]]\+/\1${micro_version}/" \
518 -e "s/\(#define PY_RELEASE_LEVEL[[:space:]]\+\)[^[:space:]]\+/\1PY_RELEASE_LEVEL_ALPHA/" \
519 -e "s/\(#define PY_VERSION[[:space:]]\+\"\)[^\"]\+\(\"\)/\1${version_string}\2/" \
520 -i Include/patchlevel.h || die "sed failed"
521 fi
522 fi
523
524 local excluded_patches
525 if ! tc-is-cross-compiler; then
526 excluded_patches="*_all_crosscompile.patch"
527 fi
528
529 local patchset_dir
530 if [[ "${PV}" == *_pre* ]]; then
531 patchset_dir="${FILESDIR}/${SLOT}-${PATCHSET_REVISION}"
532 else
533 patchset_dir="${WORKDIR}/${MY_PV}"
534 fi
535
536 EPATCH_EXCLUDE="${excluded_patches}" EPATCH_SUFFIX="patch" epatch "${patchset_dir}"
537
538 sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
539 Lib/distutils/command/install.py \
540 Lib/distutils/sysconfig.py \
541 Lib/site.py \
542 Makefile.pre.in \
543 Modules/Setup.dist \
544 Modules/getpath.c \
545 setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
546
547 if ! use wininst; then
548 # Remove Microsoft Windows executables.
549 rm Lib/distutils/command/wininst-*.exe
550 fi
551
552 # Fix OtherFileTests.testStdin() not to assume
553 # that stdin is a tty for bug #248081.
554 sed -e "s:'osf1V5':'osf1V5' and sys.stdin.isatty():" -i Lib/test/test_file.py || die "sed failed"
555
556 if [[ "${PV}" == *_pre* ]]; then
557 sed -e "s/\(-DSVNVERSION=\).*\( -o\)/\1\\\\\"${ESVN_REVISION}\\\\\"\2/" -i Makefile.pre.in || die "sed failed"
558 fi
559
560 eautoreconf
561 }
562
563 src_configure() {
564 if use build; then
565 # Disable extraneous modules with extra dependencies.
566 export PYTHON_DISABLE_MODULES="gdbm _curses _curses_panel readline _sqlite3 _tkinter _elementtree pyexpat"
567 export PYTHON_DISABLE_SSL="1"
568 else
569 local disable
570 use gdbm || disable+=" gdbm"
571 use ncurses || disable+=" _curses _curses_panel"
572 use readline || disable+=" readline"
573 use sqlite || disable+=" _sqlite3"
574 use ssl || export PYTHON_DISABLE_SSL="1"
575 use tk || disable+=" _tkinter"
576 use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
577 export PYTHON_DISABLE_MODULES="${disable}"
578
579 if ! use xml; then
580 ewarn "You have configured Python without XML support."
581 ewarn "This is NOT a recommended configuration as you"
582 ewarn "may face problems parsing any XML documents."
583 fi
584 fi
585
586 if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
587 einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
588 fi
589
590 if [[ "$(gcc-major-version)" -ge 4 ]]; then
591 append-flags -fwrapv
592 fi
593
594 filter-flags -malign-double
595
596 [[ "${ARCH}" == "alpha" ]] && append-flags -fPIC
597
598 # https://bugs.gentoo.org/show_bug.cgi?id=50309
599 if is-flagq -O3; then
600 is-flagq -fstack-protector-all && replace-flags -O3 -O2
601 use hardened && replace-flags -O3 -O2
602 fi
603
604 if tc-is-cross-compiler; then
605 OPT="-O1" CFLAGS="" LDFLAGS="" CC="" \
606 ./configure --{build,host}=${CBUILD} || die "cross-configure failed"
607 emake python Parser/pgen || die "cross-make failed"
608 mv python hostpython
609 mv Parser/pgen Parser/hostpgen
610 make distclean
611 sed -i \
612 -e "/^HOSTPYTHON/s:=.*:=./hostpython:" \
613 -e "/^HOSTPGEN/s:=.*:=./Parser/hostpgen:" \
614 Makefile.pre.in || die "sed failed"
615 fi
616
617 # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
618 tc-export CXX
619
620 # Set LDFLAGS so we link modules with -lpython3.1 correctly.
621 # Needed on FreeBSD unless Python 3.1 is already installed.
622 # Please query BSD team before removing this!
623 append-ldflags "-L."
624
625 local dbmliborder
626 if use gdbm; then
627 dbmliborder+="${dbmliborder:+:}gdbm"
628 fi
629
630 OPT="" econf \
631 --with-fpectl \
632 --enable-shared \
633 $(use_enable ipv6) \
634 $(use_with threads) \
635 $(use_with wide-unicode) \
636 --infodir='${prefix}/share/info' \
637 --mandir='${prefix}/share/man' \
638 --with-computed-gotos \
639 --with-dbmliborder="${dbmliborder}" \
640 --with-libc="" \
641 --with-system-ffi
642 }
643
644 src_compile() {
645 emake EPYTHON="python${PV%%.*}" || die "emake failed"
646 }
647
648 src_test() {
649 # Tests will not work when cross compiling.
650 if tc-is-cross-compiler; then
651 elog "Disabling tests due to crosscompiling."
652 return
653 fi
654
655 if ! use threads; then
656 ewarn "Disabling tests due to USE=\"-threads\""
657 return
658 fi
659
660 # Byte compiling should be enabled here.
661 # Otherwise test_import fails.
662 python_enable_pyc
663
664 # Skip failing tests.
665 local skip_tests="distutils"
666
667 # test_ctypes fails with PAX kernel (bug #234498).
668 host-is-pax && skip_tests+=" ctypes"
669
670 for test in ${skip_tests}; do
671 mv "${S}/Lib/test/test_${test}.py" "${T}"
672 done
673
674 # Rerun failed tests in verbose mode (regrtest -w).
675 EXTRATESTOPTS="-w" emake test
676 local result="$?"
677
678 for test in ${skip_tests}; do
679 mv "${T}/test_${test}.py" "${S}/Lib/test/test_${test}.py"
680 done
681
682 elog "The following tests have been skipped:"
683 for test in ${skip_tests}; do
684 elog "test_${test}.py"
685 done
686
687 elog "If you would like to run them, you may:"
688 elog "cd '${EPREFIX}$(python_get_libdir)/test'"
689 elog "and run the tests separately."
690
691 python_disable_pyc
692
693 if [[ "${result}" -ne 0 ]]; then
694 die "emake test failed"
695 fi
696 }
697
698 src_install() {
699 emake DESTDIR="${D}" altinstall || die "emake altinstall failed"
700 python_clean_installation_image -q
701
702 mv "${ED}usr/bin/python${SLOT}-config" "${ED}usr/bin/python-config-${SLOT}"
703
704 # Fix collisions between different slots of Python.
705 mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}"
706 mv "${ED}usr/bin/pydoc3" "${ED}usr/bin/pydoc${SLOT}"
707 mv "${ED}usr/bin/idle3" "${ED}usr/bin/idle${SLOT}"
708 rm -f "${ED}usr/bin/smtpd.py"
709
710 if use build; then
711 rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{idlelib,sqlite3,test,tkinter}
712 else
713 use elibc_uclibc && rm -fr "${ED}$(python_get_libdir)/test"
714 use sqlite || rm -fr "${ED}$(python_get_libdir)/"{sqlite3,test/test_sqlite*}
715 use tk || rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{idlelib,tkinter,test/test_tk*}
716 fi
717
718 use threads || rm -fr "${ED}$(python_get_libdir)/multiprocessing"
719
720 prep_ml_includes $(python_get_includedir)
721
722 dodoc Misc/{ACKS,HISTORY,NEWS} || die "dodoc failed"
723
724 if use examples; then
725 insinto /usr/share/doc/${PF}/examples
726 doins -r "${S}/Tools" || die "doins failed"
727 fi
728
729 newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} || die "newinitd failed"
730 newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} || die "newconfd failed"
731 }
732
733 pkg_preinst() {
734 if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version ">=${CATEGORY}/${PN}-${SLOT}_alpha"; then
735 python_updater_warning="1"
736 fi
737 }
738
739 eselect_python_update() {
740 if [[ -z "$(eselect python show --python${PV%%.*})" ]]; then
741 eselect python update --python${PV%%.*}
742 fi
743 }
744
745 pkg_postinst() {
746 eselect_python_update
747
748 python_mod_optimize -f -x "/(site-packages|test|tests)/" $(python_get_libdir)
749
750 if [[ "$(eselect python show)" == "python2."* ]]; then
751 ewarn
752 ewarn "WARNING!"
753 ewarn "Many Python modules have not been ported yet to Python 3.*."
754 ewarn "Python 3 has not been activated and Python wrapper is still configured to use Python 2."
755 ewarn "You can manually activate Python ${SLOT} using \`eselect python set python${SLOT}\`."
756 ewarn "It is recommended to currently have Python wrapper configured to use Python 2."
757 ewarn "Having Python wrapper configured to use Python 3 is unsupported."
758 ewarn
759 fi
760
761 if [[ "${python_updater_warning}" == "1" ]]; then
762 ewarn
763 ewarn "\e[1;31m************************************************************************\e[0m"
764 ewarn
765 ewarn "You have just upgraded from an older version of Python."
766 ewarn "You should run 'python-updater \${options}' to rebuild Python modules."
767 ewarn
768 ewarn "\e[1;31m************************************************************************\e[0m"
769 ewarn
770
771 local n
772 for ((n = 0; n < 12; n++)); do
773 echo -ne "\a"
774 sleep 1
775 done
776 fi
777 }
778
779 pkg_postrm() {
780 eselect_python_update
781
782 python_mod_cleanup $(python_get_libdir)
783 }