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