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