#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export PYBUILD_NAME=pybedtools
export MATPLOTLIBRC=$(CURDIR)/debian/

export PYBUILD_BEFORE_TEST=

ifneq ($(PYBUILD_AUTOPKGTEST), 1)
export PYBUILD_BEFORE_TEST+= cp {dir}/debian/mpl-expected.png {build_dir}/pybedtools/test/ ;
endif

export PYBUILD_TEST_ARGS=-k "not test_chromsizes" --pyargs pybedtools

export PYBUILD_AFTER_TEST=cd {dir}/docs ; PYTHONPATH={build_dir} {interpreter} -m sphinx -b doctest -d build/doctrees   source build/doctest

defaultpython=$(shell py3versions -dv)

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

execute_after_dh_auto_build:
	cd docs ; PYTHONPATH=$(shell pybuild --pyver ${defaultpython} --print build_dir | awk '-F: ' '{print $$2}') python${defaultpython} -m sphinx -N -b html source html

execute_after_dh_install:
	rm -f debian/python3-pybedtools/usr/lib/python3*/dist-packages/pybedtools/test/prevent_open_file_regression \
	      debian/python3-pybedtools/usr/lib/python3*/dist-packages/foo.bed \
	      debian/python3-pybedtools/usr/lib/python3*/dist-packages/genome.txt
