summaryrefslogtreecommitdiff
blob: fae9b6ac58e93fad7e534f458f49db3307f63833 (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
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-python/numeric/numeric-24.2-r6.ebuild,v 1.4 2007/09/04 17:18:57 bicatali Exp $

NEED_PYTHON=2.3

inherit distutils eutils fortran

MY_P=Numeric-${PV}

DESCRIPTION="Numerical multidimensional array language facility for Python."
HOMEPAGE="http://numeric.scipy.org/"
SRC_URI="mirror://sourceforge/numpy/${MY_P}.tar.gz
	doc? ( http://numpy.scipy.org/numpy.pdf )"

# numeric needs cblas (virtual/cblas work in progress)
# and lapack. needs fortran to get the proper fortran to C library.
RDEPEND="lapack? ( || ( >=sci-libs/blas-atlas-3.7.11-r1
						>=sci-libs/cblas-reference-20030223-r3 )
					virtual/lapack )"
DEPEND="${RDEPEND}
	lapack? ( app-admin/eselect-cblas )"

LICENSE="as-is"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd"
IUSE="doc lapack"

S=${WORKDIR}/${MY_P}

pkg_setup() {
	if use lapack; then
		FORTRAN="gfortran g77 ifc"
		fortran_pkg_setup
		for d in $(eselect cblas show); do mycblas=${d}; done
		if [[ -z "${mycblas/reference/}" ]] && [[ -z "${mycblas/atlas/}" ]]; then
			ewarn "You need to set cblas to atlas or reference. Do:"
			ewarn "   eselect cblas set <impl>"
			ewarn "where <impl> is atlas, threaded-atlas or reference"
			die "setup failed"
		fi
	fi
}

src_unpack() {
	unpack ${A}

	# fix list problem
	epatch "${FILESDIR}"/${P}-arrayobject.patch
	# fix skips of acosh, asinh
	epatch "${FILESDIR}"/${P}-umath.patch
	# fix eigenvalue hang
	epatch "${FILESDIR}"/${P}-eigen.patch
	# fix a bug in the test
	epatch "${FILESDIR}"/${P}-test.patch
	# fix only for python-2.5
	distutils_python_version
	[[ "${PYVER}" == 2.5 ]] && epatch "${FILESDIR}"/${P}-python25.patch
	# fix for dotblas from uncommited cvs
	epatch "${FILESDIR}"/${P}-dotblas.patch

	# adapt lapack support
	if use lapack; then
		epatch "${FILESDIR}"/${P}-lapack.patch
		local flib=
		if  [[ "${FORTRANC}" == gfortran ]]; then
			flib="'gfortran'"
		elif [[ "${FORTRANC}" == if* ]]; then
			flib="'imf'"
		elif [[ "${FORTRANC}" == g77 ]]; then
			flib="'g2c'"
		fi
		local cblaslib= cblasinc=
		if [[ "${mycblas}" == reference ]]; then
			cblaslib="'blas','cblas'"
			cblasinc="'/usr/include/cblas'"
		elif [[ "${mycblas}" == atlas ]]; then
			cblaslib="'blas','cblas','atlas'"
			cblasinc="'/usr/include/atlas'"
		elif [[ "${mycblas}" == threaded-atlas ]]; then
			cblaslib="'blas','cblas','atlas','pthread'"
			cblasinc="'/usr/include/atlas'"
		fi
		sed -i \
			-e "s:@FLIB@:${flib}:g" \
			-e "s:@LAPACKLIB@:'lapack':g" \
			-e "s:@CBLASLIB@:${cblaslib}:g" \
			-e "s:@CBLASINC@:${cblasinc}:g" \
			"${S}"/customize.py \
			|| die "sed for lapack support failed"
	fi
}

src_test() {
	cd build/lib*
	PYTHONPATH=. "${python}" "${S}"/Test/test.py \
		|| die "test failed"
}

src_install() {
	distutils_src_install

	# install various README from packages
	newdoc Packages/MA/README README.MA
	newdoc Packages/RNG/README README.RNG

	if use lapack; then
		docinto dotblas
		dodoc Packages/dotblas/{README,profileDot}.txt
		insinto /usr/share/doc/${PF}/dotblas
		doins Packages/dotblas/profileDot.py
	fi

	# install tutorial and docs
	if use doc; then
		insinto /usr/share/doc/${PF}
		doins -r Test Demo/NumTut || die "install tutorial failed"
		newins "${DISTDIR}"/numpy.pdf numeric.pdf || die "install doc failed"
	fi
}