Gentoo Archives: gentoo-commits

From: Quentin Retornaz <gentoo@××××××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/libressl:master commit in: dev-lang/python/files/, dev-lang/python/
Date: Wed, 07 Jul 2021 18:22:02
Message-Id: 1625682064.f9ec3a342601df73768b159f6055a00d563e52aa.quentin@gentoo
1 commit: f9ec3a342601df73768b159f6055a00d563e52aa
2 Author: orbea <orbea <AT> riseup <DOT> net>
3 AuthorDate: Mon Jul 5 20:56:02 2021 +0000
4 Commit: Quentin Retornaz <gentoo <AT> retornaz <DOT> com>
5 CommitDate: Wed Jul 7 18:21:04 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/libressl.git/commit/?id=f9ec3a34
7
8 dev-lang/python: New package
9
10 Signed-off-by: orbea <orbea <AT> riseup.net>
11 Closes: https://github.com/gentoo/libressl/pull/346
12 Signed-off-by: Quentin Retornaz <gentoo <AT> retornaz.com>
13
14 dev-lang/python/files/pydoc.conf | 6 +
15 dev-lang/python/files/pydoc.init | 24 +++
16 dev-lang/python/python-3.9.5_p2.ebuild | 347 +++++++++++++++++++++++++++++++++
17 dev-lang/python/python-3.9.6.ebuild | 346 ++++++++++++++++++++++++++++++++
18 4 files changed, 723 insertions(+)
19
20 diff --git a/dev-lang/python/files/pydoc.conf b/dev-lang/python/files/pydoc.conf
21 new file mode 100644
22 index 0000000..3c6920c
23 --- /dev/null
24 +++ b/dev-lang/python/files/pydoc.conf
25 @@ -0,0 +1,6 @@
26 +# /etc/init.d/pydoc.conf
27 +
28 +# This file contains the configuration for pydoc's internal webserver.
29 +
30 +# Default port for Python's pydoc server.
31 +@PYDOC_PORT_VARIABLE@="7464"
32
33 diff --git a/dev-lang/python/files/pydoc.init b/dev-lang/python/files/pydoc.init
34 new file mode 100644
35 index 0000000..f8e0563
36 --- /dev/null
37 +++ b/dev-lang/python/files/pydoc.init
38 @@ -0,0 +1,24 @@
39 +#!/sbin/openrc-run
40 +# Copyright 1999-2016 Gentoo Foundation
41 +# Distributed under the terms of the GNU General Public Licence v2
42 +
43 +start() {
44 + local pydoc_port="${@PYDOC_PORT_VARIABLE@-${PYDOC_PORT}}"
45 +
46 + if [ -z "${pydoc_port}" ]; then
47 + eerror "Port not set"
48 + return 1
49 + fi
50 +
51 + ebegin "Starting pydoc server on port ${pydoc_port}"
52 + start-stop-daemon --start --background --make-pidfile \
53 + --pidfile /var/run/@PYDOC@.pid \
54 + --exec /usr/bin/@PYDOC@ -- -p "${pydoc_port}"
55 + eend $?
56 +}
57 +
58 +stop() {
59 + ebegin "Stopping pydoc server"
60 + start-stop-daemon --stop --quiet --pidfile /var/run/@PYDOC@.pid
61 + eend $?
62 +}
63
64 diff --git a/dev-lang/python/python-3.9.5_p2.ebuild b/dev-lang/python/python-3.9.5_p2.ebuild
65 new file mode 100644
66 index 0000000..d2f8b35
67 --- /dev/null
68 +++ b/dev-lang/python/python-3.9.5_p2.ebuild
69 @@ -0,0 +1,347 @@
70 +# Copyright 1999-2021 Gentoo Authors
71 +# Distributed under the terms of the GNU General Public License v2
72 +
73 +EAPI="7"
74 +WANT_LIBTOOL="none"
75 +
76 +inherit autotools check-reqs flag-o-matic multiprocessing pax-utils \
77 + python-utils-r1 toolchain-funcs verify-sig
78 +
79 +MY_PV=${PV/_rc/rc}
80 +MY_P="Python-${MY_PV%_p*}"
81 +PYVER=$(ver_cut 1-2)
82 +PATCHSET="python-gentoo-patches-${MY_PV}"
83 +
84 +DESCRIPTION="An interpreted, interactive, object-oriented programming language"
85 +HOMEPAGE="https://www.python.org/"
86 +SRC_URI="https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz
87 + https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz
88 + verify-sig? (
89 + https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz.asc
90 + )"
91 +S="${WORKDIR}/${MY_P}"
92 +
93 +LICENSE="PSF-2"
94 +SLOT="${PYVER}"
95 +KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
96 +IUSE="bluetooth build examples gdbm hardened ipv6 +ncurses +readline +sqlite +ssl test tk wininst +xml"
97 +RESTRICT="!test? ( test )"
98 +
99 +# Do not add a dependency on dev-lang/python to this ebuild.
100 +# If you need to apply a patch which requires python for bootstrapping, please
101 +# run the bootstrap code on your dev box and include the results in the
102 +# patchset. See bug 447752.
103 +
104 +RDEPEND="app-arch/bzip2:=
105 + app-arch/xz-utils:=
106 + dev-libs/libffi:=
107 + sys-apps/util-linux:=
108 + >=sys-libs/zlib-1.1.3:=
109 + virtual/libcrypt:=
110 + virtual/libintl
111 + gdbm? ( sys-libs/gdbm:=[berkdb] )
112 + ncurses? ( >=sys-libs/ncurses-5.2:= )
113 + readline? ( >=sys-libs/readline-4.1:= )
114 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
115 + ssl? ( dev-libs/openssl:= )
116 + tk? (
117 + >=dev-lang/tcl-8.0:=
118 + >=dev-lang/tk-8.0:=
119 + dev-tcltk/blt:=
120 + dev-tcltk/tix
121 + )
122 + xml? ( >=dev-libs/expat-2.1:= )"
123 +# bluetooth requires headers from bluez
124 +DEPEND="${RDEPEND}
125 + bluetooth? ( net-wireless/bluez )
126 + test? ( app-arch/xz-utils[extra-filters(+)] )"
127 +BDEPEND="
128 + virtual/pkgconfig
129 + sys-devel/autoconf-archive
130 + verify-sig? ( app-crypt/openpgp-keys-python )
131 + !sys-devel/gcc[libffi(-)]"
132 +RDEPEND+=" !build? ( app-misc/mime-types )"
133 +PDEPEND="app-eselect/eselect-python"
134 +
135 +VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/python.org.asc
136 +
137 +# large file tests involve a 2.5G file being copied (duplicated)
138 +CHECKREQS_DISK_BUILD=5500M
139 +
140 +pkg_pretend() {
141 + use test && check-reqs_pkg_pretend
142 +}
143 +
144 +pkg_setup() {
145 + use test && check-reqs_pkg_setup
146 +}
147 +
148 +src_unpack() {
149 + if use verify-sig; then
150 + verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc}
151 + fi
152 + default
153 +}
154 +
155 +src_prepare() {
156 + # Ensure that internal copies of expat, libffi and zlib are not used.
157 + rm -fr Modules/expat || die
158 + rm -fr Modules/_ctypes/libffi* || die
159 + rm -fr Modules/zlib || die
160 +
161 + rm -f "${WORKDIR}/${PATCHSET}"/0013-bpo-43998-Default-to-TLS-1.2-and-increase-cipher-sui.patch || die
162 +
163 + local PATCHES=(
164 + "${WORKDIR}/${PATCHSET}"
165 + )
166 +
167 + default
168 +
169 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
170 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
171 +
172 + # force correct number of jobs
173 + # https://bugs.gentoo.org/737660
174 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
175 + sed -i -e "s:-j0:-j${jobs}:" Makefile.pre.in || die
176 + sed -i -e "/self\.parallel/s:True:${jobs}:" setup.py || die
177 +
178 + eautoreconf
179 +}
180 +
181 +src_configure() {
182 + local disable
183 + # disable automagic bluetooth headers detection
184 + use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no
185 + use gdbm || disable+=" gdbm"
186 + use ncurses || disable+=" _curses _curses_panel"
187 + use readline || disable+=" readline"
188 + use sqlite || disable+=" _sqlite3"
189 + use ssl || export PYTHON_DISABLE_SSL="1"
190 + use tk || disable+=" _tkinter"
191 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
192 + export PYTHON_DISABLE_MODULES="${disable}"
193 +
194 + if ! use xml; then
195 + ewarn "You have configured Python without XML support."
196 + ewarn "This is NOT a recommended configuration as you"
197 + ewarn "may face problems parsing any XML documents."
198 + fi
199 +
200 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
201 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
202 + fi
203 +
204 + if [[ "$(gcc-major-version)" -ge 4 ]]; then
205 + append-flags -fwrapv
206 + fi
207 +
208 + filter-flags -malign-double
209 +
210 + # https://bugs.gentoo.org/show_bug.cgi?id=50309
211 + if is-flagq -O3; then
212 + is-flagq -fstack-protector-all && replace-flags -O3 -O2
213 + use hardened && replace-flags -O3 -O2
214 + fi
215 +
216 + # https://bugs.gentoo.org/700012
217 + if is-flagq -flto || is-flagq '-flto=*'; then
218 + append-cflags $(test-flags-CC -ffat-lto-objects)
219 + fi
220 +
221 + # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
222 + tc-export CXX
223 +
224 + # Fix implicit declarations on cross and prefix builds. Bug #674070.
225 + use ncurses && append-cppflags -I"${ESYSROOT}"/usr/include/ncursesw
226 +
227 + local dbmliborder
228 + if use gdbm; then
229 + dbmliborder+="${dbmliborder:+:}gdbm"
230 + fi
231 +
232 + local myeconfargs=(
233 + # glibc-2.30 removes it; since we can't cleanly force-rebuild
234 + # Python on glibc upgrade, remove it proactively to give
235 + # a chance for users rebuilding python before glibc
236 + ac_cv_header_stropts_h=no
237 +
238 + --enable-shared
239 + $(use_enable ipv6)
240 + --infodir='${prefix}/share/info'
241 + --mandir='${prefix}/share/man'
242 + --with-computed-gotos
243 + --with-dbmliborder="${dbmliborder}"
244 + --with-libc=
245 + --enable-loadable-sqlite-extensions
246 + --without-ensurepip
247 + --with-system-expat
248 + --with-system-ffi
249 + )
250 +
251 + OPT="" econf "${myeconfargs[@]}"
252 +
253 + if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
254 + eerror "configure has detected that the sem_open function is broken."
255 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
256 + die "Broken sem_open function (bug 496328)"
257 + fi
258 +}
259 +
260 +src_compile() {
261 + # Ensure sed works as expected
262 + # https://bugs.gentoo.org/594768
263 + local -x LC_ALL=C
264 +
265 + emake CPPFLAGS= CFLAGS= LDFLAGS=
266 +
267 + # Work around bug 329499. See also bug 413751 and 457194.
268 + if has_version dev-libs/libffi[pax-kernel]; then
269 + pax-mark E python
270 + else
271 + pax-mark m python
272 + fi
273 +}
274 +
275 +src_test() {
276 + # Tests will not work when cross compiling.
277 + if tc-is-cross-compiler; then
278 + elog "Disabling tests due to crosscompiling."
279 + return
280 + fi
281 +
282 + # Skip failing tests.
283 + local skipped_tests="gdb"
284 +
285 + for test in ${skipped_tests}; do
286 + mv "${S}"/Lib/test/test_${test}.py "${T}"
287 + done
288 +
289 + # bug 660358
290 + local -x COLUMNS=80
291 + local -x PYTHONDONTWRITEBYTECODE=
292 +
293 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
294 +
295 + emake test EXTRATESTOPTS="-u-network -j${jobs}" \
296 + CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
297 + local result=$?
298 +
299 + for test in ${skipped_tests}; do
300 + mv "${T}/test_${test}.py" "${S}"/Lib/test
301 + done
302 +
303 + elog "The following tests have been skipped:"
304 + for test in ${skipped_tests}; do
305 + elog "test_${test}.py"
306 + done
307 +
308 + elog "If you would like to run them, you may:"
309 + elog "cd '${EPREFIX}/usr/lib/python${PYVER}/test'"
310 + elog "and run the tests separately."
311 +
312 + if [[ ${result} -ne 0 ]]; then
313 + die "emake test failed"
314 + fi
315 +}
316 +
317 +src_install() {
318 + local libdir=${ED}/usr/lib/python${PYVER}
319 +
320 + emake DESTDIR="${D}" altinstall
321 +
322 + # Remove static library
323 + rm "${ED}"/usr/$(get_libdir)/libpython*.a || die
324 +
325 + sed \
326 + -e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" \
327 + -e "s/\(PY_LDFLAGS=\).*/\1/" \
328 + -i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed"
329 +
330 + # Fix collisions between different slots of Python.
331 + rm "${ED}/usr/$(get_libdir)/libpython3.so" || die
332 +
333 + # Cheap hack to get version with ABIFLAGS
334 + local abiver=$(cd "${ED}/usr/include"; echo python*)
335 + if [[ ${abiver} != python${PYVER} ]]; then
336 + # Replace python3.X with a symlink to python3.Xm
337 + rm "${ED}/usr/bin/python${PYVER}" || die
338 + dosym "${abiver}" "/usr/bin/python${PYVER}"
339 + # Create python3.X-config symlink
340 + dosym "${abiver}-config" "/usr/bin/python${PYVER}-config"
341 + # Create python-3.5m.pc symlink
342 + dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc"
343 + fi
344 +
345 + # python seems to get rebuilt in src_install (bug 569908)
346 + # Work around it for now.
347 + if has_version dev-libs/libffi[pax-kernel]; then
348 + pax-mark E "${ED}/usr/bin/${abiver}"
349 + else
350 + pax-mark m "${ED}/usr/bin/${abiver}"
351 + fi
352 +
353 + use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
354 + use tk || rm -r "${ED}/usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*} || die
355 +
356 + dodoc Misc/{ACKS,HISTORY,NEWS}
357 +
358 + if use examples; then
359 + docinto examples
360 + find Tools -name __pycache__ -exec rm -fr {} + || die
361 + dodoc -r Tools
362 + fi
363 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
364 + local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
365 + emake --no-print-directory -s -f - 2>/dev/null)
366 + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
367 +
368 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
369 + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
370 + sed \
371 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
372 + -e "s:@PYDOC@:pydoc${PYVER}:" \
373 + -i "${ED}/etc/conf.d/pydoc-${PYVER}" \
374 + "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed"
375 +
376 + local -x EPYTHON=python${PYVER}
377 + # if not using a cross-compiler, use the fresh binary
378 + if ! tc-is-cross-compiler; then
379 + local -x PYTHON=./python
380 + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD}
381 + else
382 + local -x PYTHON=${EPREFIX}/usr/bin/${EPYTHON}
383 + fi
384 +
385 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
386 + python_domodule epython.py
387 +
388 + # python-exec wrapping support
389 + local pymajor=${PYVER%.*}
390 + local scriptdir=${D}$(python_get_scriptdir)
391 + mkdir -p "${scriptdir}" || die
392 + # python and pythonX
393 + ln -s "../../../bin/${abiver}" \
394 + "${scriptdir}/python${pymajor}" || die
395 + ln -s "python${pymajor}" "${scriptdir}/python" || die
396 + # python-config and pythonX-config
397 + # note: we need to create a wrapper rather than symlinking it due
398 + # to some random dirname(argv[0]) magic performed by python-config
399 + cat > "${scriptdir}/python${pymajor}-config" <<-EOF || die
400 + #!/bin/sh
401 + exec "${abiver}-config" "\${@}"
402 + EOF
403 + chmod +x "${scriptdir}/python${pymajor}-config" || die
404 + ln -s "python${pymajor}-config" \
405 + "${scriptdir}/python-config" || die
406 + # 2to3, pydoc
407 + ln -s "../../../bin/2to3-${PYVER}" \
408 + "${scriptdir}/2to3" || die
409 + ln -s "../../../bin/pydoc${PYVER}" \
410 + "${scriptdir}/pydoc" || die
411 + # idle
412 + if use tk; then
413 + ln -s "../../../bin/idle${PYVER}" \
414 + "${scriptdir}/idle" || die
415 + fi
416 +}
417
418 diff --git a/dev-lang/python/python-3.9.6.ebuild b/dev-lang/python/python-3.9.6.ebuild
419 new file mode 100644
420 index 0000000..7d020a1
421 --- /dev/null
422 +++ b/dev-lang/python/python-3.9.6.ebuild
423 @@ -0,0 +1,346 @@
424 +# Copyright 1999-2021 Gentoo Authors
425 +# Distributed under the terms of the GNU General Public License v2
426 +
427 +EAPI="7"
428 +WANT_LIBTOOL="none"
429 +
430 +inherit autotools check-reqs flag-o-matic multiprocessing pax-utils \
431 + python-utils-r1 toolchain-funcs verify-sig
432 +
433 +MY_PV=${PV/_rc/rc}
434 +MY_P="Python-${MY_PV%_p*}"
435 +PYVER=$(ver_cut 1-2)
436 +PATCHSET="python-gentoo-patches-${MY_PV}"
437 +
438 +DESCRIPTION="An interpreted, interactive, object-oriented programming language"
439 +HOMEPAGE="https://www.python.org/"
440 +SRC_URI="https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz
441 + https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz
442 + verify-sig? (
443 + https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz.asc
444 + )"
445 +S="${WORKDIR}/${MY_P}"
446 +
447 +LICENSE="PSF-2"
448 +SLOT="${PYVER}"
449 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
450 +IUSE="bluetooth build examples gdbm hardened ipv6 +ncurses +readline +sqlite +ssl test tk wininst +xml"
451 +RESTRICT="!test? ( test )"
452 +
453 +# Do not add a dependency on dev-lang/python to this ebuild.
454 +# If you need to apply a patch which requires python for bootstrapping, please
455 +# run the bootstrap code on your dev box and include the results in the
456 +# patchset. See bug 447752.
457 +
458 +RDEPEND="app-arch/bzip2:=
459 + app-arch/xz-utils:=
460 + dev-libs/libffi:=
461 + sys-apps/util-linux:=
462 + >=sys-libs/zlib-1.1.3:=
463 + virtual/libcrypt:=
464 + virtual/libintl
465 + gdbm? ( sys-libs/gdbm:=[berkdb] )
466 + ncurses? ( >=sys-libs/ncurses-5.2:= )
467 + readline? ( >=sys-libs/readline-4.1:= )
468 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
469 + ssl? ( dev-libs/openssl:= )
470 + tk? (
471 + >=dev-lang/tcl-8.0:=
472 + >=dev-lang/tk-8.0:=
473 + dev-tcltk/blt:=
474 + dev-tcltk/tix
475 + )
476 + xml? ( >=dev-libs/expat-2.1:= )"
477 +# bluetooth requires headers from bluez
478 +DEPEND="${RDEPEND}
479 + bluetooth? ( net-wireless/bluez )
480 + test? ( app-arch/xz-utils[extra-filters(+)] )"
481 +BDEPEND="
482 + virtual/pkgconfig
483 + sys-devel/autoconf-archive
484 + verify-sig? ( app-crypt/openpgp-keys-python )
485 + !sys-devel/gcc[libffi(-)]"
486 +RDEPEND+=" !build? ( app-misc/mime-types )"
487 +
488 +VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/python.org.asc
489 +
490 +# large file tests involve a 2.5G file being copied (duplicated)
491 +CHECKREQS_DISK_BUILD=5500M
492 +
493 +pkg_pretend() {
494 + use test && check-reqs_pkg_pretend
495 +}
496 +
497 +pkg_setup() {
498 + use test && check-reqs_pkg_setup
499 +}
500 +
501 +src_unpack() {
502 + if use verify-sig; then
503 + verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc}
504 + fi
505 + default
506 +}
507 +
508 +src_prepare() {
509 + # Ensure that internal copies of expat, libffi and zlib are not used.
510 + rm -fr Modules/expat || die
511 + rm -fr Modules/_ctypes/libffi* || die
512 + rm -fr Modules/zlib || die
513 +
514 + rm -f "${WORKDIR}/${PATCHSET}"/0013-bpo-43998-Default-to-TLS-1.2-and-increase-cipher-sui.patch || die
515 +
516 + local PATCHES=(
517 + "${WORKDIR}/${PATCHSET}"
518 + )
519 +
520 + default
521 +
522 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
523 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
524 +
525 + # force correct number of jobs
526 + # https://bugs.gentoo.org/737660
527 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
528 + sed -i -e "s:-j0:-j${jobs}:" Makefile.pre.in || die
529 + sed -i -e "/self\.parallel/s:True:${jobs}:" setup.py || die
530 +
531 + eautoreconf
532 +}
533 +
534 +src_configure() {
535 + local disable
536 + # disable automagic bluetooth headers detection
537 + use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no
538 + use gdbm || disable+=" gdbm"
539 + use ncurses || disable+=" _curses _curses_panel"
540 + use readline || disable+=" readline"
541 + use sqlite || disable+=" _sqlite3"
542 + use ssl || export PYTHON_DISABLE_SSL="1"
543 + use tk || disable+=" _tkinter"
544 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
545 + export PYTHON_DISABLE_MODULES="${disable}"
546 +
547 + if ! use xml; then
548 + ewarn "You have configured Python without XML support."
549 + ewarn "This is NOT a recommended configuration as you"
550 + ewarn "may face problems parsing any XML documents."
551 + fi
552 +
553 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
554 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
555 + fi
556 +
557 + if [[ "$(gcc-major-version)" -ge 4 ]]; then
558 + append-flags -fwrapv
559 + fi
560 +
561 + filter-flags -malign-double
562 +
563 + # https://bugs.gentoo.org/show_bug.cgi?id=50309
564 + if is-flagq -O3; then
565 + is-flagq -fstack-protector-all && replace-flags -O3 -O2
566 + use hardened && replace-flags -O3 -O2
567 + fi
568 +
569 + # https://bugs.gentoo.org/700012
570 + if is-flagq -flto || is-flagq '-flto=*'; then
571 + append-cflags $(test-flags-CC -ffat-lto-objects)
572 + fi
573 +
574 + # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
575 + tc-export CXX
576 +
577 + # Fix implicit declarations on cross and prefix builds. Bug #674070.
578 + use ncurses && append-cppflags -I"${ESYSROOT}"/usr/include/ncursesw
579 +
580 + local dbmliborder
581 + if use gdbm; then
582 + dbmliborder+="${dbmliborder:+:}gdbm"
583 + fi
584 +
585 + local myeconfargs=(
586 + # glibc-2.30 removes it; since we can't cleanly force-rebuild
587 + # Python on glibc upgrade, remove it proactively to give
588 + # a chance for users rebuilding python before glibc
589 + ac_cv_header_stropts_h=no
590 +
591 + --enable-shared
592 + $(use_enable ipv6)
593 + --infodir='${prefix}/share/info'
594 + --mandir='${prefix}/share/man'
595 + --with-computed-gotos
596 + --with-dbmliborder="${dbmliborder}"
597 + --with-libc=
598 + --enable-loadable-sqlite-extensions
599 + --without-ensurepip
600 + --with-system-expat
601 + --with-system-ffi
602 + )
603 +
604 + OPT="" econf "${myeconfargs[@]}"
605 +
606 + if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
607 + eerror "configure has detected that the sem_open function is broken."
608 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
609 + die "Broken sem_open function (bug 496328)"
610 + fi
611 +}
612 +
613 +src_compile() {
614 + # Ensure sed works as expected
615 + # https://bugs.gentoo.org/594768
616 + local -x LC_ALL=C
617 +
618 + emake CPPFLAGS= CFLAGS= LDFLAGS=
619 +
620 + # Work around bug 329499. See also bug 413751 and 457194.
621 + if has_version dev-libs/libffi[pax-kernel]; then
622 + pax-mark E python
623 + else
624 + pax-mark m python
625 + fi
626 +}
627 +
628 +src_test() {
629 + # Tests will not work when cross compiling.
630 + if tc-is-cross-compiler; then
631 + elog "Disabling tests due to crosscompiling."
632 + return
633 + fi
634 +
635 + # Skip failing tests.
636 + local skipped_tests="gdb"
637 +
638 + for test in ${skipped_tests}; do
639 + mv "${S}"/Lib/test/test_${test}.py "${T}"
640 + done
641 +
642 + # bug 660358
643 + local -x COLUMNS=80
644 + local -x PYTHONDONTWRITEBYTECODE=
645 +
646 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
647 +
648 + emake test EXTRATESTOPTS="-u-network -j${jobs}" \
649 + CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
650 + local result=$?
651 +
652 + for test in ${skipped_tests}; do
653 + mv "${T}/test_${test}.py" "${S}"/Lib/test
654 + done
655 +
656 + elog "The following tests have been skipped:"
657 + for test in ${skipped_tests}; do
658 + elog "test_${test}.py"
659 + done
660 +
661 + elog "If you would like to run them, you may:"
662 + elog "cd '${EPREFIX}/usr/lib/python${PYVER}/test'"
663 + elog "and run the tests separately."
664 +
665 + if [[ ${result} -ne 0 ]]; then
666 + die "emake test failed"
667 + fi
668 +}
669 +
670 +src_install() {
671 + local libdir=${ED}/usr/lib/python${PYVER}
672 +
673 + emake DESTDIR="${D}" altinstall
674 +
675 + # Remove static library
676 + rm "${ED}"/usr/$(get_libdir)/libpython*.a || die
677 +
678 + sed \
679 + -e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" \
680 + -e "s/\(PY_LDFLAGS=\).*/\1/" \
681 + -i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed"
682 +
683 + # Fix collisions between different slots of Python.
684 + rm "${ED}/usr/$(get_libdir)/libpython3.so" || die
685 +
686 + # Cheap hack to get version with ABIFLAGS
687 + local abiver=$(cd "${ED}/usr/include"; echo python*)
688 + if [[ ${abiver} != python${PYVER} ]]; then
689 + # Replace python3.X with a symlink to python3.Xm
690 + rm "${ED}/usr/bin/python${PYVER}" || die
691 + dosym "${abiver}" "/usr/bin/python${PYVER}"
692 + # Create python3.X-config symlink
693 + dosym "${abiver}-config" "/usr/bin/python${PYVER}-config"
694 + # Create python-3.5m.pc symlink
695 + dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc"
696 + fi
697 +
698 + # python seems to get rebuilt in src_install (bug 569908)
699 + # Work around it for now.
700 + if has_version dev-libs/libffi[pax-kernel]; then
701 + pax-mark E "${ED}/usr/bin/${abiver}"
702 + else
703 + pax-mark m "${ED}/usr/bin/${abiver}"
704 + fi
705 +
706 + use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
707 + use tk || rm -r "${ED}/usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*} || die
708 +
709 + dodoc Misc/{ACKS,HISTORY,NEWS}
710 +
711 + if use examples; then
712 + docinto examples
713 + find Tools -name __pycache__ -exec rm -fr {} + || die
714 + dodoc -r Tools
715 + fi
716 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
717 + local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
718 + emake --no-print-directory -s -f - 2>/dev/null)
719 + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
720 +
721 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
722 + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
723 + sed \
724 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
725 + -e "s:@PYDOC@:pydoc${PYVER}:" \
726 + -i "${ED}/etc/conf.d/pydoc-${PYVER}" \
727 + "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed"
728 +
729 + local -x EPYTHON=python${PYVER}
730 + # if not using a cross-compiler, use the fresh binary
731 + if ! tc-is-cross-compiler; then
732 + local -x PYTHON=./python
733 + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD}
734 + else
735 + local -x PYTHON=${EPREFIX}/usr/bin/${EPYTHON}
736 + fi
737 +
738 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
739 + python_domodule epython.py
740 +
741 + # python-exec wrapping support
742 + local pymajor=${PYVER%.*}
743 + local scriptdir=${D}$(python_get_scriptdir)
744 + mkdir -p "${scriptdir}" || die
745 + # python and pythonX
746 + ln -s "../../../bin/${abiver}" \
747 + "${scriptdir}/python${pymajor}" || die
748 + ln -s "python${pymajor}" "${scriptdir}/python" || die
749 + # python-config and pythonX-config
750 + # note: we need to create a wrapper rather than symlinking it due
751 + # to some random dirname(argv[0]) magic performed by python-config
752 + cat > "${scriptdir}/python${pymajor}-config" <<-EOF || die
753 + #!/bin/sh
754 + exec "${abiver}-config" "\${@}"
755 + EOF
756 + chmod +x "${scriptdir}/python${pymajor}-config" || die
757 + ln -s "python${pymajor}-config" \
758 + "${scriptdir}/python-config" || die
759 + # 2to3, pydoc
760 + ln -s "../../../bin/2to3-${PYVER}" \
761 + "${scriptdir}/2to3" || die
762 + ln -s "../../../bin/pydoc${PYVER}" \
763 + "${scriptdir}/pydoc" || die
764 + # idle
765 + if use tk; then
766 + ln -s "../../../bin/idle${PYVER}" \
767 + "${scriptdir}/idle" || die
768 + fi
769 +}