#!/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=scotchpy

PYVERS = $(shell py3versions -sv)
PYVER_DEFAULT = $(shell py3versions -dv)

%:
	dh $@ --buildsystem=pybuild --with sphinxdoc

execute_after_dh_clean:
	rm -rf pyproject.toml

override_dh_auto_configure:
	PTSCOTCH=ON ./configure
	dh_auto_configure -- --configure-args=-DSKBUILD_PROJECT_NAME=$(PYBUILD_NAME)

override_dh_auto_test:
	cp -r tests .pybuild
	set -e; \
	for py in $(PYVERS); do \
	  PYLIBPATH=`pybuild --print build_dir -p$$py | awk '{print $$3}'`; \
	  (cd .pybuild/tests; \
	  PYTHONPATH=$${PYLIBPATH} python$$py -m pytest -v --with-mpi); \
	done

execute_after_dh_auto_build-indep: export http_proxy=127.0.0.1:9
execute_after_dh_auto_build-indep: export https_proxy=127.0.0.1:9
execute_after_dh_auto_build-indep:
	PYTHONPATH=`pybuild --print build_dir -p$(PYVER_DEFAULT)` python3 -m sphinx -N -bhtml \
	doc/source .pybuild/html # HTML generator
