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