#!/usr/bin/make -f

export PYBUILD_NAME=torchsummary
export PYBUILD_TEST_PYTEST=1
export PYBUILD_TEST_ARGS=-v  -k"-test_frozen_layers_out -test_resnet_out -test_lstm_out"
# Link folder name so Debian Stretch pytest found the tests
export PYBUILD_BEFORE_TEST=cp -r {dir}/unit_test {build_dir}; cp -r {dir}/fixtures {build_dir}
export PYBUILD_AFTER_TEST=rm -r {build_dir}/unit_test {build_dir}/fixtures

# Get version from changelog as well as lsb_release
# to compute unique build version (useful for repo mirroring systems doing file pooling)
PKG_VERSION  := $(shell dpkg-parsechangelog | grep -E '^Version:' | cut -d' ' -f2)
PKG_UPSTREAM_VERSION := $(shell echo $(PKG_VERSION) | cut -d'-' -f1)
DIST_NAME    := $(shell lsb_release -si)
DIST_RELEASE := $(shell lsb_release -sc)
DIST_VERSION := $(shell lsb_release -sr)
PKG_VERSION_TAG := $(PKG_VERSION)+$(DIST_NAME).$(DIST_VERSION).$(DIST_RELEASE)

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

override_dh_auto_clean:
	dh_auto_clean
	rm -rf .pytest_cache .cache

override_dh_auto_test:
ifeq ($(filter nocheck,$(DEB_BUILD_PROFILES)),)
	dh_auto_test
endif

override_dh_gencontrol:
	dh_gencontrol -- -v"$(PKG_VERSION_TAG)"
