Gentoo Archives: gentoo-commits

From: Quentin Retornaz <gentoo@××××××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/libressl:master commit in: dev-lang/python/
Date: Sat, 15 Jan 2022 19:13:06
Message-Id: 1642273902.901c15e38941bb77c57d97e1fd3ee8ad03ebe2b2.quentin@gentoo
1 commit: 901c15e38941bb77c57d97e1fd3ee8ad03ebe2b2
2 Author: orbea <orbea <AT> riseup <DOT> net>
3 AuthorDate: Sat Jan 15 02:38:11 2022 +0000
4 Commit: Quentin Retornaz <gentoo <AT> retornaz <DOT> com>
5 CommitDate: Sat Jan 15 19:11:42 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/libressl.git/commit/?id=901c15e3
7
8 dev-lang/python: Updated for 3.9.9-r1
9
10 Signed-off-by: orbea <orbea <AT> riseup.net>
11 Signed-off-by: Quentin Retornaz <gentoo <AT> retornaz.com>
12
13 dev-lang/python/python-3.9.9-r1.ebuild | 377 +++++++++++++++++++++++++++++++++
14 1 file changed, 377 insertions(+)
15
16 diff --git a/dev-lang/python/python-3.9.9-r1.ebuild b/dev-lang/python/python-3.9.9-r1.ebuild
17 new file mode 100644
18 index 0000000..0371630
19 --- /dev/null
20 +++ b/dev-lang/python/python-3.9.9-r1.ebuild
21 @@ -0,0 +1,377 @@
22 +# Copyright 1999-2022 Gentoo Authors
23 +# Distributed under the terms of the GNU General Public License v2
24 +
25 +EAPI="7"
26 +WANT_LIBTOOL="none"
27 +
28 +inherit autotools check-reqs flag-o-matic multiprocessing pax-utils \
29 + python-utils-r1 toolchain-funcs verify-sig
30 +
31 +MY_PV=${PV/_rc/rc}
32 +MY_P="Python-${MY_PV%_p*}"
33 +PYVER=$(ver_cut 1-2)
34 +PATCHSET="python-gentoo-patches-${MY_PV}"
35 +
36 +DESCRIPTION="An interpreted, interactive, object-oriented programming language"
37 +HOMEPAGE="https://www.python.org/"
38 +SRC_URI="https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz
39 + https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz
40 + verify-sig? (
41 + https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz.asc
42 + )"
43 +S="${WORKDIR}/${MY_P}"
44 +
45 +LICENSE="PSF-2"
46 +SLOT="${PYVER}"
47 +KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
48 +IUSE="bluetooth build examples gdbm hardened lto +ncurses pgo +readline +sqlite +ssl test tk wininst +xml"
49 +RESTRICT="!test? ( test )"
50 +
51 +# Do not add a dependency on dev-lang/python to this ebuild.
52 +# If you need to apply a patch which requires python for bootstrapping, please
53 +# run the bootstrap code on your dev box and include the results in the
54 +# patchset. See bug 447752.
55 +
56 +RDEPEND="app-arch/bzip2:=
57 + app-arch/xz-utils:=
58 + dev-lang/python-exec[python_targets_python3_9(-)]
59 + dev-libs/libffi:=
60 + sys-apps/util-linux:=
61 + >=sys-libs/zlib-1.1.3:=
62 + virtual/libcrypt:=
63 + virtual/libintl
64 + gdbm? ( sys-libs/gdbm:=[berkdb] )
65 + ncurses? ( >=sys-libs/ncurses-5.2:= )
66 + readline? ( >=sys-libs/readline-4.1:= )
67 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
68 + ssl? ( >=dev-libs/openssl-1.1.1:= )
69 + tk? (
70 + >=dev-lang/tcl-8.0:=
71 + >=dev-lang/tk-8.0:=
72 + dev-tcltk/blt:=
73 + dev-tcltk/tix
74 + )
75 + xml? ( >=dev-libs/expat-2.1:= )"
76 +# bluetooth requires headers from bluez
77 +DEPEND="${RDEPEND}
78 + bluetooth? ( net-wireless/bluez )
79 + test? ( app-arch/xz-utils[extra-filters(+)] )"
80 +BDEPEND="
81 + virtual/awk
82 + virtual/pkgconfig
83 + sys-devel/autoconf-archive
84 + verify-sig? ( sec-keys/openpgp-keys-python )
85 + !sys-devel/gcc[libffi(-)]"
86 +RDEPEND+=" !build? ( app-misc/mime-types )"
87 +
88 +VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/python.org.asc
89 +
90 +# large file tests involve a 2.5G file being copied (duplicated)
91 +CHECKREQS_DISK_BUILD=5500M
92 +
93 +pkg_pretend() {
94 + use test && check-reqs_pkg_pretend
95 +}
96 +
97 +pkg_setup() {
98 + use test && check-reqs_pkg_setup
99 +}
100 +
101 +src_unpack() {
102 + if use verify-sig; then
103 + verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc}
104 + fi
105 + default
106 +}
107 +
108 +src_prepare() {
109 + # Ensure that internal copies of expat, libffi and zlib are not used.
110 + rm -fr Modules/expat || die
111 + rm -fr Modules/_ctypes/libffi* || die
112 + rm -fr Modules/zlib || die
113 +
114 + rm -f "${WORKDIR}/${PATCHSET}"/0013-bpo-43998-Default-to-TLS-1.2-and-increase-cipher-sui.patch || 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 + if use pgo; then
186 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
187 + export PROFILE_TASK="-m test -j${jobs} --pgo-extended -x test_gdb -u-network"
188 +
189 + # All of these seem to occasionally hang for PGO inconsistently
190 + # They'll even hang here but be fine in src_test sometimes.
191 + # bug #828535 (and related: bug #788022)
192 + PROFILE_TASK+=" -x test_socket -x test_asyncio -x test_httpservers -x test_logging -x test_multiprocessing_fork -x test_xmlrpc"
193 +
194 + if has_version "app-arch/rpm" ; then
195 + # Avoid sandbox failure (attempts to write to /var/lib/rpm)
196 + PROFILE_TASK+=" -x test_distutils"
197 + fi
198 + fi
199 +
200 + local myeconfargs=(
201 + # glibc-2.30 removes it; since we can't cleanly force-rebuild
202 + # Python on glibc upgrade, remove it proactively to give
203 + # a chance for users rebuilding python before glibc
204 + ac_cv_header_stropts_h=no
205 +
206 + --enable-shared
207 + --enable-ipv6
208 + --infodir='${prefix}/share/info'
209 + --mandir='${prefix}/share/man'
210 + --with-computed-gotos
211 + --with-dbmliborder="${dbmliborder}"
212 + --with-libc=
213 + --enable-loadable-sqlite-extensions
214 + --without-ensurepip
215 + --with-system-expat
216 + --with-system-ffi
217 +
218 + $(use_with lto)
219 + $(use_enable pgo optimizations)
220 + )
221 +
222 + OPT="" econf "${myeconfargs[@]}"
223 +
224 + if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
225 + eerror "configure has detected that the sem_open function is broken."
226 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
227 + die "Broken sem_open function (bug 496328)"
228 + fi
229 +}
230 +
231 +src_compile() {
232 + # Ensure sed works as expected
233 + # https://bugs.gentoo.org/594768
234 + local -x LC_ALL=C
235 + # Prevent using distutils bundled by setuptools.
236 + # https://bugs.gentoo.org/823728
237 + export SETUPTOOLS_USE_DISTUTILS=stdlib
238 +
239 + if use pgo ; then
240 + # bug 660358
241 + local -x COLUMNS=80
242 + local -x PYTHONDONTWRITEBYTECODE=
243 +
244 + addpredict /usr/lib/python3.9/site-packages
245 + fi
246 +
247 + emake CPPFLAGS= CFLAGS= LDFLAGS=
248 +
249 + # Work around bug 329499. See also bug 413751 and 457194.
250 + if has_version dev-libs/libffi[pax-kernel]; then
251 + pax-mark E python
252 + else
253 + pax-mark m python
254 + fi
255 +}
256 +
257 +src_test() {
258 + # Tests will not work when cross compiling.
259 + if tc-is-cross-compiler; then
260 + elog "Disabling tests due to crosscompiling."
261 + return
262 + fi
263 +
264 + # Skip failing tests.
265 + local skipped_tests="gdb"
266 +
267 + for test in ${skipped_tests}; do
268 + mv "${S}"/Lib/test/test_${test}.py "${T}"
269 + done
270 +
271 + # bug 660358
272 + local -x COLUMNS=80
273 + local -x PYTHONDONTWRITEBYTECODE=
274 +
275 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
276 +
277 + emake test EXTRATESTOPTS="-u-network -j${jobs}" \
278 + CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
279 + local result=$?
280 +
281 + for test in ${skipped_tests}; do
282 + mv "${T}/test_${test}.py" "${S}"/Lib/test
283 + done
284 +
285 + elog "The following tests have been skipped:"
286 + for test in ${skipped_tests}; do
287 + elog "test_${test}.py"
288 + done
289 +
290 + elog "If you would like to run them, you may:"
291 + elog "cd '${EPREFIX}/usr/lib/python${PYVER}/test'"
292 + elog "and run the tests separately."
293 +
294 + if [[ ${result} -ne 0 ]]; then
295 + die "emake test failed"
296 + fi
297 +}
298 +
299 +src_install() {
300 + local libdir=${ED}/usr/lib/python${PYVER}
301 +
302 + emake DESTDIR="${D}" altinstall
303 +
304 + # Remove static library
305 + rm "${ED}"/usr/$(get_libdir)/libpython*.a || die
306 +
307 + sed \
308 + -e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" \
309 + -e "s/\(PY_LDFLAGS=\).*/\1/" \
310 + -i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed"
311 +
312 + # Fix collisions between different slots of Python.
313 + rm "${ED}/usr/$(get_libdir)/libpython3.so" || die
314 +
315 + # Cheap hack to get version with ABIFLAGS
316 + local abiver=$(cd "${ED}/usr/include"; echo python*)
317 + if [[ ${abiver} != python${PYVER} ]]; then
318 + # Replace python3.X with a symlink to python3.Xm
319 + rm "${ED}/usr/bin/python${PYVER}" || die
320 + dosym "${abiver}" "/usr/bin/python${PYVER}"
321 + # Create python3.X-config symlink
322 + dosym "${abiver}-config" "/usr/bin/python${PYVER}-config"
323 + # Create python-3.5m.pc symlink
324 + dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc"
325 + fi
326 +
327 + # python seems to get rebuilt in src_install (bug 569908)
328 + # Work around it for now.
329 + if has_version dev-libs/libffi[pax-kernel]; then
330 + pax-mark E "${ED}/usr/bin/${abiver}"
331 + else
332 + pax-mark m "${ED}/usr/bin/${abiver}"
333 + fi
334 +
335 + use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
336 + use tk || rm -r "${ED}/usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*} || die
337 +
338 + dodoc Misc/{ACKS,HISTORY,NEWS}
339 +
340 + if use examples; then
341 + docinto examples
342 + find Tools -name __pycache__ -exec rm -fr {} + || die
343 + dodoc -r Tools
344 + fi
345 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
346 + local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
347 + emake --no-print-directory -s -f - 2>/dev/null)
348 + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
349 +
350 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
351 + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
352 + sed \
353 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
354 + -e "s:@PYDOC@:pydoc${PYVER}:" \
355 + -i "${ED}/etc/conf.d/pydoc-${PYVER}" \
356 + "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed"
357 +
358 + local -x EPYTHON=python${PYVER}
359 + # if not using a cross-compiler, use the fresh binary
360 + if ! tc-is-cross-compiler; then
361 + local -x PYTHON=./python
362 + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD}
363 + else
364 + local -x PYTHON=${EPREFIX}/usr/bin/${EPYTHON}
365 + fi
366 +
367 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
368 + python_domodule epython.py
369 +
370 + # python-exec wrapping support
371 + local pymajor=${PYVER%.*}
372 + local scriptdir=${D}$(python_get_scriptdir)
373 + mkdir -p "${scriptdir}" || die
374 + # python and pythonX
375 + ln -s "../../../bin/${abiver}" \
376 + "${scriptdir}/python${pymajor}" || die
377 + ln -s "python${pymajor}" "${scriptdir}/python" || die
378 + # python-config and pythonX-config
379 + # note: we need to create a wrapper rather than symlinking it due
380 + # to some random dirname(argv[0]) magic performed by python-config
381 + cat > "${scriptdir}/python${pymajor}-config" <<-EOF || die
382 + #!/bin/sh
383 + exec "${abiver}-config" "\${@}"
384 + EOF
385 + chmod +x "${scriptdir}/python${pymajor}-config" || die
386 + ln -s "python${pymajor}-config" \
387 + "${scriptdir}/python-config" || die
388 + # 2to3, pydoc
389 + ln -s "../../../bin/2to3-${PYVER}" \
390 + "${scriptdir}/2to3" || die
391 + ln -s "../../../bin/pydoc${PYVER}" \
392 + "${scriptdir}/pydoc" || die
393 + # idle
394 + if use tk; then
395 + ln -s "../../../bin/idle${PYVER}" \
396 + "${scriptdir}/idle" || die
397 + fi
398 +}