#!/usr/bin/make -f
#export DH_VERBOSE=1

export PYBUILD_NAME=vcr

export http_proxy=
export https_proxy=

include /usr/share/dpkg/pkg-info.mk

BUILD_DATE  = $(shell LC_ALL=C date -u "+%B %d, %Y" -d "@$(SOURCE_DATE_EPOCH)")
SPHINXOPTS := -D html_last_updated_fmt="$(BUILD_DATE)"

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

override_dh_auto_test:
ifeq (~nd,$(findstring ~nd,$(DEB_VERSION)))
	PYBUILD_SYSTEM=custom PYBUILD_TEST_ARGS="{interpreter} -m pytest -v -x -rs" dh_auto_test
endif
# don't run tests on Debian because they currently need net connection, cf. #795940
# but run them on Neurodebian by request of the sponsor

override_dh_installdocs:
	pandoc -f rst -t plain -o .pybuild/README README.rst
	dh_installdocs -A .pybuild/README

override_dh_installchangelogs:
	pandoc -f rst -t plain -o .pybuild/changelog docs/changelog.rst
	dh_installchangelogs -A .pybuild/changelog

override_dh_sphinxdoc:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=. python3 -m sphinx $(SPHINXOPTS) -N -bhtml docs/ \
		debian/python-vcr-doc/usr/share/doc/python-vcr-doc/html/

	# Remove the zero byte file in doc directory.
	rm debian/python-vcr-doc/usr/share/doc/python-vcr-doc/html/.nojekyll

	dh_sphinxdoc
endif
