#!/usr/bin/make -f

export PYBUILD_NAME=shap
export PYBUILD_TEST_PYTEST=1
EXCLUDED_TESTS :=
# Attempt to download stuff from Internet
EXCLUDED_TESTS += not test_keras_imdb_lstm
EXCLUDED_TESTS += and not test_tf_keras_mnist_cnn
EXCLUDED_TESTS += and not test_kernel_shap_with_a1a_sparse
EXCLUDED_TESTS += and not test_kernel_shap_with_high_dim_sparse
EXCLUDED_TESTS += and not test_sum_match_random_forest
EXCLUDED_TESTS += and not test_single_row_random_forest
EXCLUDED_TESTS += and not test_sum_match_gradient_boosting
EXCLUDED_TESTS += and not test_single_row_gradient_boosting
export PYBUILD_TEST_ARGS=-k "$(EXCLUDED_TESTS)"


# Get version from changelog as well as lsb_release
# to compute unique build version (useful for repo mirroring systems doing file pooling)
PKG_VERSION  := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
DIST_NAME    := $(shell lsb_release -si)
DIST_RELEASE := $(shell lsb_release -sc)
DIST_VERSION := $(shell lsb_release -sr)
PKG_VERSION_TAG := $(PKG_VERSION)+$(DIST_NAME).$(DIST_RELEASE).$(DIST_VERSION)
SUBSTVARS_BINARY_VERSION := -Vbinary:Version="$(PKG_VERSION_TAG)"
SUBSTVARS_SOURCE_VERSION := -Vsource:Version="$(PKG_VERSION_TAG)"


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

override_dh_auto_configure:
	sed -i 's!test_xgboost=True!test_xgboost=False!g' setup.py

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build -N -bhtml	docs/ build/html
	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build -N -bman	docs/ build/man

override_dh_auto_clean:
	dh_auto_clean
	rm -rf .eggs
	rm -rf .cache
	rm -f shap/_cext.so
	sed -i 's!test_xgboost=False!test_xgboost=True!g' setup.py

override_dh_python2:
	dh_python2
	dh_numpy

override_dh_python3:
	dh_python3
	dh_numpy3

override_dh_gencontrol:
	dh_gencontrol -- -v"$(PKG_VERSION_TAG)" $(SUBSTVARS_BINARY_VERSION) $(SUBSTVARS_SOURCE_VERSION)
