# Copyright 1999-2020 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 ${PN}-utils-r1 toolchain-funcs multiprocessing MY_P="Python-${PV}" PATCHSET="${PN}-gentoo-patches-${PV}-r4" DESCRIPTION="An interpreted, interactive, object-oriented programming language" HOMEPAGE="https://www.${PN}.org/" SRC_URI="${HOMEPAGE}ftp/${PN}/${PV}/${MY_P}.tar.xz https://dev.gentoo.org/~mgorny/dist/${PN}/${PATCHSET}.tar.xz" S="${WORKDIR}/${MY_P}" LICENSE="PSF-2" SLOT="2.7" KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 s390 sparc x86" IUSE="-berkdb bluetooth build elibc_uclibc examples gdbm hardened ipv6 l10n_et-EE libressl +lto +ncurses +pgo +readline sqlite +ssl test +threads tk +wide-unicode wininst +xml" # Do not add a dependency on dev-lang/${PN} to this ebuild. # If you need to apply a patch which requires ${PN} for bootstrapping, please # run the bootstrap code on your dev box and include the results in the # patchset. See bug 447752. RDEPEND="app-arch/bzip2:= virtual/libffi:= >=sys-libs/zlib-1.1.3:= virtual/libcrypt:= virtual/libintl berkdb? ( || ( sys-libs/db:5.3 sys-libs/db:5.1 sys-libs/db:4.8 sys-libs/db:4.7 sys-libs/db:4.6 sys-libs/db:4.5 sys-libs/db:4.4 sys-libs/db:4.3 sys-libs/db:4.2 ) ) gdbm? ( sys-libs/gdbm:=[berkdb] ) ncurses? ( >=sys-libs/ncurses-5.2:= ) readline? ( >=sys-libs/readline-4.1:= ) sqlite? ( >=dev-db/sqlite-3.3.8:3= ) ssl? ( !libressl? ( dev-libs/openssl:= ) libressl? ( dev-libs/libressl:= ) ) tk? ( >=dev-lang/tcl-8.0:= >=dev-lang/tk-8.0:= dev-tcltk/blt:= dev-tcltk/tix ) xml? ( >=dev-libs/expat-2.1:= ) !! /dev/null if [ $? -eq 0 ]; then par_arg="-j$(echo ${MAKEOPTS} | egrep -o '(\-j|\-\-jobs)(=?|[[:space:]]*)[[:digit:]]+' | tail -n1 | egrep -o '[[:digit:]]+')" else par_arg="" fi export par_arg emake EXTRATESTOPTS="${par_arg} -uall,-audio -x test_distutils" # Work around bug 329499. See also bug 413751 and 457194. if has_version dev-libs/libffi[pax_kernel]; then pax-mark E ${PN} else pax-mark m ${PN} 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 curses xpickle bdb runpy test_support" for test in ${skipped_tests}; do mv "${S}"/Lib/test/test_${test}.py "${T}" done # bug 660358 local -x COLUMNS=80 # Daylight saving time problem # https://bugs.${PN}.org/issue22067 # https://bugs.gentoo.org/610628 local -x TZ=UTC # Rerun failed tests in verbose mode (regrtest -w). emake test EXTRATESTOPTS="-w -uall,-audio ${par_arg}" < /dev/tty local result="$?" for test in ${skipped_tests}; do mv "${T}/test_${test}.py" "${S}"/Lib/test done elog "The following tests have been skipped:" for test in ${skipped_tests}; do elog "test_${test}.py" done elog "If you would like to run them, you may:" elog "cd '${EPREFIX}/usr/$(get_libdir)/${PN}2.7/test'" elog "and run the tests separately." if [[ ${result} -ne 0 ]]; then die "emake test failed" fi } src_install() { local libdir=${ED}/usr/$(get_libdir)/${PN}2.7 emake DESTDIR="${D}" altinstall sed -e "s/\(LDFLAGS=\).*/\1/" -i "${libdir}/config/Makefile" || die "sed failed" # Fix collisions between different slots of Python. mv "${ED}/usr/bin/2to3" "${ED}/usr/bin/2to3-2.7" || die mv "${ED}/usr/bin/pydoc" "${ED}/usr/bin/pydoc2.7" || die mv "${ED}/usr/bin/idle" "${ED}/usr/bin/idle2.7" || die rm "${ED}/usr/bin/smtpd.py" || die use berkdb || rm -r "${libdir}/"{bsddb,dbhash.py*,test/test_bsddb*} || die use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die use tk || rm -r "${ED}/usr/bin/idle2.7" "${libdir}/"{idlelib,lib-tk} || die use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test} use threads || rm -r "${libdir}/multiprocessing" || die use wininst || rm "${libdir}/distutils/command/"wininst-*.exe || die dodoc Misc/{ACKS,HISTORY,NEWS} if use examples; then docinto examples dodoc -r Tools fi insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510 local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \ emake --no-print-directory -s -f - 2>/dev/null) newins "${S}"/Tools/gdb/lib${PN}.py "${libname}"-gdb.py newconfd "${FILESDIR}/pydoc.conf" pydoc-2.7 newinitd "${FILESDIR}/pydoc.init" pydoc-2.7 sed \ -e "s:@PYDOC_PORT_VARIABLE@:PYDOC2_7_PORT:" \ -e "s:@PYDOC@:pydoc2.7:" \ -i "${ED}/etc/conf.d/pydoc-2.7" \ "${ED}/etc/init.d/pydoc-2.7" || die "sed failed" local -x EPYTHON=${PN}2.7 # if not using a cross-compiler, use the fresh binary if ! tc-is-cross-compiler; then local -x PYTHON=./${PN} local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD} else local -x PYTHON=${EPREFIX}/usr/bin/${EPYTHON} fi echo "EPYTHON='${PN}2.7'" > e${PN}.py || die ${PN}_domodule e${PN}.py # ${PN}-exec wrapping support local scriptdir=${D}${PN}2.7 mkdir -p "${scriptdir}" || die # ${PN} ln -s "../../../bin/${PN}2.7" "${scriptdir}/${PN}" || die # ${PN}-config ln -s "../../../bin/${PN}2.7-config" "${scriptdir}/${PN}-config" || die # 2to3, pydoc, pyvenv ln -s "../../../bin/2to3-2.7" "${scriptdir}/2to3" || die ln -s "../../../bin/pydoc2.7" "${scriptdir}/pydoc" || die # idle if use tk; then ln -s "../../../bin/idle2.7" "${scriptdir}/idle" || die fi } eselect_python_update() { if [[ -z "$(eselect ${PN} show)" || ! -f "${EROOT}/usr/bin/$(eselect ${PN} show)" ]]; then eselect ${PN} update fi if [[ -z "$(eselect ${PN} show --${PN}${PV%%.*})" || ! -f "${EROOT}/usr/bin/$(eselect ${PN} show --${PN}${PV%%.*})" ]] then eselect ${PN} update --${PN}${PV%%.*} fi } pkg_postinst() { eselect_${PN}_update } pkg_postrm() { eselect_${PN}_update }