summaryrefslogtreecommitdiff
blob: fa59af90f48a84e2145fd641a166a31824de294c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-python/ipython/ipython-0.13.ebuild,v 1.4 2012/12/31 12:59:55 mgorny Exp $

EAPI=4

# python eclass cruft
PYTHON_DEPEND="*:2.6"
PYTHON_USE_WITH="readline sqlite"
PYTHON_MODNAME="IPython"
SUPPORT_PYTHON_ABIS="1"
RESTRICT_PYTHON_ABIS="2.5 *-jython *-pypy-*"

inherit distutils elisp-common eutils virtualx

DESCRIPTION="Advanced interactive shell for Python"
HOMEPAGE="http://ipython.org/"
SRC_URI="http://archive.ipython.org/release/${PV}/${P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
IUSE="doc emacs examples matplotlib mongodb notebook octave
	qt4 +smp test wxwidgets"

CDEPEND="dev-python/decorator
	dev-python/pexpect
	virtual/pyparsing
	dev-python/simplegeneric
	virtual/python-argparse
	emacs? ( app-emacs/python-mode virtual/emacs )
	matplotlib? ( dev-python/matplotlib )
	mongodb? ( dev-python/pymongo )
	octave? ( dev-python/oct2py )
	smp? ( dev-python/pyzmq )
	wxwidgets? ( dev-python/wxpython )"
RDEPEND="${CDEPEND}
	notebook? ( >=www-servers/tornado-2.1
			dev-python/pygments
			dev-python/pyzmq )
	qt4? ( || ( dev-python/PyQt4 dev-python/pyside )
			dev-python/pygments
			dev-python/pyzmq )"
DEPEND="${CDEPEND}
	test? ( dev-python/nose )"

src_prepare() {
	distutils_src_prepare
	epatch "${FILESDIR}"/${PN}-0.12-globalpath.patch
	epatch "${FILESDIR}"/${PN}-0.13-umlaut.patch

	# fix for gentoo python scripts
	sed -i \
		-e "/ipython_cmd/s/ipython3/ipython/g" \
		IPython/frontend/terminal/console/tests/test_console.py \
		IPython/lib/irunner.py \
		IPython/testing/tools.py || die

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

	# disable failing tests
	sed -i \
		-e 's/test_pylab_import_all_disabled/_&/' \
		-e 's/test_pylab_import_all_enabled/_&/' \
		IPython/lib/tests/test_irunner_pylab_magic.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
}

src_compile() {
	distutils_src_compile
	use emacs && elisp-compile docs/emacs/ipython.el
}

src_test() {
	# https://github.com/ipython/ipython/issues/2083
	unset PYTHONWARNINGS

	if use mongodb; then
		mkdir -p "${T}/mongo.db"
		mongod --dbpath "${T}/mongo.db" --fork --logpath "${T}/mongo.log"
	fi

	testing() {
		"$(PYTHON)" setup.py \
			build -b "build-${PYTHON_ABI}" \
			install --root="${T}/tests-${PYTHON_ABI}" > /dev/null || die
		# Initialize ~/.ipython directory.
		PATH="${T}/tests-${PYTHON_ABI}${EPREFIX}/usr/bin:${PATH}" \
			PYTHONPATH="${T}/tests-${PYTHON_ABI}${EPREFIX}$(python_get_sitedir)" \
			ipython <<< "" > /dev/null || return 1
		# Run tests (-v for more verbosity).
		PATH="${T}/tests-${PYTHON_ABI}${EPREFIX}/usr/bin:${PATH}" \
			PYTHONPATH="${T}/tests-${PYTHON_ABI}${EPREFIX}$(python_get_sitedir)" \
			iptest -v || return 1
	}
	VIRTUALX_COMMAND="python_execute_function" virtualmake testing

	use mongodb && killall -u "$(id -nu)" mongod
}

src_install() {
	distutils_src_install
	if use emacs; then
		pushd docs/emacs > /dev/null
		elisp-install ${PN} ${PN}.el*
		elisp-site-file-install "${FILESDIR}"/62ipython-gentoo.el
		popd > /dev/null
	fi
}

pkg_postinst() {
	distutils_pkg_postinst
	use emacs && elisp-site-regen
}

pkg_postrm() {
	distutils_pkg_postrm
	use emacs && elisp-site-regen
}