#!/usr/bin/make -f

# DH_VERBOSE := 1
export LC_ALL=C.UTF-8
include /usr/share/dpkg/default.mk

export PYBUILD_NAME=spython
export PYBUILD_TEST_PYTEST=1
export PYBUILD_TEST_ARGS=-k 'not (test_client or test_check_get_singularity_version or test_has_no_instances or test_check_install)'
ifeq ($(PYBUILD_AUTOPKGTEST),1)
PYBUILD_TEST_ARGS+=--pyargs spython
endif

subcommands=recipe shell test
tagline=\- Singularity Python, Singularity Client

# these tests requires singularity, which will never migrate to testing/stable
# due to https://bugs.debian.org/1029669

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_install:
	dh_auto_install
	PYTHONPATH=./debian/python3-spython/usr/lib/python$$(py3versions -v -d)/dist-packages \
        PATH=./debian/python3-spython/usr/bin:$${PATH} help2man --no-discard-stderr \
		--no-info --version-string $(DEB_VERSION_UPSTREAM) \
		--name "spython ${tagline}" spython > debian/spython.1
	for subcommand in ${subcommands}; do printf \
		"[NAME]\nspython_$${subcommand} ${tagline}\n" \
		> debian/spython_$${subcommand}-man-include; done
	for subcommand in ${subcommands}; do \
		PYTHONPATH=./debian/python3-spython/usr/lib/python$$(py3versions -v -d)/dist-packages \
		PATH=./debian/python3-spython/usr/bin:$${PATH} help2man --no-discard-stderr \
		--no-info --version-string="$(DEB_VERSION_UPSTREAM)" \
		--include debian/spython_$${subcommand}-man-include \
		"spython $${subcommand}" > \
		debian/spython_$${subcommand}.1; done
