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