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