Skip to content

Instantly share code, notes, and snippets.

@cel4
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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 Jul 31, 2014

The extension magics for oct2py and rpy live now in the oct2py and rpy2 package. The tests shipped with ipython are broken. We should disable those tests and remove the magics files:

IPython/extensions/rmagic.py -> rpy/ipython/rmagic.py
IPython/extension/octavemagic.py -> oct2py/ipython/octavemagic.py

deleted:    IPython/extensions/octavemagic.py
deleted:    IPython/extensions/rmagic.py
modified:   IPython/testing/iptest.py
diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py
index 45d2c78..db0bdfe 100644
--- a/IPython/testing/iptest.py
+++ b/IPython/testing/iptest.py
@@ -250,12 +250,10 @@ sec = test_sections['extensions']
 if not have['cython']:
     sec.exclude('cythonmagic')
     sec.exclude('tests.test_cythonmagic')
-if not have['oct2py']:
-    sec.exclude('octavemagic')
-    sec.exclude('tests.test_octavemagic')
-if not have['rpy2'] or not have['numpy']:
-    sec.exclude('rmagic')
-    sec.exclude('tests.test_rmagic')
+sec.exclude('octavemagic')
+sec.exclude('tests.test_octavemagic')
+sec.exclude('rmagic')
+sec.exclude('tests.test_rmagic')
 # autoreload does some strange stuff, so move it to its own test section
 sec.exclude('autoreload')
 sec.exclude('tests.test_autoreload')

@cel4
Copy link
Author

cel4 commented Jul 31, 2014

After this patch user's won't be able to use load_ext rmagic and load_ext octave_magic. I think we should check if ipython is compiled with rpy or oct2py and create symlinks for convenience.

IPython/extensions/rmagic.py -> rpy/ipython/rmagic.py
IPython/extension/octavemagic.py -> oct2py/ipython/octavemagic.py

@cel4
Copy link
Author

cel4 commented Jul 31, 2014

gen_python_deps() {
    local flag
    for flag in $(python_gen_useflags '*'); do
        echo "${flag}? ( ${1}[${flag}(-)] )"
    done
}

Why is this part needed?

@idella
Copy link

idella commented Aug 1, 2014

Copyright 1999-2014 Gentoo Foundation

Distributed under the terms of the GNU General Public License v2

$Header: /var/cvsroot/gentoo-x86/dev-python/ipython/ipython-2.1.0.ebuild,v 1.1 2014/08/01 03:25:26 idella4 Exp $

EAPI=5

PYTHON_COMPAT=( python{2_7,3_3,3_4} )
PYTHON_REQ_USE='readline,sqlite'

inherit distutils-r1 elisp-common virtualx

DESCRIPTION="Advanced interactive shell for Python"
HOMEPAGE="http://ipython.org/"
SRC_URI="https://github.com/${PN}/${PN}/releases/download/rel-${PV}/${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 octave qt4 +smp test wxwidgets"

PY2_USEDEP=$(python_gen_usedep python2_7)

This looks quite superfluous

gen_python_deps() {

local flag

for flag in $(python_gen_useflags '*'); do

echo "${flag}? ( ${1}[${flag}(-)] )"

done

}

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}] )
octave? ( dev-python/oct2py[${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[${PYTHON_USEDEP}] )"
DEPEND="${CDEPEND}
test? ( dev-python/nose[${PYTHON_USEDEP}]
dev-python/oct2py[${PYTHON_USEDEP}]
dev-python/mock[${PYTHON_USEDEP}]
net-libs/nodejs )
doc? ( dev-python/sphinx[${PYTHON_USEDEP}]
dev-python/numpydoc[${PYTHON_USEDEP}] )"

PY2_REQUSE="$(python_gen_useflags python2_7)"
REQUIRED_USE="
wxwidgets? ( ${PY2_REQUSE} )"

DISTUTILS_IN_SOURCE_BUILD=1

PATCHES=( "${FILESDIR}"/2.1.0-disable-tests.patch )

python_prepare_all() {
# fix for gentoo python scripts
sed -i
-e "/ipython_cmd/s/ipython3/ipython/g"
IPython/terminal/console/tests/test_console.py
IPython/testing/tools.py || die

sed -i \
    -e "s/find_scripts(True, suffix='3')/find_scripts(True)/" \
    setup.py || die

# fix gentoo installation directory for documentation
sed -i \
    -e "/docdirbase  = pjoin/s/ipython/${PF}/" \
    -e "/pjoin(docdirbase,'manual')/s/manual/html/" \
    setupbase.py || die "sed failed"

if ! use doc; then
    sed -i \
        -e "/(pjoin(docdirbase, 'extensions'), igridhelpfiles),/d" \
        -e 's/ + manual_files//' \
        setupbase.py || die
fi

if ! use examples; then
    sed -i \
        -e 's/+ example_files//' \
        setupbase.py || die
fi

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() {
# Run tests (-v for more verbosity).
PYTHONPATH="${PYTHONPATH}:$(pwd)"
pushd ${TEST_DIR} > /dev/null
"${PYTHON}" -c "import IPython; IPython.test()" || fail=1
popd > /dev/null
}

VIRTUALX_COMMAND=run_tests virtualmake

}

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
}

version deps added

@cel4
Copy link
Author

cel4 commented Aug 2, 2014

Some tests fail to create temp files in the right directories.

/var/tmp/portage/dev-python/ipython-2.py
/var/tmp/portage/dev-python/ipython-2.ipynb

Are left-overs that won't be cleaned.

@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