#! /usr/bin/make -f

export PYBUILD_NAME=biomaj-download
DTMP = $(CURDIR)/debian/python3-biomaj3-download
PRESERVED_FILE = $(CURDIR)/biomaj_download/message/downmessage_pb2.py

%:
	dh $@ --buildsystem=pybuild

execute_before_dh_clean:
	rm -rf biomaj_download.egg-info
	if [ -f $(PRESERVED_FILE).bak ] \
	; then mv -v $(PRESERVED_FILE).bak $(PRESERVED_FILE) \
	; fi

execute_before_dh_auto_configure:
	cp -av $(PRESERVED_FILE) $(PRESERVED_FILE).bak

execute_before_dh_auto_build:
	cd biomaj_download/message \
	&& protoc --python_out=. downmessage.proto

execute_after_dh_install:
	sed -i '1s;^;#!/usr/bin/python3\n;' \
		$(DTMP)/usr/bin/biomaj_download_consumer.py

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	LOCAL_IRODS=0 NETWORK=0 python3 -m pytest -v tests/biomaj_tests.py
endif
