summaryrefslogtreecommitdiff
blob: c290390a53ddfd031a78411b3218719d53bf99a1 (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
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-python/mpmath/mpmath-0.17.ebuild,v 1.2 2011/05/18 21:04:30 grozin Exp $

EAPI="3"
PYTHON_DEPEND="*:2.5"
SUPPORT_PYTHON_ABIS="1"
DISTUTILS_SRC_TEST="py.test"

inherit distutils eutils

MY_PN=${PN}-all
MY_P=${MY_PN}-${PV}
DESCRIPTION="Python library for arbitrary-precision floating-point arithmetic"
HOMEPAGE="http://code.google.com/p/mpmath/ http://pypi.python.org/pypi/mpmath"
SRC_URI="http://mpmath.googlecode.com/files/${MY_P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~x86-linux ~ppc-macos"
IUSE="doc examples gmp matplotlib"

RDEPEND="gmp? ( dev-python/gmpy )
	matplotlib? ( dev-python/matplotlib )"
DEPEND="${RDEPEND}
	doc? ( dev-python/sphinx )"

DOCS="CHANGES"
S="${WORKDIR}/${MY_P}"

src_prepare() {
	distutils_src_prepare

	# don't install tests
	epatch "${FILESDIR}/${PN}.patch"

	# this fails with the current version of dev-python/py
	rm -f ${PN}/conftest.py

	# this test requires X
	rm -f ${PN}/tests/test_visualization.py
}

src_compile() {
	distutils_src_compile

	if use doc; then
		einfo "Generation of documentation"
		pushd doc > /dev/null
		PYTHONPATH="${S}/build-$(PYTHON -f --ABI)/lib" "$(PYTHON -f)" build.py || die "Generation of documentation failed"
		popd > /dev/null
	fi
}

src_install() {
	distutils_src_install

	if use doc; then
		dohtml -r doc/build/* || die "Installation of documentation failed"
	fi

	if use examples; then
		insinto /usr/share/doc/${PF}/examples
		doins demo/* || die "Installation of examples failed"
	fi

	rm_unneeded() {
		local path="${ED}$(python_get_sitedir)/${PN}/libmp/"
		if [[ "${PYTHON_ABI}" == 2.* ]]; then
			rm -f "${path}exec_py3.py"
		else if [[ "${PYTHON_ABI}" == 3.* ]]; then
			rm -f "${path}exec_py2.py"
		fi
		fi
	}

	python_execute_function rm_unneeded
}