#!/usr/bin/make -f

DH_VERBOSE := 1

DEBPKGNAME:=$(shell dpkg-parsechangelog | awk '/^Source:/ {print $$2}')
docpkg:=$(DEBPKGNAME)-doc

export PYBUILD_NAME=ruffus

pyrun = DEB_BUILD_OPTIONS= pybuild -s custom -p $(shell pyversions -dv) --test --test-args

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

override_dh_auto_build:
	$(pyrun) 'make --directory=doc html'
	## latexpdf # <--- several LaTeX errors occure - just take the PDF provided by upstream

override_dh_installdocs:
	dh_installdocs -ppython-ruffus-doc doc/_build/html
	dh_installdocs -A

override_dh_auto_test:
	# cd ruffus/test && . $(CURDIR)/debian/tests/run-unit-test
	cd ruffus/test && \
	sh ./run_all_unit_tests.cmd && \
	sh ./run_all_unit_tests3.cmd && \
	rm -rf .ruffus_history.sqlite __pycache__ *.pyc

override_dh_auto_clean:
	dh_auto_clean
	rm -rf ruffus/test/temp_branching_dir \
	       ruffus/test/temp_filesre_combine \
	       ruffus/test/test_pausing_dir \
	       ruffus/test/tmp_test_job_history_with_exceptions \
	       ruffus/test/.ruffus_history.sqlite \
	       ruffus/__pycache__ \
	       doc/_build/html \
	       doc/_build/doctrees \
	       ruffus/test/*.log \
	       .ruffus_history.sqlite

get-orig-source:
	uscan --verbose --force-download --repack --compression xz
