#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/dpkg/pkg-info.mk
export SETUPTOOLS_SCM_PRETEND_VERSION=$(DEB_VERSION_UPSTREAM)

ifneq (,${PYBUILD_AUTOPKGTEST})
TESTDIR=/usr/lib/python3/dist-packages/satpy/tests
else
TESTDIR=satpy/tests
endif

export PYBUILD_NAME=satpy
export PYBUILD_AFTER_INSTALL=rm -rf \
{destdir}/{install_dir}/benchmarks \
{destdir}/{install_dir}/dask-worker-space \
{destdir}/{install_dir}/dummy*
export PYBUILD_TEST_ARGS=\
-k "not test__slice \
and not test_init \
and not test_strip_invalid_lat \
and not test_retrieve \
and not test_offline_retrieve \
and not test_retrieve_all \
and not test_download_script \
and not test_basic_default_not_provided \
and not test_rayleigh_corrector \
and not test_rayleigh_with_angles \
and not test_median \
and not test_no_downloads_in_tests \
and not test_convert_remote_files_to_fsspec_fsfile \
and not test_convert_remote_files_to_fsspec_filename_dict \
and not test_convert_remote_files_to_fsspec_mixed_sources" \
--ignore=${TESTDIR}/reader_tests/gms/test_gms5_vissr_l1b.py \
--ignore=${TESTDIR}/reader_tests/gms/test_gms5_vissr_navigation.py \
${TESTDIR}
# Python 3.12 does not appear to be compatible with satpy currently.
# Check and see if this can be reverted every time a new satpy comes from
# Debian.
export PYBUILD_DISABLE=python3.12

ifneq (,$(filter $(DEB_BUILD_ARCH),armhf))
export PYBUILD_DISABLE=test
endif

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_build-indep: export http_proxy=127.0.0.1:9
execute_after_dh_auto_build-indep: export https_proxy=127.0.0.1:9
execute_after_dh_auto_build-indep:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	PSP_CONFIG_FILE=$(CURDIR)/debian/pyspectral_dummycfg.yaml \
	PYTHONPATH={build_dir} \
	python3 -m sphinx -N -E -T -b html doc/source $(CURDIR)/.pybuild/docs/html
endif

execute_after_dh_fixperms:
	find debian/python*satpy -name 'agri_l1.*' -exec chmod -x {} +
