#!/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 $@ --buildsystem=pybuild

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

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 -n auto --dist loadscope -vv -W ignore --ignore src/toil/test/lib/aws/test_s3.py --ignore src/toil/test/provisioners/aws/awsProvisionerTest.py --ignore src/toil/test/wdl/wdltoil_test.py --ignore src/toil/test/cwl/cwlTest.py --ignore src/toil/test/src/promisedRequirementTest.py --ignore src/toil/test/lib/test_ec2.py --ignore src/toil/test/batchSystems/batchSystemTest.py --ignore src/toil/test/lib/aws/test_iam.py -k "not (test_bioconda or test_run_conformance or testImportFtpFile or ToilWdlIntegrationTest or SortTest or testCwlexample or testVirtualEnv or ToilDocumentationTest or test_cwl_toil_kill or testImportReadFileCompatibility or CleanWorkDirTest or DeferredFunctionTest or WdlToilTest or test_cactus_integration)" {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
