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