blob: 873621e2ae87087a6d908b4d7b176dfab3e5120e [file] [log] [blame]
tedbo023d9f72010-03-02 20:20:39 -08001# Copyright 1999-2010 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/dev-python/numpy/numpy-1.4.0.ebuild,v 1.3 2010/02/24 14:52:39 mduft Exp $
4
5EAPI="2"
6SUPPORT_PYTHON_ABIS="1"
7
8inherit distutils eutils flag-o-matic toolchain-funcs versionator
9
10NP="${PN}-1.3"
11
12DESCRIPTION="Fast array and numerical python library"
13HOMEPAGE="http://numpy.scipy.org/ http://pypi.python.org/pypi/numpy"
14SRC_URI="mirror://sourceforge/numpy/${P}.tar.gz
15 doc? (
16 http://docs.scipy.org/doc/${NP}.x/numpy-html.zip -> ${NP}-html.zip
17 http://docs.scipy.org/doc/${NP}.x/numpy-ref.pdf -> ${NP}-ref.pdf
18 http://docs.scipy.org/doc/${NP}.x/numpy-user.pdf -> ${NP}-user.pdf
19 )"
20
21LICENSE="BSD"
22SLOT="0"
23KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd ~x86-freebsd ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
24IUSE="doc lapack test"
25
26RDEPEND="dev-python/setuptools
27 lapack? ( virtual/cblas virtual/lapack )"
28DEPEND="${RDEPEND}
29 lapack? ( dev-util/pkgconfig )
30 test? ( >=dev-python/nose-0.10 )
31 doc? ( app-arch/unzip )"
32RESTRICT_PYTHON_ABIS="3.*"
33
34pkg_setup() {
35 # See progress in http://projects.scipy.org/scipy/numpy/ticket/573
36 # with the subtle difference that we don't want to break Darwin where
37 # -shared is not a valid linker argument
38 if [[ ${CHOST} != *-darwin* ]] ; then
39 append-ldflags -shared
40 fi
41
42 # only one fortran to link with:
43 # linking with cblas and lapack library will force
44 # autodetecting and linking to all available fortran compilers
45 use lapack || return
46 [[ -z ${FC} ]] && FC=$(tc-getFC)
47 # when fortran flags are set, pic is removed.
48 FFLAGS="${FFLAGS} -fPIC"
49 export NUMPY_FCONFIG="config_fc --noopt --noarch"
50}
51
52src_unpack() {
53 unpack ${P}.tar.gz
54 if use doc; then
55 unzip -qo "${DISTDIR}"/${NP}-html.zip -d html || die
56 fi
57}
58
59src_prepare() {
60 epatch "${FILESDIR}"/${PN}-1.1.0-f2py.patch
61 epatch "${FILESDIR}"/${PN}-1.3.0-fenv-freebsd.patch # bug 279487
62 epatch "${FILESDIR}"/${P}-python-2.7.patch
63
64 # Gentoo patch for ATLAS library names
65 sed -i \
66 -e "s:'f77blas':'blas':g" \
67 -e "s:'ptf77blas':'blas':g" \
68 -e "s:'ptcblas':'cblas':g" \
69 -e "s:'lapack_atlas':'lapack':g" \
70 numpy/distutils/system_info.py \
71 || die "sed system_info.py failed"
72
73 if use lapack; then
74 append-ldflags "$(pkg-config --libs-only-other cblas lapack)"
75 sed -i -e '/NO_ATLAS_INFO/,+1d' numpy/core/setup.py || die
76 local libdir="${EPREFIX}"/usr/$(get_libdir)
77 cat >> site.cfg <<-EOF
78 [atlas]
79 include_dirs = $(pkg-config --cflags-only-I \
80 cblas | sed -e 's/^-I//' -e 's/ -I/:/g')
81 library_dirs = $(pkg-config --libs-only-L \
82 cblas blas lapack | sed -e 's/^-L//' -e 's/ -L/:/g' -e 's/ //g'):${libdir}
83 atlas_libs = $(pkg-config --libs-only-l \
84 cblas blas | sed -e 's/^-l//' -e 's/ -l/, /g' -e 's/,.pthread//g')
85 lapack_libs = $(pkg-config --libs-only-l \
86 lapack | sed -e 's/^-l//' -e 's/ -l/, /g' -e 's/,.pthread//g')
87 [blas_opt]
88 include_dirs = $(pkg-config --cflags-only-I \
89 cblas | sed -e 's/^-I//' -e 's/ -I/:/g')
90 library_dirs = $(pkg-config --libs-only-L \
91 cblas blas | sed -e 's/^-L//' -e 's/ -L/:/g' -e 's/ //g'):${libdir}
92 libraries = $(pkg-config --libs-only-l \
93 cblas blas | sed -e 's/^-l//' -e 's/ -l/, /g' -e 's/,.pthread//g')
94 [lapack_opt]
95 library_dirs = $(pkg-config --libs-only-L \
96 lapack | sed -e 's/^-L//' -e 's/ -L/:/g' -e 's/ //g'):${libdir}
97 libraries = $(pkg-config --libs-only-l \
98 lapack | sed -e 's/^-l//' -e 's/ -l/, /g' -e 's/,.pthread//g')
99 EOF
100 else
101 export {ATLAS,PTATLAS,BLAS,LAPACK,MKL}=None
102 fi
103
104 epatch "${FILESDIR}"/${P}-interix.patch
105}
106
107src_compile() {
108 distutils_src_compile ${NUMPY_FCONFIG}
109}
110
111src_test() {
112 testing() {
113 "$(PYTHON)" setup.py ${NUMPY_FCONFIG} build -b "build-${PYTHON_ABI}" install \
114 --home="${S}/test-${PYTHON_ABI}" --no-compile || die "install test failed"
115 pushd "${S}/test-${PYTHON_ABI}/"lib* > /dev/null
116 PYTHONPATH=python "$(PYTHON)" -c "import numpy; numpy.test()" 2>&1 | tee test.log
117 grep -q '^ERROR' test.log && die "test failed"
118 popd > /dev/null
119 rm -fr test-${PYTHON_ABI}
120 }
121 python_execute_function testing
122}
123
124src_install() {
125 [[ -z ${ED} ]] && local ED=${D}
126 distutils_src_install ${NUMPY_FCONFIG}
127 dodoc THANKS.txt DEV_README.txt COMPATIBILITY
128 rm -f "${ED}"/usr/lib/python*/site-packages/numpy/*.txt || die
129 docinto f2py
130 dodoc numpy/f2py/docs/*.txt || die "dodoc f2py failed"
131 doman numpy/f2py/f2py.1 || die "doman failed"
132 if use doc; then
133 insinto /usr/share/doc/${PF}
134 doins -r "${WORKDIR}"/html || die
135 doins "${DISTDIR}"/${NP}*pdf || die
136 fi
137}