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