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: Wed, 02 Jun 2021 08:47:48
Message-Id: 1622623658.6e7d5b8bded2614e18552378a1ded01b70702371.mgorny@gentoo
1 commit: 6e7d5b8bded2614e18552378a1ded01b70702371
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jun 2 07:50:03 2021 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Jun 2 08:47:38 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6e7d5b8b
7
8 dev-lang/python: Backport sec fixes to 3.8.10_p2
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.10_p2.ebuild | 336 ++++++++++++++++++++++++++++++++
14 2 files changed, 337 insertions(+)
15
16 diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest
17 index 89349d888da..8d709e5b5ca 100644
18 --- a/dev-lang/python/Manifest
19 +++ b/dev-lang/python/Manifest
20 @@ -26,6 +26,7 @@ DIST python-gentoo-patches-3.7.10_p3.tar.xz 16804 BLAKE2B 1db238e4b928332d459b5f
21 DIST python-gentoo-patches-3.7.10_p4.tar.xz 17076 BLAKE2B 628d82f5fc24ee68b4d529ab6d2fcaf7361d55a99dccd699a2fd027e86a731e641ff1573c7639d3d513b2030f8e8629adab84c13a9dd1ba5e2a84bdb16e92c44 SHA512 856ff2e3a73d56888bc1a3b2a28e2ca284a2a40ac3df4d060616fee47e95052b535e697d1d77c58ed850da105c7accfe3093a41492e63f6642349f7a6c80a3ea
22 DIST python-gentoo-patches-3.8.10.tar.xz 15180 BLAKE2B 1f8c57c6ed8d49c5ff42ecaaf19f470567db7fc68ed95eb44a89e9e85a542c085708207f02a1e50ebd7e6fc5e876e232ccd47f49e7653d338ec0520b7dac1a3d SHA512 65e3ec0a0fd49c0c6e96eb07c98b93ce5168e430bbfcd1e62185f6df6bd42fb1a5b5752cbe8bde93101510c0cfd37e604dde40549703b1d1c0e37d24cc327472
23 DIST python-gentoo-patches-3.8.10_p1.tar.xz 15504 BLAKE2B 63bd3e4928853a80a57ff922c42c434990b38a5c1dc639a277b8dcd01dabf1e0ff745750859b2ee47d30f84afd2bece81e4ba72b89a9ec690300de42e2a5f590 SHA512 955f7647bb05572a1f77cc8a8c35b7690ae914b9b22d30da553502ccc018b4134a7b647dd088b8b75c46a6971bf64dd750e47ceb1b3b219dd58260bf7b67860f
24 +DIST python-gentoo-patches-3.8.10_p2.tar.xz 20288 BLAKE2B 4d9db5c8d5c27673d5a026149e5678c2b4072d6d0326ae015bf4fd5b5065beeff0cd6ee0a061f79ab3258d3d156d555a38cbdca2e5e05b4405038847dcc97c8e SHA512 165a4e3b537538e792a98141a8e4af6b5cde369e6322155731ecb1b55d0e609f06208d88d68dbb1fbe59a5127ae7ac49d76d8fb6505ccf835931b2a802cd85de
25 DIST python-gentoo-patches-3.8.9_p2.tar.xz 16600 BLAKE2B 895eebdfabfe9cc4a30d87255112033b506511a8def7cecb03e37b0bde350f1c4b53f06a7e8ead53218c29e2cf4866f2ddfc9d30a07e9f5c67e4c7c271c18cba SHA512 5751c4bcdd1f637f9678d3fa3455c701b2dec051e12d5a1fa6468d7745c1387fb0485672e53dc619b4244435897f21702699c64b63ad9a0422ed91edd7fb2491
26 DIST python-gentoo-patches-3.9.4_p1.tar.xz 14472 BLAKE2B c8bd49c2eb77eb00377e6c6e63a2f6b1108a2c8d4eb45cc943ad2d0a2b4457e00002f90d2597032716af5268f33d24902d4634cf8e98778c1d15bf8dda5d7215 SHA512 9a12c1935be31b1663e4ab6c1f7aca51ba62ef4033600885678ce436ecab688e2df82742125b4885b1cb8da9c68140c5ca4ee1684360ac87d82c6491bce5d0a0
27 DIST python-gentoo-patches-3.9.5.tar.xz 8820 BLAKE2B 177234776f00c3efa6b76fefc1ef0001225ded1dd8ba916e3dc8498a7e845467bf387ba8a4f82da713a51bff627420a084f6627218863f70e1273cce58ca7252 SHA512 37b7e25a1703184556f12202da9cba1a8e2fb1c059d75195ef2997f55948229f164642a580e33c59f5877fe36d4c62f1735f95df318b36d92c528eb98f42e55f
28
29 diff --git a/dev-lang/python/python-3.8.10_p2.ebuild b/dev-lang/python/python-3.8.10_p2.ebuild
30 new file mode 100644
31 index 00000000000..0a87aec9180
32 --- /dev/null
33 +++ b/dev-lang/python/python-3.8.10_p2.ebuild
34 @@ -0,0 +1,336 @@
35 +# Copyright 1999-2021 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 ipv6 +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-libs/libffi:=
72 + sys-apps/util-linux:=
73 + >=sys-libs/zlib-1.1.3:=
74 + virtual/libcrypt:=
75 + virtual/libintl
76 + gdbm? ( sys-libs/gdbm:=[berkdb] )
77 + ncurses? ( >=sys-libs/ncurses-5.2:= )
78 + readline? ( >=sys-libs/readline-4.1:= )
79 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
80 + ssl? ( dev-libs/openssl:= )
81 + tk? (
82 + >=dev-lang/tcl-8.0:=
83 + >=dev-lang/tk-8.0:=
84 + dev-tcltk/blt:=
85 + dev-tcltk/tix
86 + )
87 + xml? ( >=dev-libs/expat-2.1:= )"
88 +# bluetooth requires headers from bluez
89 +DEPEND="${RDEPEND}
90 + bluetooth? ( net-wireless/bluez )
91 + test? ( app-arch/xz-utils[extra-filters(+)] )"
92 +BDEPEND="
93 + virtual/pkgconfig
94 + sys-devel/autoconf-archive
95 + verify-sig? ( app-crypt/openpgp-keys-python )
96 + !sys-devel/gcc[libffi(-)]"
97 +PDEPEND="app-eselect/eselect-python"
98 +RDEPEND+=" !build? ( app-misc/mime-types )"
99 +
100 +VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/python.org.asc
101 +
102 +src_unpack() {
103 + if use verify-sig; then
104 + verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc}
105 + fi
106 + default
107 +}
108 +
109 +src_prepare() {
110 + # Ensure that internal copies of expat, libffi and zlib are not used.
111 + rm -fr Modules/expat || die
112 + rm -fr Modules/_ctypes/libffi* || die
113 + rm -fr Modules/zlib || die
114 +
115 + local PATCHES=(
116 + "${WORKDIR}/${PATCHSET}"
117 + )
118 +
119 + default
120 +
121 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
122 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
123 +
124 + # force correct number of jobs
125 + # https://bugs.gentoo.org/737660
126 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
127 + sed -i -e "s:-j0:-j${jobs}:" Makefile.pre.in || die
128 + sed -i -e "/self\.parallel/s:True:${jobs}:" setup.py || die
129 +
130 + eautoreconf
131 +}
132 +
133 +src_configure() {
134 + local disable
135 + # disable automagic bluetooth headers detection
136 + use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no
137 + use gdbm || disable+=" gdbm"
138 + use ncurses || disable+=" _curses _curses_panel"
139 + use readline || disable+=" readline"
140 + use sqlite || disable+=" _sqlite3"
141 + use ssl || export PYTHON_DISABLE_SSL="1"
142 + use tk || disable+=" _tkinter"
143 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
144 + export PYTHON_DISABLE_MODULES="${disable}"
145 +
146 + if ! use xml; then
147 + ewarn "You have configured Python without XML support."
148 + ewarn "This is NOT a recommended configuration as you"
149 + ewarn "may face problems parsing any XML documents."
150 + fi
151 +
152 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
153 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
154 + fi
155 +
156 + if [[ "$(gcc-major-version)" -ge 4 ]]; then
157 + append-flags -fwrapv
158 + fi
159 +
160 + filter-flags -malign-double
161 +
162 + # https://bugs.gentoo.org/show_bug.cgi?id=50309
163 + if is-flagq -O3; then
164 + is-flagq -fstack-protector-all && replace-flags -O3 -O2
165 + use hardened && replace-flags -O3 -O2
166 + fi
167 +
168 + # https://bugs.gentoo.org/700012
169 + if is-flagq -flto || is-flagq '-flto=*'; then
170 + append-cflags $(test-flags-CC -ffat-lto-objects)
171 + fi
172 +
173 + # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
174 + tc-export CXX
175 +
176 + # Fix implicit declarations on cross and prefix builds. Bug #674070.
177 + use ncurses && append-cppflags -I"${ESYSROOT}"/usr/include/ncursesw
178 +
179 + local dbmliborder
180 + if use gdbm; then
181 + dbmliborder+="${dbmliborder:+:}gdbm"
182 + fi
183 +
184 + local myeconfargs=(
185 + # glibc-2.30 removes it; since we can't cleanly force-rebuild
186 + # Python on glibc upgrade, remove it proactively to give
187 + # a chance for users rebuilding python before glibc
188 + ac_cv_header_stropts_h=no
189 +
190 + --enable-shared
191 + $(use_enable ipv6)
192 + --infodir='${prefix}/share/info'
193 + --mandir='${prefix}/share/man'
194 + --with-computed-gotos
195 + --with-dbmliborder="${dbmliborder}"
196 + --with-libc=
197 + --enable-loadable-sqlite-extensions
198 + --without-ensurepip
199 + --with-system-expat
200 + --with-system-ffi
201 + )
202 +
203 + OPT="" 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 + emake CPPFLAGS= CFLAGS= LDFLAGS=
218 +
219 + # Work around bug 329499. See also bug 413751 and 457194.
220 + if has_version dev-libs/libffi[pax_kernel]; then
221 + pax-mark E python
222 + else
223 + pax-mark m python
224 + fi
225 +}
226 +
227 +src_test() {
228 + # Tests will not work when cross compiling.
229 + if tc-is-cross-compiler; then
230 + elog "Disabling tests due to crosscompiling."
231 + return
232 + fi
233 +
234 + # Skip failing tests.
235 + local skipped_tests="gdb"
236 +
237 + for test in ${skipped_tests}; do
238 + mv "${S}"/Lib/test/test_${test}.py "${T}"
239 + done
240 +
241 + # bug 660358
242 + local -x COLUMNS=80
243 + local -x PYTHONDONTWRITEBYTECODE=
244 +
245 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
246 +
247 + emake test EXTRATESTOPTS="-u-network -j${jobs}" \
248 + CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
249 + local result=$?
250 +
251 + for test in ${skipped_tests}; do
252 + mv "${T}/test_${test}.py" "${S}"/Lib/test
253 + done
254 +
255 + elog "The following tests have been skipped:"
256 + for test in ${skipped_tests}; do
257 + elog "test_${test}.py"
258 + done
259 +
260 + elog "If you would like to run them, you may:"
261 + elog "cd '${EPREFIX}/usr/lib/python${PYVER}/test'"
262 + elog "and run the tests separately."
263 +
264 + if [[ ${result} -ne 0 ]]; then
265 + die "emake test failed"
266 + fi
267 +}
268 +
269 +src_install() {
270 + local libdir=${ED}/usr/lib/python${PYVER}
271 +
272 + emake DESTDIR="${D}" altinstall
273 +
274 + # Remove static library
275 + rm "${ED}"/usr/$(get_libdir)/libpython*.a || die
276 +
277 + sed \
278 + -e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" \
279 + -e "s/\(PY_LDFLAGS=\).*/\1/" \
280 + -i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed"
281 +
282 + # Fix collisions between different slots of Python.
283 + rm "${ED}/usr/$(get_libdir)/libpython3.so" || die
284 +
285 + # Cheap hack to get version with ABIFLAGS
286 + local abiver=$(cd "${ED}/usr/include"; echo python*)
287 + if [[ ${abiver} != python${PYVER} ]]; then
288 + # Replace python3.X with a symlink to python3.Xm
289 + rm "${ED}/usr/bin/python${PYVER}" || die
290 + dosym "${abiver}" "/usr/bin/python${PYVER}"
291 + # Create python3.X-config symlink
292 + dosym "${abiver}-config" "/usr/bin/python${PYVER}-config"
293 + # Create python-3.5m.pc symlink
294 + dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc"
295 + fi
296 +
297 + # python seems to get rebuilt in src_install (bug 569908)
298 + # Work around it for now.
299 + if has_version dev-libs/libffi[pax_kernel]; then
300 + pax-mark E "${ED}/usr/bin/${abiver}"
301 + else
302 + pax-mark m "${ED}/usr/bin/${abiver}"
303 + fi
304 +
305 + use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
306 + use tk || rm -r "${ED}/usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*} || die
307 +
308 + use wininst || rm "${libdir}/distutils/command/"wininst-*.exe || die
309 +
310 + dodoc Misc/{ACKS,HISTORY,NEWS}
311 +
312 + if use examples; then
313 + docinto examples
314 + find Tools -name __pycache__ -exec rm -fr {} + || die
315 + dodoc -r Tools
316 + fi
317 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
318 + local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
319 + emake --no-print-directory -s -f - 2>/dev/null)
320 + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
321 +
322 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
323 + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
324 + sed \
325 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
326 + -e "s:@PYDOC@:pydoc${PYVER}:" \
327 + -i "${ED}/etc/conf.d/pydoc-${PYVER}" \
328 + "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed"
329 +
330 + local -x EPYTHON=python${PYVER}
331 + # if not using a cross-compiler, use the fresh binary
332 + if ! tc-is-cross-compiler; then
333 + local -x PYTHON=./python
334 + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD}
335 + else
336 + local -x PYTHON=${EPREFIX}/usr/bin/${EPYTHON}
337 + fi
338 +
339 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
340 + python_domodule epython.py
341 +
342 + # python-exec wrapping support
343 + local pymajor=${PYVER%.*}
344 + local scriptdir=${D}$(python_get_scriptdir)
345 + mkdir -p "${scriptdir}" || die
346 + # python and pythonX
347 + ln -s "../../../bin/${abiver}" \
348 + "${scriptdir}/python${pymajor}" || die
349 + ln -s "python${pymajor}" "${scriptdir}/python" || die
350 + # python-config and pythonX-config
351 + # note: we need to create a wrapper rather than symlinking it due
352 + # to some random dirname(argv[0]) magic performed by python-config
353 + cat > "${scriptdir}/python${pymajor}-config" <<-EOF || die
354 + #!/bin/sh
355 + exec "${abiver}-config" "\${@}"
356 + EOF
357 + chmod +x "${scriptdir}/python${pymajor}-config" || die
358 + ln -s "python${pymajor}-config" \
359 + "${scriptdir}/python-config" || die
360 + # 2to3, pydoc
361 + ln -s "../../../bin/2to3-${PYVER}" \
362 + "${scriptdir}/2to3" || die
363 + ln -s "../../../bin/pydoc${PYVER}" \
364 + "${scriptdir}/pydoc" || die
365 + # idle
366 + if use tk; then
367 + ln -s "../../../bin/idle${PYVER}" \
368 + "${scriptdir}/idle" || die
369 + fi
370 +}