# Template file for 'python-numpy'
pkgname=python-numpy
version=1.9.2
revision=1
wrksrc="numpy-${version}"
build_style=python-module
python_versions="2.7 3.4"
hostmakedepends="python-setuptools python3.4-setuptools gcc-fortran"
makedepends="python-devel python3.4-devel blas-devel lapack-devel"
pycompile_module="numpy"
short_desc="Fast and sophisticated array facility to Python2"
_short_desc="${short_desc/Python2/Python3.4}"
maintainer="Alessio Sergi <al3hex@gmail.com>"
homepage="http://www.numpy.org/"
license="3-clause-BSD"
distfiles="${SOURCEFORGE_SITE}/numpy/NumPy/${version}/numpy-${version}.tar.gz"
checksum=325e5f2b0b434ecb6e6882c7e1034cc6cdde3eeeea87dbc482575199a6aeef2a
nocross=yes

export ATLAS=None
LDFLAGS="-shared"

pre_build() {
	# make sure _dotblas.so gets built
	sed -i '/NO_ATLAS_INFO/,+1d' numpy/core/setup.py

	# remove shebangs
	find numpy -type f -name '*.py' -exec sed -i '/^#!.*python$/d' {} +
}
post_install() {
	# create symlinks for unversioned f2py* scripts
	ln -sf f2py2.7 ${DESTDIR}/usr/bin/f2py
	ln -sf f2py3.4 ${DESTDIR}/usr/bin/f2py3

	# create compat symlinks for .h files
	vmkdir usr/include/python2.7
	ln -sfr ${DESTDIR}/usr/lib/python2.7/site-packages/numpy/core/include/numpy \
		${DESTDIR}/usr/include/python2.7
	vmkdir usr/include/python3.4m
	ln -sfr ${DESTDIR}/usr/lib/python3.4/site-packages/numpy/core/include/numpy \
		${DESTDIR}/usr/include/python3.4m

	# install f2py*.1 man pages and license
	vman doc/f2py/f2py.1
	vman doc/f2py/f2py.1 f2py3.1
	vlicense LICENSE.txt LICENSE
}

python-numpy-devel_package() {
	depends="${sourcepkg}-${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include/python2.7
		vmove usr/lib/python2.7/site-packages/numpy/core/include/numpy
		vmove usr/lib/python2.7/site-packages/numpy/random/randomkit.h
		vmove usr/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h
	}
}
python3.4-numpy_package() {
	pycompile_version="3.4"
	pycompile_module="numpy"
	short_desc="${_short_desc}"
	pkg_install() {
		vmove usr/bin/f2py3*
		vmove usr/lib/python3.4
		vmove usr/share/man/man1/f2py3.1
		vlicense ${wrksrc}/LICENSE.txt LICENSE
	}
}
python3.4-numpy-devel_package() {
	depends="python3.4-numpy-${version}_${revision}"
	short_desc="${_short_desc} - development files"
	pkg_install() {
		vmove usr/include/python3.4m
		vmove usr/lib/python3.4/site-packages/numpy/core/include/numpy
		vmove usr/lib/python3.4/site-packages/numpy/random/randomkit.h
		vmove usr/lib/python3.4/site-packages/numpy/f2py/src/fortranobject.h
	}
}
