#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1
include /usr/share/dpkg/buildopts.mk
export PYBUILD_NAME=pyranges
export PYBUILD_TEST_ARGS=-n $(DEB_BUILD_OPTION_PARALLEL) \
	-k "not tutorial_doctest"

# The upstream test suite fails on 32-bit architectures, see #1103074.
# This must take effect for dpkg-buildpackage (dh_auto_test) *and* for
# autopkgtest, where the pybuild template calls pytest directly without the
# dh sequencer - an override_dh_auto_test target would be ignored there.
# PYBUILD_TEST_ARGS is read by pybuild itself, so it reaches both.
ifneq (,$(filter $(DEB_HOST_ARCH), i386 armhf armel mipsel powerpc))
export PYBUILD_TEST_ARGS = --collect-only
endif

export PYBUILD_AFTER_INSTALL=rm -fr {destdir}/usr/lib/python3*/dist-packages/pyranges-*/top_level.txt

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_build:
	echo 'Generating corresponding files ...'
	cat debian/missing-sources/control.sam| samtools view -Sb - > pyranges/example_data/control.bam
	samtools index pyranges/example_data/control.bam pyranges/example_data/control.bam.bai

execute_after_dh_install:
	find debian/ -name *.bam* | xargs rm -rf
	find debian/ -name 'hi' | xargs rm -rf
	find debian/ -name '.hypothesis' | xargs rm -rf
