#!/usr/bin/make -f

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

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

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

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

build-python%:
	python$* setup.py build

override_dh_auto_install: $(PYTHON3:%=install-python%)
	dh_auto_install

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

# No dask for python2, so skip
override_dh_auto_test:
	# pybuild --test --test-pytest -i $(PY3VERS) -p $(PY3VERNUM)
	# don't try py3.7 until pandas (dep) is built for py3.7
	pybuild --test --test-pytest -i python3.6 -p 3.6

override_dh_sphinxdoc:
	dh_sphinxdoc --exclude=MathJax.js
	mv debian/python-xarray-doc/usr/share/doc/python-xarray/html debian/python-xarray-doc/usr/share/doc/python-xarray-doc
	rmdir debian/python-xarray-doc/usr/share/doc/python-xarray
