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