# Copyright 1999-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.7.8.ebuild,v 1.2 2014/09/22 16:47:38 floppym Exp $ EAPI="4" WANT_AUTOMAKE="none" WANT_LIBTOOL="none" inherit autotools eutils flag-o-matic multilib pax-utils python-utils-r1 toolchain-funcs multiprocessing MY_P="Python-${PV}" PATCHSET_VERSION="2.7.8-0" PREFIX_PATCHREV="" DESCRIPTION="An interpreted, interactive, object-oriented programming language" HOMEPAGE="http://www.python.org/" SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.xz http://dev.gentoo.org/~floppym/python/python-gentoo-patches-${PATCHSET_VERSION}.tar.xz prefix? ( http://dev.gentoo.org/~grobian/distfiles/python-prefix-${PV}-gentoo-patches${PREFIX_PATCHREV}.tar.bz2 )" LICENSE="PSF-2" SLOT="2.7" KEYWORDS="~ppc-aix ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" IUSE="aqua -berkdb build doc elibc_uclibc examples gdbm hardened ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml" # 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. RDEPEND="app-arch/bzip2 >=sys-libs/zlib-1.1.3 !m68k-mint? ( virtual/libffi ) virtual/libintl !build? ( berkdb? ( || ( sys-libs/db:5.3 sys-libs/db:5.2 sys-libs/db:5.1 sys-libs/db:5.0 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? ( dev-libs/openssl ) tk? ( >=dev-lang/tk-8.0[-aqua] dev-tcltk/blt dev-tcltk/tix ) xml? ( >=dev-libs/expat-2.1 ) ) !! /dev/null rm -f python python-config python${SLOT}-config # python${SLOT} was created above for f in pythonw smtpd${SLOT}.py pydoc idle ; do rm -f ${f} ${f}${SLOT} done # pythonw needs to remain in the framework (that's the whole # reason we go through this framework hassle) ln -s ../lib/Python.framework/Versions/${SLOT}/bin/pythonw${SLOT} || die # copy the scripts to we can fix their shebangs for f in 2to3 pydoc${SLOT} idle${SLOT} python${SLOT}-config ; do # for some reason sometimes they already exist, bug #347321 rm -f ${f} cp "${D}${fwdir}"/Versions/${SLOT}/bin/${f} . || die sed -i -e '1c\#!'"${EPREFIX}"'/usr/bin/python'"${SLOT}" \ ${f} || die done # "fix" to have below collision fix not to bail mv pydoc${SLOT} pydoc || die mv idle${SLOT} idle || die popd > /dev/null # basically we don't like the framework stuff at all, so just move # stuff around or add some symlinks to make our life easier mkdir -p "${ED}"/usr mv "${D}${fwdir}"/Versions/${SLOT}/share \ "${ED}"/usr/ || die "can't move share" # get includes just UNIX style mkdir -p "${ED}"/usr/include mv "${D}${fwdir}"/Versions/${SLOT}/include/python${SLOT} \ "${ED}"/usr/include/ || die "can't move include" pushd "${D}${fwdir}"/Versions/${SLOT}/include > /dev/null ln -s ../../../../../include/python${SLOT} || die popd > /dev/null rm -f "${ED}"/usr/share/man/man1/python{,2}.1 # same for libs # NOTE: can't symlink the entire dir, because a real dir already exists # on upgrade (site-packages), however since we h4x0rzed python to # actually look into the UNIX-style dir, we just switch them around. mkdir -p "${ED}"/usr/$(get_libdir)/python${SLOT} mv "${D}${fwdir}"/Versions/${SLOT}/lib/python${SLOT}/* \ "${ED}"/usr/$(get_libdir)/python${SLOT}/ || die "can't move python${SLOT}" rmdir "${D}${fwdir}"/Versions/${SLOT}/lib/python${SLOT} || die pushd "${D}${fwdir}"/Versions/${SLOT}/lib > /dev/null ln -s ../../../../python${SLOT} || die popd > /dev/null # remove now dead symlinks rm "${ED}"/usr/lib/python${SLOT}/config/libpython${SLOT}.a rm "${ED}"/usr/lib/python${SLOT}/config/libpython${SLOT}.dylib # fix up Makefile sed -i \ -e '/^LINKFORSHARED=/s/-u _PyMac_Error.*$//' \ -e '/^LDFLAGS=/s/=.*$/=/' \ -e '/^prefix=/s:=.*$:= '"${EPREFIX}"'/usr:' \ -e '/^PYTHONFRAMEWORK=/s/=.*$/=/' \ -e '/^PYTHONFRAMEWORKDIR=/s/=.*$/= no-framework/' \ -e '/^PYTHONFRAMEWORKPREFIX=/s/=.*$/=/' \ -e '/^PYTHONFRAMEWORKINSTALLDIR=/s/=.*$/=/' \ -e '/^LDLIBRARY=/s:=.*$:libpython$(VERSION).dylib:' \ "${ED}"/usr/lib/python${SLOT}/config/Makefile || die # add missing version.plist file mkdir -p "${D}${fwdir}"/Versions/${SLOT}/Resources cat > "${D}${fwdir}"/Versions/${SLOT}/Resources/version.plist << EOF BuildVersion 1 CFBundleShortVersionString ${PV} CFBundleVersion ${PV} ProjectName Python SourceVersion ${PV} EOF else emake DESTDIR="${D}" altinstall fi sed -e "s/\(LDFLAGS=\).*/\1/" -i "${libdir}/config/Makefile" || die "sed failed" if [[ ${CHOST} == *-aix* ]]; then # fix upstream bugs with quite large proposed diffs still to be sorted out: # http://bugs.python.org/issue13493 # http://bugs.python.org/issue14150 # http://bugs.python.org/issue15590 # http://bugs.python.org/issue16189 sed -e "/Libs:/s|\$| -Wl,-bE:${EPREFIX}/${libdir#$ED}/config/python.exp -lld|" \ -i "${ED}"usr/$(get_libdir)/pkgconfig/python-${SLOT}.pc || die "sed failed" sed -e "s|:Modules/python.exp|:${EPREFIX}/${libdir#$ED}/config/python.exp|" \ -e 's| -bI:| -Wl,-bI:|g' \ -e '/LINKFORSHARED/s|-bE:|-bI:|g' \ -e '/LINKFORSHARED/s| -lld||g' \ -i "${libdir}"/{_sysconfigdata.py,config/Makefile} || die "sed failed" fi # Backwards compat with Gentoo divergence. dosym python${SLOT}-config /usr/bin/python-config-${SLOT} # Fix collisions between different slots of Python. mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}" mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}" mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}" rm -f "${ED}usr/bin/smtpd.py" # http://src.opensolaris.org/source/xref/jds/spec-files/trunk/SUNWPython.spec # These #defines cause problems when building c99 compliant python modules # http://bugs.python.org/issue1759169 [[ ${CHOST} == *-solaris* ]] && sed -i -e \ 's:^\(^#define \(_POSIX_C_SOURCE\|_XOPEN_SOURCE\|_XOPEN_SOURCE_EXTENDED\).*$\):/* \1 */:' \ "${ED}"/usr/include/python${SLOT}/pyconfig.h if use build; then rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{bsddb,dbhash.py,idlelib,lib-tk,sqlite3,test} else 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 -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{idlelib,lib-tk} || die use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test} fi use threads || rm -r "${libdir}/multiprocessing" || die use wininst || rm -r "${libdir}/distutils/command/"wininst-*.exe || die dodoc "${S}"/Misc/{ACKS,HISTORY,NEWS} if use examples; then insinto /usr/share/doc/${PF}/examples doins -r "${S}"/Tools fi insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510 local libname if use aqua ; then # we do framework, so the emake trick below returns a pathname # since that won't work here, use a (cheap) trick instead libname=libpython${SLOT} else libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \ emake --no-print-directory -s -f - 2>/dev/null) fi newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} sed \ -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${SLOT/./_}_PORT:" \ -e "s:@PYDOC@:pydoc${SLOT}:" \ -i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" || die "sed failed" # for python-exec python_export python${SLOT} EPYTHON PYTHON PYTHON_SITEDIR # if not using a cross-compiler, use the fresh binary if ! tc-is-cross-compiler; then local PYTHON=./python local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}. fi echo "EPYTHON='${EPYTHON}'" > epython.py python_domodule epython.py } pkg_preinst() { if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.7"; then python_updater_warning="1" fi } eselect_python_update() { if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then eselect python update fi if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then eselect python update --python${PV%%.*} fi } pkg_postinst() { eselect_python_update if [[ "${python_updater_warning}" == "1" ]]; then ewarn "You have just upgraded from an older version of Python." ewarn "You should switch active version of Python ${PV%%.*} and run" ewarn "'python-updater [options]' to rebuild Python modules." fi } pkg_postrm() { eselect_python_update }