Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/python/
Date: Mon, 05 Sep 2022 07:44:27
Message-Id: 1662363858.c02fc63c3bffc7080c6b64eb954207549901e370.mgorny@gentoo
1 commit: c02fc63c3bffc7080c6b64eb954207549901e370
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Mon Sep 5 07:28:13 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Mon Sep 5 07:44:18 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c02fc63c
7
8 dev-lang/python: Backport more bignum fixes to 3.10.6_p4
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 dev-lang/python/Manifest | 1 +
13 dev-lang/python/python-3.10.6_p4.ebuild | 407 ++++++++++++++++++++++++++++++++
14 2 files changed, 408 insertions(+)
15
16 diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest
17 index 5f6dcd704221..c8c9c0ba11fe 100644
18 --- a/dev-lang/python/Manifest
19 +++ b/dev-lang/python/Manifest
20 @@ -11,6 +11,7 @@ DIST Python-3.9.13.tar.xz.asc 833 BLAKE2B db01c01be9d56cd15f9ab4a9e2cfa800faf4eb
21 DIST python-gentoo-patches-2.7.18_p15.tar.xz 34956 BLAKE2B d173f276dd9c0ce31004dcc55a0d18e9ce25a47683c2df3c4dd62e967dfbbb35be59a2f08cf20f30a19475a8a2344dd95b17400eafa88b5fdbe9270a12ccbf32 SHA512 d9386808265f978808e5c0ffd384cefe54fb0e05aeccfd394167d5227d9cd66e25c8e93c54914762b2cfc3c2dd851b26a7a84d62634c6aa8a0798aacbb7ac25f
22 DIST python-gentoo-patches-3.10.6_p2.tar.xz 12040 BLAKE2B 75c93fab19137a966b3775308bc20142f4d3648bbb9364e82c4eaffae93beda54011192881c52b85d2e2493a06cfe2a90f50675609908c3d5ebdb0103fe41644 SHA512 7e451a8a18a62592c2cd7b2db71065b77256960f43e172a0d7856b22b69138dcb1552f53b39bec14585a761cfe729c81613551c1b616fe1ec8d2b59856b11453
23 DIST python-gentoo-patches-3.10.6_p3.tar.xz 26712 BLAKE2B 701a7a4da1a09f71dee8fdf924a45e030b8ae93e469a2789b28b904d2fd6b011589fb940eb0c262e8b19005af523a2f66075d053fb60892d6ebd473159fce718 SHA512 ed43ba18735ddf72c434bfe905894d156a144a77f9fb8266378d384e840b376c6220859d8d1af83f304293368bf1dd45881316c1797ba25d618a064daaacab17
24 +DIST python-gentoo-patches-3.10.6_p4.tar.xz 28612 BLAKE2B 197ef33c3086cb9efaf09868145826e2889f61d6fb207df8b60ac6cfc4ca637c8a87fd10afa2d8a7a47ae81bcf0ae589085c694523e1ca6f85acdc4e517b7d07 SHA512 8bd0aa8f7a775d12914d542dbb04c7b555055228002dd826a815255d4a35392e09c44d560cc5da7df1feae98e2f73e8fbf476e2811ae5269f91120c11cbb6291
25 DIST python-gentoo-patches-3.11.0rc1.tar.xz 4384 BLAKE2B 31bcdc055bfaf3434dbb02543aaf66910eaccd01808d9a0e57bf7cb3b097fc0046c00ac44737d9c37e3b6d074c524f4dd3ab439a741e66d74a0425889ecaead5 SHA512 05b044e2d8f881c471528600ee300bfd9cf5160609dfb3d7cbdb8e43f47b681542582a85de97e28e6a3b89a3fb6c8d7398e029d31e20cea9c5a2a71700382d4e
26 DIST python-gentoo-patches-3.11.0rc1_p1.tar.xz 19584 BLAKE2B 33c87e2e7141fa5cdf343df8cf30e8e0bd37fdfc7b4d84564b1131c57db27b5886184fd1291b2a898efafec60da5c01d16dce8b3c8792df7df15793d767d74cd SHA512 dc5547622a17bc899dfa7f55a4705f780fd3b731ccdb2c0a87e3d71b4490a32b54683ff862f412e2ac3480f0e84acf2e88176ecf89a8d62b97454e51258696ea
27 DIST python-gentoo-patches-3.11.0rc1_p2.tar.xz 21580 BLAKE2B 188a3b2e5bc0d067dac20a7d5bfe3149eeac062bdb29972b0d0a8b24238aa21eb2f2a797b57f6ded80cb85d255f6cc1e6336d57c3e5f43d2b8aa890e7d35ef50 SHA512 fbc740b7e8161d4878cc91d9ee66026ae51082f2b18d77dc40167bfab4891e7b811fa4920ddf5c5a27d8ddc84a0220ccb1b3612744818084da321188ada09563
28
29 diff --git a/dev-lang/python/python-3.10.6_p4.ebuild b/dev-lang/python/python-3.10.6_p4.ebuild
30 new file mode 100644
31 index 000000000000..b919f0692412
32 --- /dev/null
33 +++ b/dev-lang/python/python-3.10.6_p4.ebuild
34 @@ -0,0 +1,407 @@
35 +# Copyright 1999-2022 Gentoo Authors
36 +# Distributed under the terms of the GNU General Public License v2
37 +
38 +EAPI="7"
39 +WANT_LIBTOOL="none"
40 +
41 +inherit autotools check-reqs flag-o-matic multiprocessing pax-utils
42 +inherit python-utils-r1 toolchain-funcs verify-sig
43 +
44 +MY_PV=${PV/_rc/rc}
45 +MY_P="Python-${MY_PV%_p*}"
46 +PYVER=$(ver_cut 1-2)
47 +PATCHSET="python-gentoo-patches-${MY_PV}"
48 +
49 +DESCRIPTION="An interpreted, interactive, object-oriented programming language"
50 +HOMEPAGE="
51 + https://www.python.org/
52 + https://github.com/python/cpython/
53 +"
54 +SRC_URI="
55 + https://www.python.org/ftp/python/${PV%%_*}/${MY_P}.tar.xz
56 + https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz
57 + verify-sig? (
58 + https://www.python.org/ftp/python/${PV%%_*}/${MY_P}.tar.xz.asc
59 + )
60 +"
61 +S="${WORKDIR}/${MY_P}"
62 +
63 +LICENSE="PSF-2"
64 +SLOT="${PYVER}"
65 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
66 +IUSE="
67 + bluetooth build +ensurepip examples gdbm hardened libedit lto
68 + +ncurses pgo +readline +sqlite +ssl test tk +xml
69 +"
70 +RESTRICT="!test? ( test )"
71 +
72 +# Do not add a dependency on dev-lang/python to this ebuild.
73 +# If you need to apply a patch which requires python for bootstrapping, please
74 +# run the bootstrap code on your dev box and include the results in the
75 +# patchset. See bug 447752.
76 +
77 +RDEPEND="
78 + app-arch/bzip2:=
79 + app-arch/xz-utils:=
80 + dev-lang/python-exec[python_targets_python3_10(-)]
81 + dev-libs/libffi:=
82 + sys-apps/util-linux:=
83 + >=sys-libs/zlib-1.1.3:=
84 + virtual/libcrypt:=
85 + virtual/libintl
86 + ensurepip? ( dev-python/ensurepip-wheels )
87 + gdbm? ( sys-libs/gdbm:=[berkdb] )
88 + ncurses? ( >=sys-libs/ncurses-5.2:= )
89 + readline? (
90 + !libedit? ( >=sys-libs/readline-4.1:= )
91 + libedit? ( dev-libs/libedit:= )
92 + )
93 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
94 + ssl? ( >=dev-libs/openssl-1.1.1:= )
95 + tk? (
96 + >=dev-lang/tcl-8.0:=
97 + >=dev-lang/tk-8.0:=
98 + dev-tcltk/blt:=
99 + dev-tcltk/tix
100 + )
101 + xml? ( >=dev-libs/expat-2.1:= )
102 + !!<sys-apps/sandbox-2.21
103 +"
104 +# bluetooth requires headers from bluez
105 +DEPEND="
106 + ${RDEPEND}
107 + bluetooth? ( net-wireless/bluez )
108 + test? ( app-arch/xz-utils[extra-filters(+)] )
109 +"
110 +# autoconf-archive needed to eautoreconf
111 +BDEPEND="
112 + sys-devel/autoconf-archive
113 + virtual/awk
114 + virtual/pkgconfig
115 + verify-sig? ( sec-keys/openpgp-keys-python )
116 +"
117 +RDEPEND+="
118 + !build? ( app-misc/mime-types )
119 +"
120 +
121 +VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/python.org.asc
122 +
123 +# large file tests involve a 2.5G file being copied (duplicated)
124 +CHECKREQS_DISK_BUILD=5500M
125 +
126 +QA_PKGCONFIG_VERSION=${PYVER}
127 +
128 +pkg_pretend() {
129 + use test && check-reqs_pkg_pretend
130 +}
131 +
132 +pkg_setup() {
133 + use test && check-reqs_pkg_setup
134 +}
135 +
136 +src_unpack() {
137 + if use verify-sig; then
138 + verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc}
139 + fi
140 + default
141 +}
142 +
143 +src_prepare() {
144 + # Ensure that internal copies of expat and libffi are not used.
145 + rm -r Modules/expat || die
146 + rm -r Modules/_ctypes/libffi* || die
147 +
148 + local PATCHES=(
149 + "${WORKDIR}/${PATCHSET}"
150 + )
151 +
152 + default
153 +
154 + # https://bugs.gentoo.org/850151
155 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" setup.py || die
156 +
157 + # force the correct number of jobs
158 + # https://bugs.gentoo.org/737660
159 + local jobs=$(makeopts_jobs)
160 + sed -i -e "s:-j0:-j${jobs}:" Makefile.pre.in || die
161 + sed -i -e "/self\.parallel/s:True:${jobs}:" setup.py || die
162 +
163 + eautoreconf
164 +}
165 +
166 +src_configure() {
167 + # disable automagic bluetooth headers detection
168 + if ! use bluetooth; then
169 + local -x ac_cv_header_bluetooth_bluetooth_h=no
170 + fi
171 + local disable
172 + use gdbm || disable+=" gdbm"
173 + use ncurses || disable+=" _curses _curses_panel"
174 + use readline || disable+=" readline"
175 + use sqlite || disable+=" _sqlite3"
176 + use ssl || export PYTHON_DISABLE_SSL="1"
177 + use tk || disable+=" _tkinter"
178 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
179 + export PYTHON_DISABLE_MODULES="${disable}"
180 +
181 + if ! use xml; then
182 + ewarn "You have configured Python without XML support."
183 + ewarn "This is NOT a recommended configuration as you"
184 + ewarn "may face problems parsing any XML documents."
185 + fi
186 +
187 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
188 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
189 + fi
190 +
191 + append-flags -fwrapv
192 + filter-flags -malign-double
193 +
194 + # https://bugs.gentoo.org/700012
195 + if is-flagq -flto || is-flagq '-flto=*'; then
196 + append-cflags $(test-flags-CC -ffat-lto-objects)
197 + fi
198 +
199 + # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
200 + # PKG_CONFIG needed for cross.
201 + tc-export CXX PKG_CONFIG
202 +
203 + # Fix implicit declarations on cross and prefix builds. Bug #674070.
204 + if use ncurses; then
205 + append-cppflags -I"${ESYSROOT}"/usr/include/ncursesw
206 + fi
207 +
208 + local dbmliborder=
209 + if use gdbm; then
210 + dbmliborder+="${dbmliborder:+:}gdbm"
211 + fi
212 +
213 + if use pgo; then
214 + local profile_task_flags=(
215 + -m test
216 + "-j$(makeopts_jobs)"
217 + --pgo-extended
218 + -x test_gdb
219 + -u-network
220 +
221 + # All of these seem to occasionally hang for PGO inconsistently
222 + # They'll even hang here but be fine in src_test sometimes.
223 + # bug #828535 (and related: bug #788022)
224 + -x test_asyncio
225 + -x test_httpservers
226 + -x test_logging
227 + -x test_multiprocessing_fork
228 + -x test_socket
229 + -x test_xmlrpc
230 + )
231 +
232 + if has_version "app-arch/rpm" ; then
233 + # Avoid sandbox failure (attempts to write to /var/lib/rpm)
234 + profile_task_flags+=(
235 + -x test_distutils
236 + )
237 + fi
238 + local -x PROFILE_TASK="${profile_task_flags[*]}"
239 + fi
240 +
241 + local myeconfargs=(
242 + # glibc-2.30 removes it; since we can't cleanly force-rebuild
243 + # Python on glibc upgrade, remove it proactively to give
244 + # a chance for users rebuilding python before glibc
245 + ac_cv_header_stropts_h=no
246 +
247 + --enable-shared
248 + --without-static-libpython
249 + --enable-ipv6
250 + --infodir='${prefix}/share/info'
251 + --mandir='${prefix}/share/man'
252 + --with-computed-gotos
253 + --with-dbmliborder="${dbmliborder}"
254 + --with-libc=
255 + --enable-loadable-sqlite-extensions
256 + --without-ensurepip
257 + --with-system-expat
258 + --with-system-ffi
259 + --with-wheel-pkg-dir="${EPREFIX}"/usr/lib/python/ensurepip
260 +
261 + $(use_with lto)
262 + $(use_enable pgo optimizations)
263 + $(use_with readline readline "$(usex libedit editline readline)")
264 + )
265 +
266 + # disable implicit optimization/debugging flags
267 + local -x OPT=
268 + # pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
269 + # propagated to sysconfig for built extensions
270 + local -x CFLAGS_NODIST=${CFLAGS}
271 + local -x LDFLAGS_NODIST=${LDFLAGS}
272 + local -x CFLAGS= LDFLAGS=
273 +
274 + econf "${myeconfargs[@]}"
275 +
276 + if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
277 + eerror "configure has detected that the sem_open function is broken."
278 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
279 + die "Broken sem_open function (bug 496328)"
280 + fi
281 +
282 + # install epython.py as part of stdlib
283 + echo "EPYTHON='python${PYVER}'" > Lib/epython.py || die
284 +}
285 +
286 +src_compile() {
287 + # Ensure sed works as expected
288 + # https://bugs.gentoo.org/594768
289 + local -x LC_ALL=C
290 + # Prevent using distutils bundled by setuptools.
291 + # https://bugs.gentoo.org/823728
292 + export SETUPTOOLS_USE_DISTUTILS=stdlib
293 +
294 + # Save PYTHONDONTWRITEBYTECODE so that 'has_version' doesn't
295 + # end up writing bytecode & violating sandbox.
296 + # bug #831897
297 + local -x _PYTHONDONTWRITEBYTECODE=${PYTHONDONTWRITEBYTECODE}
298 +
299 + if use pgo ; then
300 + # bug 660358
301 + local -x COLUMNS=80
302 + local -x PYTHONDONTWRITEBYTECODE=
303 +
304 + addpredict /usr/lib/python3.10/site-packages
305 + fi
306 +
307 + # also need to clear the flags explicitly here or they end up
308 + # in _sysconfigdata*
309 + emake CPPFLAGS= CFLAGS= LDFLAGS=
310 +
311 + # Restore saved value from above.
312 + local -x PYTHONDONTWRITEBYTECODE=${_PYTHONDONTWRITEBYTECODE}
313 +
314 + # Work around bug 329499. See also bug 413751 and 457194.
315 + if has_version dev-libs/libffi[pax-kernel]; then
316 + pax-mark E python
317 + else
318 + pax-mark m python
319 + fi
320 +}
321 +
322 +src_test() {
323 + # Tests will not work when cross compiling.
324 + if tc-is-cross-compiler; then
325 + elog "Disabling tests due to crosscompiling."
326 + return
327 + fi
328 +
329 + local test_opts=(
330 + -u-network
331 + -j "$(makeopts_jobs)"
332 +
333 + # fails
334 + -x test_gdb
335 + )
336 +
337 + if use sparc ; then
338 + # bug #788022
339 + test_opts+=(
340 + -x test_multiprocessing_fork
341 + -x test_multiprocessing_forkserver
342 + )
343 + fi
344 +
345 + # bug 660358
346 + local -x COLUMNS=80
347 + local -x PYTHONDONTWRITEBYTECODE=
348 + # workaround https://bugs.gentoo.org/775416
349 + addwrite /usr/lib/python3.10/site-packages
350 +
351 + emake test EXTRATESTOPTS="${test_opts[*]}" \
352 + CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty || die "emake test failed"
353 +}
354 +
355 +src_install() {
356 + local libdir=${ED}/usr/lib/python${PYVER}
357 +
358 + emake DESTDIR="${D}" altinstall
359 +
360 + # Fix collisions between different slots of Python.
361 + rm "${ED}/usr/$(get_libdir)/libpython3.so" || die
362 +
363 + # Cheap hack to get version with ABIFLAGS
364 + local abiver=$(cd "${ED}/usr/include"; echo python*)
365 + if [[ ${abiver} != python${PYVER} ]]; then
366 + # Replace python3.X with a symlink to python3.Xm
367 + rm "${ED}/usr/bin/python${PYVER}" || die
368 + dosym "${abiver}" "/usr/bin/python${PYVER}"
369 + # Create python3.X-config symlink
370 + dosym "${abiver}-config" "/usr/bin/python${PYVER}-config"
371 + # Create python-3.5m.pc symlink
372 + dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc"
373 + fi
374 +
375 + # python seems to get rebuilt in src_install (bug 569908)
376 + # Work around it for now.
377 + if has_version dev-libs/libffi[pax-kernel]; then
378 + pax-mark E "${ED}/usr/bin/${abiver}"
379 + else
380 + pax-mark m "${ED}/usr/bin/${abiver}"
381 + fi
382 +
383 + rm -r "${libdir}"/ensurepip/_bundled || die
384 + if ! use ensurepip; then
385 + rm -r "${libdir}"/ensurepip || die
386 + fi
387 + if ! use sqlite; then
388 + rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
389 + fi
390 + if ! use tk; then
391 + rm -r "${ED}/usr/bin/idle${PYVER}" || die
392 + rm -r "${libdir}/"{idlelib,tkinter,test/test_tk*} || die
393 + fi
394 +
395 + dodoc Misc/{ACKS,HISTORY,NEWS}
396 +
397 + if use examples; then
398 + docinto examples
399 + find Tools -name __pycache__ -exec rm -fr {} + || die
400 + dodoc -r Tools
401 + fi
402 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
403 + local libname=$(
404 + printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' |
405 + emake --no-print-directory -s -f - 2>/dev/null
406 + )
407 + newins Tools/gdb/libpython.py "${libname}"-gdb.py
408 +
409 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
410 + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
411 + sed \
412 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
413 + -e "s:@PYDOC@:pydoc${PYVER}:" \
414 + -i "${ED}/etc/conf.d/pydoc-${PYVER}" \
415 + "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed"
416 +
417 + # python-exec wrapping support
418 + local pymajor=${PYVER%.*}
419 + local EPYTHON=python${PYVER}
420 + local scriptdir=${D}$(python_get_scriptdir)
421 + mkdir -p "${scriptdir}" || die
422 + # python and pythonX
423 + ln -s "../../../bin/${abiver}" "${scriptdir}/python${pymajor}" || die
424 + ln -s "python${pymajor}" "${scriptdir}/python" || die
425 + # python-config and pythonX-config
426 + # note: we need to create a wrapper rather than symlinking it due
427 + # to some random dirname(argv[0]) magic performed by python-config
428 + cat > "${scriptdir}/python${pymajor}-config" <<-EOF || die
429 + #!/bin/sh
430 + exec "${abiver}-config" "\${@}"
431 + EOF
432 + chmod +x "${scriptdir}/python${pymajor}-config" || die
433 + ln -s "python${pymajor}-config" "${scriptdir}/python-config" || die
434 + # 2to3, pydoc
435 + ln -s "../../../bin/2to3-${PYVER}" "${scriptdir}/2to3" || die
436 + ln -s "../../../bin/pydoc${PYVER}" "${scriptdir}/pydoc" || die
437 + # idle
438 + if use tk; then
439 + ln -s "../../../bin/idle${PYVER}" "${scriptdir}/idle" || die
440 + fi
441 +}