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