#!/usr/bin/make -f

export DH_VERBOSE=1
export PYBUILD_NAME=pyfai
export PYBUILD_SYSTEM=pyproject
#export PYBUILD_BUILD_ARGS := -Csetup-args=-Dcython=cython3

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

override_dh_clean:
	dh_clean
	rm -f $(patsubst %.pyx,%.c,$(wildcard pyFAI/ext/*.pyx))
	rm -rf build
	rm -rf *.egg-info

override_dh_install:
	dh_numpy3

	# move the scripts to right package
	dh_install -p pyfai debian/python3-pyfai/usr/bin usr/
	# remove all scripts installed by pybuild
	rm -rf debian/python3-pyfai/usr/bin

	#Finally install stuff
	dh_install

# inactive test for now
override_dh_auto_test:
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="PYTHONPATH={build_dir} PYFAI_TESTIMAGES=testimages PYFAI_DATA=$(shell pwd) {interpreter} ./run_tests.py --installed" dh_auto_test

#override_dh_installman:
#	python3 setup.py build_man
#	dh_installman -p pyfai build/man/*.1

override_dh_installdocs:
	python3 build-doc.py
	dh_installdocs "build/sphinx" -p pyfai-doc
	dh_installdocs
