Skip to content

Instantly share code, notes, and snippets.

@cel4
Last active August 29, 2015 14:04
Show Gist options
  • Save cel4/5315eb2b76fab0156f9c to your computer and use it in GitHub Desktop.
Save cel4/5315eb2b76fab0156f9c to your computer and use it in GitHub Desktop.
First draft version of ipython-2.1.0.ebuild
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=5
PYTHON_COMPAT=( python{2_7,3_3,3_4} )
PYTHON_REQ_USE='readline,sqlite'
inherit distutils-r1 virtualx
DESCRIPTION="Advanced interactive shell for Python"
HOMEPAGE="http://ipython.org/"
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
IUSE="doc examples matplotlib mongodb notebook nbconvert qt4 +smp test wxwidgets"
IUSE_MAGIC_EXTENSIONS=" octave R cython sympy"
IUSE+=" ${IUSE_MAGIC_EXTENSIONS// / magic_extensions_}"
PY2_USEDEP=$(python_gen_usedep python2_7)
CDEPEND="
dev-python/decorator[${PYTHON_USEDEP}]
dev-python/pexpect[${PYTHON_USEDEP}]
dev-python/setuptools[${PYTHON_USEDEP}]
dev-python/simplegeneric[${PYTHON_USEDEP}]
dev-python/pyparsing[${PYTHON_USEDEP}]
matplotlib? ( dev-python/matplotlib[${PYTHON_USEDEP}] )
mongodb? ( dev-python/pymongo[${PYTHON_USEDEP}] )
magic_extensions_octave? ( dev-python/oct2py[${PYTHON_USEDEP}] )
magic_extensions_R? ( dev-python/rpy[${PYTHON_USEDEP}] )
magic_extensions_sympy? ( dev-python/sympy[${PYTHON_USEDEP}] )
magic_extensions_cython? ( dev-python/cython[${PYTHON_USEDEP}] )
smp? ( >=dev-python/pyzmq-2.1.11[${PYTHON_USEDEP}] )
wxwidgets? ( dev-python/wxpython[${PY2_USEDEP}] )"
RDEPEND="${CDEPEND}
notebook? (
>=www-servers/tornado-3.1[${PYTHON_USEDEP}]
dev-python/pygments[${PYTHON_USEDEP}]
>=dev-python/pyzmq-2.1.11[${PYTHON_USEDEP}]
dev-python/jinja[${PYTHON_USEDEP}]
dev-libs/mathjax
)
nbconvert? (
>=app-text/pandoc-1.12.1
dev-python/pygments[${PYTHON_USEDEP}]
dev-python/sphinx[${PYTHON_USEDEP}]
dev-python/jinja[${PYTHON_USEDEP}]
)
qt4? ( || ( dev-python/PyQt4[${PYTHON_USEDEP}] dev-python/pyside[${PYTHON_USEDEP}] )
dev-python/pygments[${PYTHON_USEDEP}]
>=dev-python/pyzmq-2.1.11[${PYTHON_USEDEP}] )"
DEPEND="${CDEPEND}
test? (
dev-python/nose[${PYTHON_USEDEP}]
dev-python/mock[${PY2_USEDEP}]
)
doc? ( dev-python/sphinx[${PYTHON_USEDEP}]
dev-python/numpydoc[${PYTHON_USEDEP}]
$(python_gen_cond_dep 'dev-python/fabric[${PYTHON_USEDEP}]' python2_7)
)"
PY2_REQUSE="$(python_gen_useflags python2_7)"
REQUIRED_USE="
wxwidgets? ( ${PY2_REQUSE} )
doc? (
matplotlib
mongodb
magic_extensions_octave
magic_extensions_R
)"
PATCHES=(
"${FILESDIR}/ipython-2.1.0-bp1406.patch"
"${FILESDIR}/ipython-2.1.0-bp1407.patch"
"${FILESDIR}/ipython-2.1.0-test.patch"
)
DISTUTILS_IN_SOURCE_BUILD=1
python_prepare() {
rm IPython/extensions/rmagic.py || die
rm IPython/extensions/octavemagic.py || die
if use magic_extensions_octave; then
ln -s "${EPREFIX}$(python_get_sitedir)/oct2py/ipython/octavemagic.py"\
IPython/extensions/octavemagic.py || die
fi
if use magic_extensions_R; then
ln -s "${EPREFIX}$(python_get_sitedir)/rpy2/ipython/rmagic.py"\
IPython/extensions/rmagic.py || die
fi
distutils-r1_python_prepare
}
python_prepare_all() {
if use doc; then
#Prevent un-needed download during build
sed -e "/^ 'sphinx.ext.intersphinx',/d" -i docs/source/conf.py || die
fi
distutils-r1_python_prepare_all
}
python_compile_all() {
use doc && emake -C docs html
}
src_test() {
# virtualx has trouble with parallel runs.
local DISTUTILS_NO_PARALLEL_BUILD=1
distutils-r1_src_test
}
python_test() {
distutils_install_for_testing
local fail
run_tests() {
# Initialize ~/.ipython directory.
"${PYTHON}" -m IPython </dev/null >/dev/null || fail=1
cd ${TEST_DIR} || die
"${PYTHON}" -m IPython.testing.iptestcontroller --all || fail=1
}
VIRTUALX_COMMAND=run_tests virtualmake
[[ ${fail} ]] && die "Tests fail with ${EPYTHON}"
}
python_install() {
distutils-r1_python_install
ln -snf "${EPREFIX}"/usr/share/mathjax \
"${D}$(python_get_sitedir)"/IPython/html/static/mathjax || die
# Create ipythonX.Y symlinks.
# TODO:
# 1. do we want them for pypy?
# 2. handle it in the eclass instead (use _python_ln_rel).
if [[ ${EPYTHON} == python* ]]; then
dosym ../lib/python-exec/${EPYTHON}/ipython \
/usr/bin/ipython${EPYTHON#python}
fi
}
python_install_all() {
use doc && local HTML_DOCS=( docs/build/html/. )
distutils-r1_python_install_all
}
@cel4
Copy link
Author

cel4 commented Aug 2, 2014

I can't see that any of the sed commands in the prepare_all phase patching files. We can probably clean that up.

@idella
Copy link

idella commented Aug 2, 2014

  • if use doc; then
  • Prevent un-needed download during build

  • sed -e "/^ 'sphinx.ext.intersphinx',/d" -i docs/source/conf.py || die
  • fi

I put this in and it belongs

Oh, and

        doc? ( dev-python/sphinx[${PYTHON_USEDEP}]
                dev-python/numpydoc[${PYTHON_USEDEP}]
                dev-python/rpy[${PYTHON_USEDEP}]
                $(python_gen_cond_dep 'dev-python/fabric[${PYTHON_USEDEP}]' python2_7)
                dev-python/nose[${PYTHON_USEDEP}] )"

PY2_REQUSE="$(python_gen_useflags python2_7)"
REQUIRED_USE="
        wxwidgets? ( ${PY2_REQUSE} )
        doc? ( matplotlib mongodb octave )"

@prometheanfire
Copy link

what makes magic extensions special enough to be 'magic', also, magic has bad connotations in gentoo (autotools mythbuster series by flameeyes).

in short, they look like regular use flags to me, treat them as such.

@cel4
Copy link
Author

cel4 commented Aug 6, 2014

    if use magic_extensions_R; then
        dosym "${EPREFIX}$(python_get_sitedir)/rpy2/ipython/rmagic.py" \
            "$(python_get_sitedir)/IPython/extensions/rmagic.py"
    fi

    if use magic_extensions_octave; then
        dosym "${EPREFIX}$(python_get_sitedir)/oct2py/ipython/octavemagic.py" \
            "$(python_get_sitedir)/IPython/extensions/octavemagic.py"
    fi

This part need review: Is this kind of symlinking allowed according to the dev-manual?

@idella
Copy link

idella commented Aug 7, 2014

For now I have held back on the IUSE cython, sympy and 'rpy or R' flags by your own change of mind. The octave was already in place. While viable, their use may be sufficiently addressed by a msg via elog in pkg_postinst. This matches guides from the dev manual. Feel free to draft such msgs.

The issue over the making of symlinks is I believe unusable because it goes into global scope. Processes within ebuilds need be kept within the local scope of the phase. While there are samples of symlinking to the system at src_install, it's generally done to somewhere like /bin /or /sbin or within the package's own dir structure. Symlinking to another installed package's files is taking this to another level, and I anticipate it to to not be endorsed by review by other devs.
Rather than rm the 'broken' intra source files, I would instead the tests_ files from the suite the import them. The broken files are still required for the doc build, and if the doc build content is at fault, the onus is on upstream to get them right.
This clearly is the next task with upstream. If not you, then by me. Having a 'broken' or outdated key file in the source is something you just shouldn't have to dodge around. It needs fixing either by getting a healthy file substituted or re-writing the source to import the system installed good files in any and all instances.

I am next to add a diff file to the Bug 507410 which reflects the changes outlined above. Note it is a diff and not a commit. This is far from finished. The doc build simply requires its deps added, and additional keywording

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment