#!/usr/bin/make -f
#export DH_VERBOSE = 1

export PYBUILD_NAME=toil

export PYBUILD_DESTDIR_python3=debian/toil/

#export PYBUILD_DISABLE=test
export PYBUILD_DISABLE_python2=1
%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=$(CURDIR)/src $(MAKE) -C docs man

override_dh_auto_install:
	dh_auto_install
	find $(CURDIR)/debian -name cwltoil -delete
	# remove the below once mesos is packaged and tested
	find $(CURDIR)/debian -name _toil_mesos_executor -delete

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	PYBUILD_SYSTEM=custom \
		PYBUILD_TEST_ARGS='HOME={home_dir} {interpreter} setup.py develop --user && PYTHONPATH={dir}/src:$$PYTHONPATH PATH={home_dir}/.local/bin/:$$PATH TOIL_TEST_QUICK=True TOIL_SKIP_DOCKER=True {interpreter} -m pytest -vv -W ignore --ignore src/toil/test/provisioners/aws/awsProvisionerTest.py --ignore src/toil/test/wdl/toilwdlTest.py --ignore src/toil/test/cwl/cwlTest.py -k "not test_bioconda and not test_run_conformance and not testImportFtpFile and not ToilWdlIntegrationTest and not SortTest" {dir}/src/toil/test' \
		dh_auto_test
endif

# If you need to rebuild the Sphinx documentation
# Add spinxdoc to the dh --with line
#override_dh_auto_build:
#	dh_auto_build
#	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build -N -bhtml docs/ build/html # HTML generator
#	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build -N -bman  docs/ build/man  # Manpage generator

override_dh_auto_clean:
	rm -rf .pybuild
	rm -rf docs/_build
	find . -name "*.pyc" -delete
