#! /usr/bin/make -f

export PYBUILD_NAME=barcode
# Disable temporarily tests at build time, not working under sbuild.
export PYBUILD_DISABLE=test
export SETUPTOOLS_SCM_NO_WRITE = 1
export SETUPTOOLS_SCM_PRETEND_VERSION = $(DEB_VERSION_UPSTREAM)
export SETUPTOOLS_SCM_IGNORE_VCS = 1

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

execute_after_dh_auto_build-indep:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	cd docs && \
	PYTHONPATH=$(CURDIR) http_proxy='http://127.0.0.1:9/' https_proxy='https://127.0.0.1:9/' \
	sphinx-build -N -E -T -b html . $(CURDIR)/.pybuild/docs/html/
	rm -rf $(CURDIR)/.pybuild/docs/html/.doctrees
endif

override_dh_fixperms:
	dh_fixperms
	chmod 644 debian/python3-barcode/usr/share/python3-barcode/tests/*.py
	chmod 644 debian/python3-barcode/usr/lib/python3/dist-packages/barcode/fonts/*
