#!/usr/bin/make -f

export PYBUILD_NAME=uncertainties
export DH_VERBOSE=1
export PYBUILD_DISABLE=test

%:
	dh $@ --with python2,python3,sphinxdoc  --buildsystem=pybuild

override_dh_auto_clean:
	# clean for Python 3.x recreates files which makes dpkg-source fail
	pybuild --clean --test-nose -i python{version} -p 2.7
	find . -name .pydistutils.cfg -delete
	rm uncertainties uncertainties.egg-info dist debian/html -rf

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=. http_proxy='http://127.0.0.1:9/' sphinx-build -N -bhtml doc debian/html

override_dh_installchangelogs:
	grep -A 1000 'Version history' PKG-INFO \
	| grep '^        - ' \
	| sed -e 's/^ *//g;s/  */ /g;s/$$/\n/g' \
	| fmt > changelog
	dh_installchangelogs

override_dh_auto_build:
	pybuild --build --test-nose -i python{version} -p "`pyversions -v -r`"
	pybuild --build --test-nose -i python{version} -p "`py3versions -v -r`"
	PYTHONPATH=`pybuild --print build_dir --interpreter python3` http_proxy='http://127.0.0.1:9/' sphinx-build -N -bhtml doc debian/html
