#!/usr/bin/make -f

export LC_ALL=C.UTF-8
export PYBUILD_INSTALL_DIR=/usr/share/beets/
# https://github.com/beetbox/beets/issues/1876
export PYBUILD_TEST_ARGS=-k "not test_completion"
export PYBUILD_AFTER_INSTALL=rm -r {destdir}{install_dir}/beets-*.dist-info/licenses/

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

execute_after_dh_auto_build:
ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
	PYTHONPATH=$(CURDIR) $(MAKE) -C docs html man
	# There seem to be leftover static js files.
	rm -rf docs/_build/man/_sphinx_design_static
endif

override_dh_installchangelogs:
	dh_installchangelogs docs/changelog.rst

execute_after_dh_fixperms:
	chmod a-x debian/beets/usr/share/beets/beets/dbcore/db.py \
		debian/beets/usr/share/beets/beets/ui/commands.py
