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