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: 1646481291.31a128fad09c3d3969a16fc42cc093466b048943.mgorny@gentoo
1 commit: 31a128fad09c3d3969a16fc42cc093466b048943
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sat Mar 5 11:12:32 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sat Mar 5 11:54:51 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=31a128fa
7
8 dev-lang/python: Backport expat test fixes to 3.8
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.8.12_p2.ebuild | 345 ++++++++++++++++++++++++++++++++
14 2 files changed, 346 insertions(+)
15
16 diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest
17 index 5532998d624a..bbcb3e53ea7e 100644
18 --- a/dev-lang/python/Manifest
19 +++ b/dev-lang/python/Manifest
20 @@ -31,6 +31,7 @@ DIST python-gentoo-patches-3.11.0a5_p1.tar.xz 4956 BLAKE2B e93817dd9b0fe695b5ade
21 DIST python-gentoo-patches-3.6.15.tar.xz 15300 BLAKE2B f49fd96f6ad1a1c94fea6b83acd229a81754b86061e243044ead4b9a9d5122a2e43b270b68722c359c084c05a566a3ad70aa46588ab7a005ee560ee118b92b8b SHA512 cc33491a33f3f1d990cf494d53b91b74db761142e8aebe1bd4b128ef10a268ff945e5ba08daad39cee095612a8e52265d6988873ecf9c073377cbbc10735aa39
22 DIST python-gentoo-patches-3.7.12_p1.tar.xz 19112 BLAKE2B e9964244af3db544dd6e96d85ca4bc24d7131b48eda85df5bafa3fb36474a024cecbbf4b27324e1f35f76ae6a1aed31dd7896e831b79b574b45a4371afcc7e5b SHA512 9ec996c2904f99bd6651ed1b700eabd91f2b82b1e9e0f3d9572243886a9c7139bf8ac2af04169485d3ca6339e1a87044cba203f6f0aee9609d2a1d53c812548d
23 DIST python-gentoo-patches-3.8.12_p1.tar.xz 16632 BLAKE2B cce7a41d020af1ffc55a01ef67b20bcb16c68adbccc1e44ef166d1707e817ed6c3bae70f84c56553f27bca449015e273014c0be73bc2f9b4e25844ddce385486 SHA512 4621727c2e9cc1c5519e021210e16a97e7167ea831445dfdd07f5b0ed642b5919834244111708a971ce098b10b439797e1c76827eccab803f801052c671f1ae6
24 +DIST python-gentoo-patches-3.8.12_p2.tar.xz 17224 BLAKE2B 1287a7fe2e55a5a24872cc9849d2339fbc453ed9a02a276afef9aecb451f97104cbc926d10dc99fdf423dbe49987b7a56c548120e204088b59e5ca710c146a66 SHA512 c2ebea7a74fe2d2d9af5b3902a0cd8542247f2e3a310b1e91be3ed7f5bd1d51a77f013f7c3047aef8c2762b740cb9daeb30fd4680dc3bbe1b61dc095ebb1a6ac
25 DIST python-gentoo-patches-3.9.10.tar.xz 12844 BLAKE2B f342fbdd1a580787e2d699ded9dc5307f5b610303c6869aa8d0fa4d9e60acd997dc12ae96c6de07cdf9ce0a8bfb6e13291d611d4a6a193844049882b5d01d1e5 SHA512 50111552ff82019672d82e5a328e6e9d8ec2a61a957b63a7a49c5de1f1b77be296272f4273c78154667d5a88d82646360d9a411bb8cf451408837413b06d4b23
26 DIST python-gentoo-patches-3.9.10_p1.tar.xz 14080 BLAKE2B 7cc21ffc439b82661e151ce7f85e217ce7cbe674296e7f7fc7f9b9215486d2845e8314130d1d378e24a0c2c9a6340055b1e4345426b136c113b7e833c564e903 SHA512 1be7ccf4dbb29d4b19985000baf98e54d77f493069f44381b5a3629b1e5b275755ef5a4736a7490d0bec037ab4be88ca1856d615bca9c759b0995b066dd2dbed
27 DIST python-gentoo-patches-3.9.9.tar.xz 13200 BLAKE2B 672e3b79094cbc791988639a5dde4c9e5622e91bef4310d26838716c65763ca69a12c6afef2f19487f4389974af009896e452c19783b0a491072d13f893af7e9 SHA512 3cd4ddd070ab48d9978e1136d237fc24030fd3ce6704371ce99815702a45d839ee26c7e9552b004661827759edd30222434e4166f9ee16f873ad4783c83f723f
28
29 diff --git a/dev-lang/python/python-3.8.12_p2.ebuild b/dev-lang/python/python-3.8.12_p2.ebuild
30 new file mode 100644
31 index 000000000000..f55e6edea522
32 --- /dev/null
33 +++ b/dev-lang/python/python-3.8.12_p2.ebuild
34 @@ -0,0 +1,345 @@
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 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 +ncurses +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_8(-)]
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? ( >=sys-libs/readline-4.1:= )
80 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
81 + ssl? ( >=dev-libs/openssl-1.1.1:= )
82 + tk? (
83 + >=dev-lang/tcl-8.0:=
84 + >=dev-lang/tk-8.0:=
85 + dev-tcltk/blt:=
86 + dev-tcltk/tix
87 + )
88 + xml? ( >=dev-libs/expat-2.1:= )"
89 +# bluetooth requires headers from bluez
90 +DEPEND="${RDEPEND}
91 + bluetooth? ( net-wireless/bluez )
92 + test? ( app-arch/xz-utils[extra-filters(+)] )"
93 +BDEPEND="
94 + virtual/awk
95 + virtual/pkgconfig
96 + sys-devel/autoconf-archive
97 + verify-sig? ( sec-keys/openpgp-keys-python )
98 + !sys-devel/gcc[libffi(-)]"
99 +RDEPEND+=" !build? ( app-misc/mime-types )"
100 +
101 +VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/python.org.asc
102 +
103 +src_unpack() {
104 + if use verify-sig; then
105 + verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc}
106 + fi
107 + default
108 +}
109 +
110 +src_prepare() {
111 + # Ensure that internal copies of expat, libffi and zlib are not used.
112 + rm -fr Modules/expat || die
113 + rm -fr Modules/_ctypes/libffi* || die
114 + rm -fr Modules/zlib || die
115 +
116 + local PATCHES=(
117 + "${WORKDIR}/${PATCHSET}"
118 + )
119 +
120 + default
121 +
122 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
123 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
124 +
125 + # force correct number of jobs
126 + # https://bugs.gentoo.org/737660
127 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
128 + sed -i -e "s:-j0:-j${jobs}:" Makefile.pre.in || die
129 + sed -i -e "/self\.parallel/s:True:${jobs}:" setup.py || die
130 +
131 + eautoreconf
132 +}
133 +
134 +src_configure() {
135 + local disable
136 + # disable automagic bluetooth headers detection
137 + use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no
138 + use gdbm || disable+=" gdbm"
139 + use ncurses || disable+=" _curses _curses_panel"
140 + use readline || disable+=" readline"
141 + use sqlite || disable+=" _sqlite3"
142 + use ssl || export PYTHON_DISABLE_SSL="1"
143 + use tk || disable+=" _tkinter"
144 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
145 + export PYTHON_DISABLE_MODULES="${disable}"
146 +
147 + if ! use xml; then
148 + ewarn "You have configured Python without XML support."
149 + ewarn "This is NOT a recommended configuration as you"
150 + ewarn "may face problems parsing any XML documents."
151 + fi
152 +
153 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
154 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
155 + fi
156 +
157 + if [[ "$(gcc-major-version)" -ge 4 ]]; then
158 + append-flags -fwrapv
159 + fi
160 +
161 + filter-flags -malign-double
162 +
163 + # https://bugs.gentoo.org/show_bug.cgi?id=50309
164 + if is-flagq -O3; then
165 + is-flagq -fstack-protector-all && replace-flags -O3 -O2
166 + use hardened && replace-flags -O3 -O2
167 + fi
168 +
169 + # https://bugs.gentoo.org/700012
170 + if is-flagq -flto || is-flagq '-flto=*'; then
171 + append-cflags $(test-flags-CC -ffat-lto-objects)
172 + fi
173 +
174 + # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
175 + tc-export CXX
176 +
177 + # Fix implicit declarations on cross and prefix builds. Bug #674070.
178 + use ncurses && append-cppflags -I"${ESYSROOT}"/usr/include/ncursesw
179 +
180 + local dbmliborder
181 + if use gdbm; then
182 + dbmliborder+="${dbmliborder:+:}gdbm"
183 + fi
184 +
185 + local myeconfargs=(
186 + # glibc-2.30 removes it; since we can't cleanly force-rebuild
187 + # Python on glibc upgrade, remove it proactively to give
188 + # a chance for users rebuilding python before glibc
189 + ac_cv_header_stropts_h=no
190 +
191 + --enable-shared
192 + --enable-ipv6
193 + --infodir='${prefix}/share/info'
194 + --mandir='${prefix}/share/man'
195 + --with-computed-gotos
196 + --with-dbmliborder="${dbmliborder}"
197 + --with-libc=
198 + --enable-loadable-sqlite-extensions
199 + --without-ensurepip
200 + --with-system-expat
201 + --with-system-ffi
202 + )
203 +
204 + # disable implicit optimization/debugging flags
205 + local -x OPT=
206 + # pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
207 + # propagated to sysconfig for built extensions
208 + local -x CFLAGS_NODIST=${CFLAGS}
209 + local -x LDFLAGS_NODIST=${LDFLAGS}
210 + local -x CFLAGS= LDFLAGS=
211 +
212 + econf "${myeconfargs[@]}"
213 +
214 + if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
215 + eerror "configure has detected that the sem_open function is broken."
216 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
217 + die "Broken sem_open function (bug 496328)"
218 + fi
219 +}
220 +
221 +src_compile() {
222 + # Ensure sed works as expected
223 + # https://bugs.gentoo.org/594768
224 + local -x LC_ALL=C
225 + # Prevent using distutils bundled by setuptools.
226 + # https://bugs.gentoo.org/823728
227 + export SETUPTOOLS_USE_DISTUTILS=stdlib
228 +
229 + # also need to clear the flags explicitly here or they end up
230 + # in _sysconfigdata*
231 + emake CPPFLAGS= CFLAGS= LDFLAGS=
232 +
233 + # Work around bug 329499. See also bug 413751 and 457194.
234 + if has_version dev-libs/libffi[pax-kernel]; then
235 + pax-mark E python
236 + else
237 + pax-mark m python
238 + fi
239 +}
240 +
241 +src_test() {
242 + # Tests will not work when cross compiling.
243 + if tc-is-cross-compiler; then
244 + elog "Disabling tests due to crosscompiling."
245 + return
246 + fi
247 +
248 + # Skip failing tests.
249 + local skipped_tests="gdb"
250 +
251 + for test in ${skipped_tests}; do
252 + mv "${S}"/Lib/test/test_${test}.py "${T}"
253 + done
254 +
255 + # bug 660358
256 + local -x COLUMNS=80
257 + local -x PYTHONDONTWRITEBYTECODE=
258 +
259 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
260 +
261 + emake test EXTRATESTOPTS="-u-network -j${jobs}" \
262 + CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
263 + local result=$?
264 +
265 + for test in ${skipped_tests}; do
266 + mv "${T}/test_${test}.py" "${S}"/Lib/test
267 + done
268 +
269 + elog "The following tests have been skipped:"
270 + for test in ${skipped_tests}; do
271 + elog "test_${test}.py"
272 + done
273 +
274 + elog "If you would like to run them, you may:"
275 + elog "cd '${EPREFIX}/usr/lib/python${PYVER}/test'"
276 + elog "and run the tests separately."
277 +
278 + if [[ ${result} -ne 0 ]]; then
279 + die "emake test failed"
280 + fi
281 +}
282 +
283 +src_install() {
284 + local libdir=${ED}/usr/lib/python${PYVER}
285 +
286 + emake DESTDIR="${D}" altinstall
287 +
288 + # Remove static library
289 + rm "${ED}"/usr/$(get_libdir)/libpython*.a || die
290 +
291 + # Fix collisions between different slots of Python.
292 + rm "${ED}/usr/$(get_libdir)/libpython3.so" || die
293 +
294 + # Cheap hack to get version with ABIFLAGS
295 + local abiver=$(cd "${ED}/usr/include"; echo python*)
296 + if [[ ${abiver} != python${PYVER} ]]; then
297 + # Replace python3.X with a symlink to python3.Xm
298 + rm "${ED}/usr/bin/python${PYVER}" || die
299 + dosym "${abiver}" "/usr/bin/python${PYVER}"
300 + # Create python3.X-config symlink
301 + dosym "${abiver}-config" "/usr/bin/python${PYVER}-config"
302 + # Create python-3.5m.pc symlink
303 + dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc"
304 + fi
305 +
306 + # python seems to get rebuilt in src_install (bug 569908)
307 + # Work around it for now.
308 + if has_version dev-libs/libffi[pax-kernel]; then
309 + pax-mark E "${ED}/usr/bin/${abiver}"
310 + else
311 + pax-mark m "${ED}/usr/bin/${abiver}"
312 + fi
313 +
314 + use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
315 + use tk || rm -r "${ED}/usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*} || die
316 +
317 + use wininst || rm "${libdir}/distutils/command/"wininst-*.exe || die
318 +
319 + dodoc Misc/{ACKS,HISTORY,NEWS}
320 +
321 + if use examples; then
322 + docinto examples
323 + find Tools -name __pycache__ -exec rm -fr {} + || die
324 + dodoc -r Tools
325 + fi
326 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
327 + local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
328 + emake --no-print-directory -s -f - 2>/dev/null)
329 + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
330 +
331 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
332 + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
333 + sed \
334 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
335 + -e "s:@PYDOC@:pydoc${PYVER}:" \
336 + -i "${ED}/etc/conf.d/pydoc-${PYVER}" \
337 + "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed"
338 +
339 + local -x EPYTHON=python${PYVER}
340 + # if not using a cross-compiler, use the fresh binary
341 + if ! tc-is-cross-compiler; then
342 + local -x PYTHON=./python
343 + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD}
344 + else
345 + local -x PYTHON=${EPREFIX}/usr/bin/${EPYTHON}
346 + fi
347 +
348 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
349 + python_domodule epython.py
350 +
351 + # python-exec wrapping support
352 + local pymajor=${PYVER%.*}
353 + local scriptdir=${D}$(python_get_scriptdir)
354 + mkdir -p "${scriptdir}" || die
355 + # python and pythonX
356 + ln -s "../../../bin/${abiver}" \
357 + "${scriptdir}/python${pymajor}" || die
358 + ln -s "python${pymajor}" "${scriptdir}/python" || die
359 + # python-config and pythonX-config
360 + # note: we need to create a wrapper rather than symlinking it due
361 + # to some random dirname(argv[0]) magic performed by python-config
362 + cat > "${scriptdir}/python${pymajor}-config" <<-EOF || die
363 + #!/bin/sh
364 + exec "${abiver}-config" "\${@}"
365 + EOF
366 + chmod +x "${scriptdir}/python${pymajor}-config" || die
367 + ln -s "python${pymajor}-config" \
368 + "${scriptdir}/python-config" || die
369 + # 2to3, pydoc
370 + ln -s "../../../bin/2to3-${PYVER}" \
371 + "${scriptdir}/2to3" || die
372 + ln -s "../../../bin/pydoc${PYVER}" \
373 + "${scriptdir}/pydoc" || die
374 + # idle
375 + if use tk; then
376 + ln -s "../../../bin/idle${PYVER}" \
377 + "${scriptdir}/idle" || die
378 + fi
379 +}