#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export PYBUILD_NAME=refnx
export FORCE_SOURCE_DATE=1

pyversion=$(shell py3versions -d -v)

export PYBUILD_TEST_ARGS = -v -ra --deselect=refnx/reflect/tests/test_structure.py::TestStructure::test_to_from_orso --ignore=refnx/reflect/tests/test_jax.py
export PYTEST_QT_API = PyQt6


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

execute_after_dh_clean:
	make -C paper clean

execute_after_dh_auto_build:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	PYTHONPATH=$(CURDIR)/src/ \
	 http_proxy=http://127.0.0.1:9 \
	 https_proxy=https://127.0.0.1:9 \
	 python3 -m sphinx -N -bhtml doc/ build/html
	# Work around https://github.com/jupyter/jupyter-sphinx/issues/163
	cp /usr/lib/python3/dist-packages/jupyter_sphinx/thebelab/* build/html/_static/
	make -C paper
endif

execute_after_dh_auto_install:
	mv $(CURDIR)/debian/python3-refnx/usr/bin/refnx $(CURDIR)/debian/python3-refnx/usr/lib/python$(pyversion)/dist-packages/refnx/refnx-gui
	cp $(CURDIR)/debian/refnx-wrapper $(CURDIR)/debian/python3-refnx/usr/bin/refnx
	mkdir -p $(CURDIR)/debian/python3-refnx/usr/share/icons/hicolor/scalable/apps/
	cp ./refnx/reflect/_app/icons/scatteringevent.svg $(CURDIR)/debian/python3-refnx/usr/share/icons/hicolor/scalable/apps/refnx.svg
