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

include /usr/share/dpkg/default.mk
export PYBUILD_NAME=toil

export PYBUILD_DESTDIR=debian/toil/
ifeq ($(PYBUILD_AUTOPKGTEST),1)
PREFIX=/usr/lib/python3/dist-packages/
endif
PYBUILD_TEST_ARGS=$(DEB_BUILD_OPTION_PARALLEL:%=-n %) --dist loadscope -vv -W ignore  -k "not (testVirtualEnv or DockstoreLookupTest or testMultiplejobs or testServices or test_file_hints or test_download_http or test_load_contents_http)" -m "not slow" --ignore $(PREFIX)toil/test/wdl/wdltoil_test.py --ignore $(PREFIX)toil/test/wdl/wdltoil_test_kubernetes.py
# testVirtualEnv - requires an internet connection to download packages from PyPI
# testMultiplejobs - flaky during parallel execution
# testServices - flaky during parallel execution https://bugs.debian.org/1101085
# test_file_hints - require unpackaged edit_distance
# test_download_http - requires network access
# test_load_contents_http - requires network access
# toil/test/wdl/wdltoil_test.py: ModuleNotFoundError: No module named 'WDL'
ifeq ($(PYBUILD_AUTOPKGTEST),1)
PYBUILD_TEST_ARGS += --pyargs toil.test
else
PYBUILD_TEST_ARGS += toil/test
endif
export PYBUILD_TEST_ARGS
export TOIL_SKIP_ONLINE=true TOIL_TEST_QUICK=True TOIL_SKIP_DOCKER=True

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_build:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	PYTHONPATH=$(CURDIR)/src http_proxy='127.0.0.1:9' $(MAKE) -C docs man SPHINXOPTS=""
endif
# If you need to rebuild the Sphinx documentation
# Add spinxdoc to the dh --with line
#	PYTHONPATH=$(CURDIR)/src http_proxy='127.0.0.1:9' $(MAKE) -C docs html # HTML generator

execute_after_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

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