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