#!/usr/bin/make -f
# -*- makefile -*-

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

export PYBUILD_NAME=lmfit

## This might have been used, but doctest should be optional
## https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=749506
#export PYBUILD_TEST_NOSE=1

# copy the tests to the build dir to be able to pass nose
export PYBUILD_AFTER_BUILD=cp -r NIST_STRD {build_dir}
export PYBUILD_BEFORE_INSTALL=rm -fr {build_dir}/NIST_STRD
export PYBUILD_AFTER_INSTALL_python2=dh_numpy
export PYBUILD_AFTER_INSTALL_python3=dh_numpy3

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

override_dh_clean:
	rm -rf doc/_static/conf_interval2.png
	rm -rf doc/_static/conf_interval.png
	dh_clean

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=. http_proxy='localhost' sphinx-build -N -bhtml doc/ build/html  # HTML generator

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	find .pybuild -name build -type d -exec ln -s $(CURDIR)/examples \{\} \;
	dh_auto_test
endif

override_dh_installdocs-indep:
	dh_installdocs -i
	find debian/python-$(PYBUILD_NAME)-doc/usr/share/doc -name "*.html" -type f | xargs sed -i 's;https://cdn[js]*\..*/MathJax.js;_static/MathJax.js;g'
	ln -s /usr/share/javascript/mathjax/MathJax.js  debian/python-$(PYBUILD_NAME)-doc/usr/share/doc/python-$(PYBUILD_NAME)/html/_static

override_dh_python3:
	dh_python3
	find . -name python3.7 -type d | xargs rm -rf
