# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI="7" WANT_LIBTOOL="none" inherit autotools flag-o-matic pax-utils toolchain-funcs verify-sig MY_P="Python-${PV%_p*}" PYVER=$(ver_cut 1-2) PATCHSET="python-gentoo-patches-${PV}" DESCRIPTION="An interpreted, interactive, object-oriented programming language" HOMEPAGE=" https://www.python.org/ https://github.com/python/cpython/ https://gitweb.gentoo.org/fork/cpython.git/ " SRC_URI=" https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz verify-sig? ( https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz.asc ) " S="${WORKDIR}/${MY_P}" LICENSE="PSF-2" SLOT="${PYVER}" KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86" IUSE=" berkdb bluetooth build examples gdbm +ncurses +readline +sqlite +ssl tk valgrind wininst +xml " RESTRICT="test" # Do not add a dependency on dev-lang/python to this ebuild. # If you need to apply a patch which requires python for bootstrapping, please # run the bootstrap code on your dev box and include the results in the # patchset. See bug 447752. # Lib/epython.py || die } src_compile() { # Ensure sed works as expected # https://bugs.gentoo.org/594768 local -x LC_ALL=C # Avoid invoking pgen for cross-compiles. touch Include/graminit.h Python/graminit.c || die emake # Work around bug 329499. See also bug 413751 and 457194. if has_version dev-libs/libffi[pax-kernel]; then pax-mark E python else pax-mark m python fi } src_test() { # Tests will not work when cross compiling. if tc-is-cross-compiler; then elog "Disabling tests due to crosscompiling." return fi # Skip failing tests. local skipped_tests=( distutils gdb ) for test in "${skipped_tests[@]}"; do mv Lib/test/test_${test}.py "${T}"/ || die done # bug 660358 local -x COLUMNS=80 # Daylight saving time problem # https://bugs.python.org/issue22067 # https://bugs.gentoo.org/610628 local -x TZ=UTC # Rerun failed tests in verbose mode (regrtest -w). emake test EXTRATESTOPTS="-w" < /dev/tty for test in "${skipped_tests[@]}"; do mv "${T}/test_${test}.py" Lib/test/ || die done } src_install() { local libdir=${ED}/usr/$(get_libdir)/python${PYVER} emake DESTDIR="${D}" altinstall sed -e "s/\(LDFLAGS=\).*/\1/" -i "${libdir}/config/Makefile" || die # Remove static library rm "${ED}"/usr/$(get_libdir)/libpython*.a || die # Fix collisions between different slots of Python. mv "${ED}/usr/bin/2to3" "${ED}/usr/bin/2to3-${PYVER}" || die mv "${ED}/usr/bin/pydoc" "${ED}/usr/bin/pydoc${PYVER}" || die mv "${ED}/usr/bin/idle" "${ED}/usr/bin/idle${PYVER}" || die rm "${ED}/usr/bin/smtpd.py" || die if ! use berkdb; then rm -r "${libdir}/"{bsddb,dbhash.py*,test/test_bsddb*} || die fi if ! use sqlite; then rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die fi if ! use tk; then rm -r "${ED}/usr/bin/idle${PYVER}" || die rm -r "${libdir}/"{idlelib,lib-tk} || die fi dodoc Misc/{ACKS,HISTORY,NEWS} if use examples; then docinto examples dodoc -r Tools fi newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER} newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER} sed \ -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \ -e "s:@PYDOC@:pydoc${PYVER}:" \ -i "${ED}/etc/conf.d/pydoc-${PYVER}" \ "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed" # python2* is no longer wrapped, so just symlink it local pymajor=${PYVER%.*} dosym "python${PYVER}" "/usr/bin/python${pymajor}" dosym "python${PYVER}-config" "/usr/bin/python${pymajor}-config" }