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: Tue, 31 Aug 2021 08:17:49
Message-Id: 1630397863.4cdeebe398acb3725f5feb70556b8d33bb596d4a.mgorny@gentoo
1 commit: 4cdeebe398acb3725f5feb70556b8d33bb596d4a
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Tue Aug 31 08:03:57 2021 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue Aug 31 08:17:43 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4cdeebe3
7
8 dev-lang/python: Backport secfixes to 2.7.18_p12
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 dev-lang/python/Manifest | 1 +
13 dev-lang/python/python-2.7.18_p12.ebuild | 354 +++++++++++++++++++++++++++++++
14 2 files changed, 355 insertions(+)
15
16 diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest
17 index 2f312db284c..c2318578594 100644
18 --- a/dev-lang/python/Manifest
19 +++ b/dev-lang/python/Manifest
20 @@ -15,6 +15,7 @@ DIST Python-3.9.6.tar.xz.asc 833 BLAKE2B 41901bfb80a901f2f14e86769e6d08ded8f7565
21 DIST Python-3.9.7.tar.xz 19123232 BLAKE2B 69dfba6974c8c74de1b71977d28cad4d7c26615695f48a99444d2eb83d657b4bd8d22e7f6e94b1b2dcbcc5605c0aee08c609b9564e306f48588e2a7f471209b2 SHA512 55139776ab58a40f9e1e70613d7071d559ef9e51e32a77791422aac134322c21a49f0348c42813214b69789c589367eae43e16d4ae838a73daf37617e966b735
22 DIST Python-3.9.7.tar.xz.asc 833 BLAKE2B 2d9c47e47d9a625e393a8b456dd5b10dd485fc13ca7c236b5fd304c373879bea8ab3c67ff99c3a81350443f6ccba20718466a221a05faada6b82cfe92943fdbf SHA512 7ff9f845f520efab3b4a0e95da3ffe055ee5777a4173a5b2cc1fd2419dc2b4faf30d1e711e372df36e34bc971ecfcde88a7cd815cfe2d8080ccb575a1ae8e101
23 DIST python-gentoo-patches-2.7.18_p11.tar.xz 31340 BLAKE2B bdc097b971ab8ec0b60f944002af34f3fff6b681c43515a4fec2fcac1a2c731bf4fcfae2178463103911e2f8cd6bc84d3b56cd0ad61da5c8276278ec9b85a242 SHA512 2a2388c4543267bfb0167f963a22f5141442c9347d9a8806ad6917843e6958d47c8f1933244651c870101b21408c920408fe056efb7a148117c24ab391151d88
24 +DIST python-gentoo-patches-2.7.18_p12.tar.xz 33308 BLAKE2B 68022a32640a8b790ddbe36d865c9ff504d9af9382263160deae8eef28f06487843f24fc6a19788c113de204205908a542bf8d3b9d74d2c114debaa03b7584e0 SHA512 753404374f8917498766ce7d1f9c78807636d06fb8943599eb72f38f8e1ec33bd64e404d031ea7dadbd5134f9fb8575bbe4c9067db08f44488af17f40a74f175
25 DIST python-gentoo-patches-3.10.0rc1_p1.tar.xz 8496 BLAKE2B b3b771a8894e5bfeabb3bee10cf60c068dca28341784f0914bb2190f67f10007c2e4e3b18dc31ac7dd791e06314cd3f8cda6776261c6e83da380c492bbc53e89 SHA512 bb22cc121d3b915b98de32244926188dd9717054f32437822a59652be001ac3b6309cb1aba79ce158a486d33e761a31861aed56b5a7976bc83aee18174903248
26 DIST python-gentoo-patches-3.10.0rc1_p2.tar.xz 10548 BLAKE2B b0a78e3b5e45ead483391c4382c3d6046b4a03e43c1ab5fcd1569f05afc271dde6278078cec852756364663111c38f0ecedca99ef2f2bb233714406505ed8e79 SHA512 1e0129903a3756b6ab087b982269197b64028432f81592b887d8431f429f864918eaa611c7b671e303de7603fd835fb4563219fedd3ee1dbd42e843e66d4fccd
27 DIST python-gentoo-patches-3.6.14.tar.xz 14744 BLAKE2B b9482f9d2b7ada60eff9a5672ed21556c00b473a7cfdb543dce8253fb0ff1539e635a35569478c496012ecde4eef78a257da28f7a80bff99da10249708262229 SHA512 246f83911c8e52ea83a9bf453faa0bc0ea0c29bbf3b666a938e3790c6147f71e617ff9cb27501c5f0b89172eb9e7819e3f2ef0a5bae271cc938d2c0c2b93f7ae
28
29 diff --git a/dev-lang/python/python-2.7.18_p12.ebuild b/dev-lang/python/python-2.7.18_p12.ebuild
30 new file mode 100644
31 index 00000000000..dfa49704adf
32 --- /dev/null
33 +++ b/dev-lang/python/python-2.7.18_p12.ebuild
34 @@ -0,0 +1,354 @@
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 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}"
59 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
60 +IUSE="berkdb bluetooth build elibc_uclibc examples gdbm hardened ipv6 +ncurses +readline +sqlite +ssl +threads tk +wide-unicode wininst +xml"
61 +
62 +# Do not add a dependency on dev-lang/python to this ebuild.
63 +# If you need to apply a patch which requires python for bootstrapping, please
64 +# run the bootstrap code on your dev box and include the results in the
65 +# patchset. See bug 447752.
66 +
67 +RDEPEND="app-arch/bzip2:=
68 + dev-libs/libffi:=
69 + >=sys-libs/zlib-1.1.3:=
70 + virtual/libcrypt:=
71 + virtual/libintl
72 + berkdb? ( || (
73 + sys-libs/db:5.3
74 + sys-libs/db:5.1
75 + sys-libs/db:4.8
76 + sys-libs/db:4.7
77 + sys-libs/db:4.6
78 + sys-libs/db:4.5
79 + sys-libs/db:4.4
80 + sys-libs/db:4.3
81 + sys-libs/db:4.2
82 + ) )
83 + gdbm? ( sys-libs/gdbm:=[berkdb] )
84 + ncurses? ( >=sys-libs/ncurses-5.2:= )
85 + readline? ( >=sys-libs/readline-4.1:= )
86 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
87 + ssl? ( dev-libs/openssl:= )
88 + tk? (
89 + >=dev-lang/tcl-8.0:=
90 + >=dev-lang/tk-8.0:=
91 + dev-tcltk/blt:=
92 + dev-tcltk/tix
93 + )
94 + xml? ( >=dev-libs/expat-2.1:= )"
95 +# bluetooth requires headers from bluez
96 +DEPEND="${RDEPEND}
97 + bluetooth? ( net-wireless/bluez )"
98 +BDEPEND="
99 + virtual/pkgconfig
100 + verify-sig? ( app-crypt/openpgp-keys-python )
101 + !sys-devel/gcc[libffi(-)]"
102 +RDEPEND+="
103 + !build? ( app-misc/mime-types )
104 + !<=dev-lang/python-exec-2.4.6-r1"
105 +
106 +VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/python.org.asc
107 +
108 +pkg_setup() {
109 + if use berkdb; then
110 + ewarn "'bsddb' module is out-of-date and no longer maintained inside"
111 + ewarn "dev-lang/python. 'bsddb' and 'dbhash' modules have been additionally"
112 + ewarn "removed in Python 3. A maintained alternative of 'bsddb3' module"
113 + ewarn "is provided by dev-python/bsddb3."
114 + else
115 + if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then
116 + ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"
117 + ewarn "to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
118 + ewarn "You might need to migrate your databases."
119 + fi
120 + fi
121 +}
122 +
123 +src_unpack() {
124 + if use verify-sig; then
125 + verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc}
126 + fi
127 + default
128 +}
129 +
130 +src_prepare() {
131 + # Ensure that internal copies of expat, libffi and zlib are not used.
132 + rm -fr Modules/expat || die
133 + rm -fr Modules/_ctypes/libffi* || die
134 + rm -fr Modules/zlib || die
135 +
136 + local PATCHES=(
137 + "${WORKDIR}/${PATCHSET}"
138 + )
139 +
140 + default
141 +
142 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
143 + Lib/distutils/command/install.py \
144 + Lib/distutils/sysconfig.py \
145 + Lib/site.py \
146 + Lib/sysconfig.py \
147 + Lib/test/test_site.py \
148 + Makefile.pre.in \
149 + Modules/Setup.dist \
150 + Modules/getpath.c \
151 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
152 +
153 + eautoreconf
154 +}
155 +
156 +src_configure() {
157 + # dbm module can be linked against berkdb or gdbm.
158 + # Defaults to gdbm when both are enabled, #204343.
159 + local disable
160 + use berkdb || use gdbm || disable+=" dbm"
161 + use berkdb || disable+=" _bsddb"
162 + # disable automagic bluetooth headers detection
163 + use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no
164 + use gdbm || disable+=" gdbm"
165 + use ncurses || disable+=" _curses _curses_panel"
166 + use readline || disable+=" readline"
167 + use sqlite || disable+=" _sqlite3"
168 + use ssl || export PYTHON_DISABLE_SSL="1"
169 + use tk || disable+=" _tkinter"
170 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
171 + export PYTHON_DISABLE_MODULES="${disable}"
172 +
173 + if ! use xml; then
174 + ewarn "You have configured Python without XML support."
175 + ewarn "This is NOT a recommended configuration as you"
176 + ewarn "may face problems parsing any XML documents."
177 + fi
178 +
179 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
180 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
181 + fi
182 +
183 + if [[ "$(gcc-major-version)" -ge 4 ]]; then
184 + append-flags -fwrapv
185 + fi
186 +
187 + filter-flags -malign-double
188 +
189 + # https://bugs.gentoo.org/show_bug.cgi?id=50309
190 + if is-flagq -O3; then
191 + is-flagq -fstack-protector-all && replace-flags -O3 -O2
192 + use hardened && replace-flags -O3 -O2
193 + fi
194 +
195 + if tc-is-cross-compiler; then
196 + # Force some tests that try to poke fs paths.
197 + export ac_cv_file__dev_ptc=no
198 + export ac_cv_file__dev_ptmx=yes
199 + fi
200 +
201 + # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.
202 + tc-export CXX
203 + # The configure script fails to use pkg-config correctly.
204 + # http://bugs.python.org/issue15506
205 + export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG)
206 +
207 + local dbmliborder
208 + if use gdbm; then
209 + dbmliborder+="${dbmliborder:+:}gdbm"
210 + fi
211 + if use berkdb; then
212 + dbmliborder+="${dbmliborder:+:}bdb"
213 + fi
214 +
215 + local myeconfargs=(
216 + # The check is broken on clang, and gives false positive:
217 + # https://bugs.gentoo.org/596798
218 + # (upstream dropped this flag in 3.2a4 anyway)
219 + ac_cv_opt_olimit_ok=no
220 + # glibc-2.30 removes it; since we can't cleanly force-rebuild
221 + # Python on glibc upgrade, remove it proactively to give
222 + # a chance for users rebuilding python before glibc
223 + ac_cv_header_stropts_h=no
224 +
225 + --with-fpectl
226 + --enable-shared
227 + $(use_enable ipv6)
228 + $(use_with threads)
229 + $(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2")
230 + --infodir='${prefix}/share/info'
231 + --mandir='${prefix}/share/man'
232 + --with-computed-gotos
233 + --with-dbmliborder="${dbmliborder}"
234 + --with-libc=
235 + --enable-loadable-sqlite-extensions
236 + --with-system-expat
237 + --with-system-ffi
238 + --without-ensurepip
239 + )
240 +
241 + OPT="" econf "${myeconfargs[@]}"
242 +
243 + if use threads && grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
244 + eerror "configure has detected that the sem_open function is broken."
245 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
246 + die "Broken sem_open function (bug 496328)"
247 + fi
248 +}
249 +
250 +src_compile() {
251 + # Ensure sed works as expected
252 + # https://bugs.gentoo.org/594768
253 + local -x LC_ALL=C
254 +
255 + # Avoid invoking pgen for cross-compiles.
256 + touch Include/graminit.h Python/graminit.c
257 +
258 + emake
259 +
260 + # Work around bug 329499. See also bug 413751 and 457194.
261 + if has_version dev-libs/libffi[pax-kernel]; then
262 + pax-mark E python
263 + else
264 + pax-mark m python
265 + fi
266 +}
267 +
268 +src_test() {
269 + # Tests will not work when cross compiling.
270 + if tc-is-cross-compiler; then
271 + elog "Disabling tests due to crosscompiling."
272 + return
273 + fi
274 +
275 + # Skip failing tests.
276 + local skipped_tests="distutils gdb"
277 +
278 + for test in ${skipped_tests}; do
279 + mv "${S}"/Lib/test/test_${test}.py "${T}"
280 + done
281 +
282 + # bug 660358
283 + local -x COLUMNS=80
284 +
285 + # Daylight saving time problem
286 + # https://bugs.python.org/issue22067
287 + # https://bugs.gentoo.org/610628
288 + local -x TZ=UTC
289 +
290 + # Rerun failed tests in verbose mode (regrtest -w).
291 + emake test EXTRATESTOPTS="-w" < /dev/tty
292 + local result="$?"
293 +
294 + for test in ${skipped_tests}; do
295 + mv "${T}/test_${test}.py" "${S}"/Lib/test
296 + done
297 +
298 + elog "The following tests have been skipped:"
299 + for test in ${skipped_tests}; do
300 + elog "test_${test}.py"
301 + done
302 +
303 + elog "If you would like to run them, you may:"
304 + elog "cd '${EPREFIX}/usr/$(get_libdir)/python${PYVER}/test'"
305 + elog "and run the tests separately."
306 +
307 + if [[ ${result} -ne 0 ]]; then
308 + die "emake test failed"
309 + fi
310 +}
311 +
312 +src_install() {
313 + local libdir=${ED}/usr/$(get_libdir)/python${PYVER}
314 +
315 + emake DESTDIR="${D}" altinstall
316 +
317 + sed -e "s/\(LDFLAGS=\).*/\1/" -i "${libdir}/config/Makefile" || die
318 +
319 + # Fix collisions between different slots of Python.
320 + mv "${ED}/usr/bin/2to3" "${ED}/usr/bin/2to3-${PYVER}" || die
321 + mv "${ED}/usr/bin/pydoc" "${ED}/usr/bin/pydoc${PYVER}" || die
322 + mv "${ED}/usr/bin/idle" "${ED}/usr/bin/idle${PYVER}" || die
323 + rm "${ED}/usr/bin/smtpd.py" || die
324 +
325 + use berkdb || rm -r "${libdir}/"{bsddb,dbhash.py*,test/test_bsddb*} || die
326 + use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
327 + use tk || rm -r "${ED}/usr/bin/idle${PYVER}" "${libdir}/"{idlelib,lib-tk} || die
328 + use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test}
329 +
330 + use threads || rm -r "${libdir}/multiprocessing" || die
331 + use wininst || rm "${libdir}/distutils/command/"wininst-*.exe || die
332 +
333 + dodoc Misc/{ACKS,HISTORY,NEWS}
334 +
335 + if use examples; then
336 + docinto examples
337 + dodoc -r Tools
338 + fi
339 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
340 + local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
341 + emake --no-print-directory -s -f - 2>/dev/null)
342 + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
343 +
344 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
345 + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
346 + sed \
347 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
348 + -e "s:@PYDOC@:pydoc${PYVER}:" \
349 + -i "${ED}/etc/conf.d/pydoc-${PYVER}" \
350 + "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed"
351 +
352 + local -x EPYTHON=python${PYVER}
353 + # if not using a cross-compiler, use the fresh binary
354 + if ! tc-is-cross-compiler; then
355 + local -x PYTHON=./python
356 + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD}
357 + else
358 + local -x PYTHON=${EPREFIX}/usr/bin/${EPYTHON}
359 + fi
360 +
361 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
362 + python_domodule epython.py
363 +
364 + # python-exec wrapping support
365 + local scriptdir=${D}$(python_get_scriptdir)
366 + mkdir -p "${scriptdir}" || die
367 + # python
368 + ln -s "../../../bin/python${PYVER}" \
369 + "${scriptdir}/python" || die
370 + # python-config
371 + ln -s "../../../bin/python${PYVER}-config" \
372 + "${scriptdir}/python-config" || die
373 + # 2to3, pydoc, pyvenv
374 + ln -s "../../../bin/2to3-${PYVER}" \
375 + "${scriptdir}/2to3" || die
376 + ln -s "../../../bin/pydoc${PYVER}" \
377 + "${scriptdir}/pydoc" || die
378 + # idle
379 + if use tk; then
380 + ln -s "../../../bin/idle${PYVER}" \
381 + "${scriptdir}/idle" || die
382 + fi
383 +
384 + # python2* is no longer wrapped, so just symlink it
385 + local pymajor=${PYVER%.*}
386 + dosym "python${PYVER}" "/usr/bin/python${pymajor}"
387 + dosym "python${PYVER}-config" "/usr/bin/python${pymajor}-config"
388 +}