#!/usr/bin/make -f

export PYBUILD_NAME=torchvision

# 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)
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_RELEASE).$(DIST_VERSION)
SUBSTVARS_BINARY_VERSION := -Vbinary:Version="$(PKG_VERSION_TAG)"
SUBSTVARS_SOURCE_VERSION := -Vsource:Version="$(PKG_VERSION_TAG)"


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

# Otherwise I get a circular dependency because
# torchvision is used in torch documentation
SUBSTVARS_PYTHON_DEPENDS  := -Vpython:customDepends="python-numpy, python-pil, python-six"
SUBSTVARS_PYTHON3_DEPENDS := -Vpython3:customDepends="python3-numpy, python3-pil, python3-six"
SUBSTVARS_PYTHON_RECOMMENDS  := -Vpython:customRecommends="python-torch"
SUBSTVARS_PYTHON3_RECOMMENDS := -Vpython3:customRecommends="python3-torch"
override_dh_python3:
	dh_python3 --no-guessing-deps
override_dh_python2:
	dh_python2 --no-guessing-deps

override_dh_gencontrol:
	dh_gencontrol -- -v"$(PKG_VERSION_TAG)" \
	                   $(SUBSTVARS_BINARY_VERSION) \
	                   $(SUBSTVARS_SOURCE_VERSION) \
	                   $(SUBSTVARS_PYTHON_DEPENDS) \
	                   $(SUBSTVARS_PYTHON3_DEPENDS) \
	                   $(SUBSTVARS_PYTHON_RECOMMENDS) \
	                   $(SUBSTVARS_PYTHON3_RECOMMENDS)

# Same issue with unittests here...
override_dh_auto_test:
