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, 24 Jan 2022 22:14:15
Message-Id: 1643062176.1f8b1370d91c1f1c2322cdedde542c63869a654b.mgorny@gentoo
1 commit: 1f8b1370d91c1f1c2322cdedde542c63869a654b
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 24 14:29:02 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 24 22:09:36 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1f8b1370
7
8 dev-lang/python: Fix hardcoding C/FLAGS in Python 3.6
9
10 Closes: https://bugs.gentoo.org/831901
11 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
12
13 dev-lang/python/python-3.6.15-r1.ebuild | 342 ++++++++++++++++++++++++++++++++
14 1 file changed, 342 insertions(+)
15
16 diff --git a/dev-lang/python/python-3.6.15-r1.ebuild b/dev-lang/python/python-3.6.15-r1.ebuild
17 new file mode 100644
18 index 000000000000..55fe23a77484
19 --- /dev/null
20 +++ b/dev-lang/python/python-3.6.15-r1.ebuild
21 @@ -0,0 +1,342 @@
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 flag-o-matic multiprocessing pax-utils \
29 + python-utils-r1 toolchain-funcs verify-sig
30 +
31 +MY_P="Python-${PV%_p*}"
32 +PYVER=$(ver_cut 1-2)
33 +PATCHSET="python-gentoo-patches-${PV}"
34 +
35 +DESCRIPTION="An interpreted, interactive, object-oriented programming language"
36 +HOMEPAGE="https://www.python.org/"
37 +SRC_URI="https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz
38 + https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz
39 + verify-sig? (
40 + https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz.asc
41 + )"
42 +S="${WORKDIR}/${MY_P}"
43 +
44 +LICENSE="PSF-2"
45 +SLOT="${PYVER}/${PYVER}m"
46 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
47 +IUSE="bluetooth build examples gdbm hardened +ncurses +readline +sqlite +ssl test tk wininst +xml"
48 +RESTRICT="!test? ( test )"
49 +
50 +# Do not add a dependency on dev-lang/python to this ebuild.
51 +# If you need to apply a patch which requires python for bootstrapping, please
52 +# run the bootstrap code on your dev box and include the results in the
53 +# patchset. See bug 447752.
54 +
55 +RDEPEND="app-arch/bzip2:=
56 + app-arch/xz-utils:=
57 + dev-libs/libffi:=
58 + >=sys-libs/zlib-1.1.3:=
59 + virtual/libcrypt:=
60 + virtual/libintl
61 + gdbm? ( sys-libs/gdbm:=[berkdb] )
62 + ncurses? ( >=sys-libs/ncurses-5.2:= )
63 + readline? ( >=sys-libs/readline-4.1:= )
64 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
65 + ssl? ( dev-libs/openssl:= )
66 + tk? (
67 + >=dev-lang/tcl-8.0:=
68 + >=dev-lang/tk-8.0:=
69 + dev-tcltk/blt:=
70 + dev-tcltk/tix
71 + )
72 + xml? ( >=dev-libs/expat-2.1:= )"
73 +# bluetooth requires headers from bluez
74 +DEPEND="${RDEPEND}
75 + bluetooth? ( net-wireless/bluez )
76 + test? ( app-arch/xz-utils[extra-filters(+)] )"
77 +BDEPEND="
78 + virtual/awk
79 + virtual/pkgconfig
80 + verify-sig? ( sec-keys/openpgp-keys-python )
81 + !sys-devel/gcc[libffi(-)]"
82 +RDEPEND+=" !build? ( app-misc/mime-types )"
83 +
84 +VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/python.org.asc
85 +
86 +src_unpack() {
87 + if use verify-sig; then
88 + verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc}
89 + fi
90 + default
91 +}
92 +
93 +src_prepare() {
94 + # Ensure that internal copies of expat, libffi and zlib are not used.
95 + rm -fr Modules/expat || die
96 + rm -fr Modules/_ctypes/libffi* || die
97 + rm -fr Modules/zlib || die
98 +
99 + local PATCHES=(
100 + "${WORKDIR}/${PATCHSET}"
101 + )
102 +
103 + default
104 +
105 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
106 + Lib/distutils/command/install.py \
107 + Lib/distutils/sysconfig.py \
108 + Lib/site.py \
109 + Lib/sysconfig.py \
110 + Lib/test/test_site.py \
111 + Makefile.pre.in \
112 + Modules/Setup.dist \
113 + Modules/getpath.c \
114 + configure.ac \
115 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
116 +
117 + # force correct number of jobs
118 + # https://bugs.gentoo.org/737660
119 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
120 + sed -i -e "/self\.parallel/s:True:${jobs}:" setup.py || die
121 +
122 + eautoreconf
123 +}
124 +
125 +src_configure() {
126 + local disable
127 + # disable automagic bluetooth headers detection
128 + use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no
129 + use gdbm || disable+=" gdbm"
130 + use ncurses || disable+=" _curses _curses_panel"
131 + use readline || disable+=" readline"
132 + use sqlite || disable+=" _sqlite3"
133 + use ssl || export PYTHON_DISABLE_SSL="1"
134 + use tk || disable+=" _tkinter"
135 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
136 + export PYTHON_DISABLE_MODULES="${disable}"
137 +
138 + if ! use xml; then
139 + ewarn "You have configured Python without XML support."
140 + ewarn "This is NOT a recommended configuration as you"
141 + ewarn "may face problems parsing any XML documents."
142 + fi
143 +
144 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
145 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
146 + fi
147 +
148 + if [[ "$(gcc-major-version)" -ge 4 ]]; then
149 + append-flags -fwrapv
150 + fi
151 +
152 + filter-flags -malign-double
153 +
154 + # https://bugs.gentoo.org/show_bug.cgi?id=50309
155 + if is-flagq -O3; then
156 + is-flagq -fstack-protector-all && replace-flags -O3 -O2
157 + use hardened && replace-flags -O3 -O2
158 + fi
159 +
160 + # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
161 + tc-export CXX
162 +
163 + local dbmliborder
164 + if use gdbm; then
165 + dbmliborder+="${dbmliborder:+:}gdbm"
166 + fi
167 +
168 + local myeconfargs=(
169 + # glibc-2.30 removes it; since we can't cleanly force-rebuild
170 + # Python on glibc upgrade, remove it proactively to give
171 + # a chance for users rebuilding python before glibc
172 + ac_cv_header_stropts_h=no
173 +
174 + --with-fpectl
175 + --enable-shared
176 + --enable-ipv6
177 + --with-threads
178 + --infodir='${prefix}/share/info'
179 + --mandir='${prefix}/share/man'
180 + --with-computed-gotos
181 + --with-dbmliborder="${dbmliborder}"
182 + --with-libc=
183 + --enable-loadable-sqlite-extensions
184 + --without-ensurepip
185 + --with-system-expat
186 + --with-system-ffi
187 + )
188 +
189 + # disable implicit optimization/debugging flags
190 + local -x OPT=
191 + # pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
192 + # propagated to sysconfig for built extensions
193 + local -x CFLAGS_NODIST=${CFLAGS}
194 + local -x LDFLAGS_NODIST=${LDFLAGS}
195 + local -x CFLAGS= LDFLAGS=
196 +
197 + econf "${myeconfargs[@]}"
198 +
199 + if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
200 + eerror "configure has detected that the sem_open function is broken."
201 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
202 + die "Broken sem_open function (bug 496328)"
203 + fi
204 +}
205 +
206 +src_compile() {
207 + # Ensure sed works as expected
208 + # https://bugs.gentoo.org/594768
209 + local -x LC_ALL=C
210 +
211 + # also need to clear the flags explicitly here or they end up
212 + # in _sysconfigdata*
213 + emake CPPFLAGS= CFLAGS= LDFLAGS=
214 +
215 + # Work around bug 329499. See also bug 413751 and 457194.
216 + if has_version dev-libs/libffi[pax-kernel]; then
217 + pax-mark E python
218 + else
219 + pax-mark m python
220 + fi
221 +}
222 +
223 +src_test() {
224 + # Tests will not work when cross compiling.
225 + if tc-is-cross-compiler; then
226 + elog "Disabling tests due to crosscompiling."
227 + return
228 + fi
229 +
230 + # Skip failing tests.
231 + local skipped_tests="gdb faulthandler"
232 +
233 + for test in ${skipped_tests}; do
234 + mv "${S}"/Lib/test/test_${test}.py "${T}"
235 + done
236 +
237 + # bug 660358
238 + local -x COLUMNS=80
239 + local -x PYTHONDONTWRITEBYTECODE=
240 +
241 + local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
242 +
243 + emake test EXTRATESTOPTS="-u-network -j${jobs}" \
244 + CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
245 + local result=$?
246 +
247 + for test in ${skipped_tests}; do
248 + mv "${T}/test_${test}.py" "${S}"/Lib/test
249 + done
250 +
251 + elog "The following tests have been skipped:"
252 + for test in ${skipped_tests}; do
253 + elog "test_${test}.py"
254 + done
255 +
256 + elog "If you would like to run them, you may:"
257 + elog "cd '${EPREFIX}/usr/$(get_libdir)/python${PYVER}/test'"
258 + elog "and run the tests separately."
259 +
260 + if [[ ${result} -ne 0 ]]; then
261 + die "emake test failed"
262 + fi
263 +}
264 +
265 +src_install() {
266 + local libdir=${ED}/usr/$(get_libdir)/python${PYVER}
267 +
268 + emake DESTDIR="${D}" altinstall
269 +
270 + # Remove static library
271 + rm "${ED}"/usr/$(get_libdir)/libpython*.a || die
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 +}