#!/usr/bin/env modbuild

SOURCE_URL="https://www.python.org/ftp/python/$V/$P-$V.tgz"

export LDFLAGS=""
export CPPFLAGS=""
pbuild::configure() {
	export LDFLAGS="-L${OPENSSL_LIBRARY_DIR}"
	export CPPFLAGS="-fPIC -I${OPENSSL_INCLUDE_DIR} -I${OPENSSL_INCLUDE_DIR}/openssl"
	export LD_LIBRARY_PATH+=":${PREFIX}/lib"
	"${MODULE_SRCDIR}"/configure \
		--prefix="${PREFIX}" \
		--enable-shared \
		|| exit 1
}

pbuild::post_install() {
	export LDFLAGS="-L${OPENSSL_LIBRARY_DIR}"
	export CPPFLAGS="-I${OPENSSL_INCLUDE_DIR} -I${OPENSSL_INCLUDE_DIR}/openssl"
	export LD_LIBRARY_PATH+=":${PREFIX}/lib"
	ln -fs "${PREFIX}/bin/python${V%%.*}" "${PREFIX}/bin/python"
	ln -fs "${PREFIX}/include/python${V%.*}m" "${PREFIX}/include/python"
	ln -fs "${PREFIX}/include/python${V%.*}m" "${PREFIX}/include/python${V%.*}"
	PATH+=":${PREFIX}/bin"
	cd "${BUILD_BLOCK_DIR}"
	"${PREFIX}/bin/python" 'get-pip.py'
	pip${V_MAJOR} install numpy
	pip${V_MAJOR} install scipy
	pip${V_MAJOR} install matplotlib
	pip${V_MAJOR} install ipython
	pip${V_MAJOR} install pandas
	pip${V_MAJOR} install sympy
	pip${V_MAJOR} install nose
	#pip${V_MAJOR} install mpi4py
}

pbuild::add_to_group 'Programming'
pbuild::make_all

