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

# SasView insists on writing to ~/sasview.log, sasmodels likes caches
export HOME = $(CURDIR)/build/

# Force pdflatex to use SOURCE_DATE_EPOCH for \today too
export FORCE_SOURCE_DATE = 1

# Skip test that needs unpackaged external library
export PYBUILD_TEST_ARGS = -v -s -k "not test_debye_impl" test


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

execute_after_dh_auto_clean:
	# clean up tests
	find test -name logs -type d -exec rm -rf {} +

execute_after_dh_auto_install:
	# tidy up some items that creep into the module but should not
	rm -rf debian/python3-sasview/usr/lib/python*/dist-packages/doc
	find debian/python3-sasview \( -name convert\*.sh -o -name convert\*.bat -o -name Thumbs.db \) -delete
	# move the executable into the sasview package
	mkdir -p debian/sasview/usr/bin
	mv $(CURDIR)/debian/python3-sasview/usr/bin/sasview $(CURDIR)/debian/sasview/usr/bin/sasview
	rm -rf $(CURDIR)/debian/python3-sasview/usr/lib/python3*/dist-packages/sas/docs*/

execute_after_dh_installdocs:
	find debian/sasview-doc/usr/share/doc/sasview -name __pycache__ -exec rm -rf {} +
	find debian/* -name doctrees -type d -exec rm -rf {} +

execute_after_dh_fixperms:
	find debian/python3-sasview/usr/lib/python*/dist-packages/ -type f -exec chmod a-x {} +

override_dh_compress:
	dh_compress -X usr/share/doc/sasview/docs-source/
