#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

export PYBUILD_NAME=metakernel
export PYBUILD_VERBOSE=1
export PYBUILD_TEST_ARGS=-o cache_dir=$(CURDIR)/.pytest-cache
export PYBUILD_BEFORE_TEST=touch {home_dir}/.bashrc; mkdir $(CURDIR)/.pytest-cache ; \
    PYTHONPATH={dir}/metakernel_python \
    IPYTHONDIR={home_dir}/.ipython \
    {interpreter} /usr/bin/ipcluster start -n=3 --daemonize
export PYBUILD_AFTER_TEST=IPYTHONDIR={home_dir}/.ipython ipcluster stop ; \
	rm -Rf $(CURDIR)/.pytest-cache

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_build:
ifeq (,$(filter nodoc,${DEB_BUILD_OPTIONS} ${DEB_BUILD_PROFILES}))
	PYTHONPATH=./metakernel_python/ python3 generate_help.py
	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build -N -bhtml docs/ build/html
	# replace static files copied from python3-sphinx-bootstrap-theme with symlinks
	find build/html/_static/ -type f -print0 | xargs -0 -L 1 debian/test_and_link.sh
endif

override_dh_installdocs:
	dh_installdocs --package=python3-metakernel
	dh_installdocs --package=python-metakernel-doc --doc-main-package=python3-metakernel

override_dh_installchangelogs:
	dh_installchangelogs HISTORY.rst
