#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

export PYBUILD_NAME=xarray
PY3VERS:= $(shell py3versions -s)

# add sphinx3-build to path 
export PATH:=$(PATH):$(CURDIR)/debian

# Disable checking for this release:
DEB_BUILD_OPTIONS += nocheck

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

override_dh_auto_clean:
	dh_auto_clean
ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
	$(MAKE) -C doc clean
endif

override_dh_auto_install: $(PYTHON3:%=install-python%)
	dh_auto_install
	find debian/python3-xarray -name '*.idx' -exec chmod -x {} \;

override_dh_auto_build:
	http_proxy=127.0.0.1:9 https_proxy=127.0.0.1:9 dh_auto_build
ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
	PYTHONPATH=$(CURDIR) $(MAKE) -C doc html
endif

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	for p in $(PY3VERS); do \
		PY3VERNUM=`echo $$p | sed -e 's/python//' `; \
		pybuild --test --test-pytest -i $$p -p $$PY3VERNUM  ;  \
		done
endif

override_dh_sphinxdoc:
	dh_sphinxdoc --exclude=MathJax.js
