#!/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_retrieve \
and not test_offline_retrieve \
and not test_retrieve_all \
and not test_download_script \
and not test_start_time \
and not test_end_time \
and not test_mimic_TPW2_nc \
and not TestAngleGeneration \
and not test_get_luts \
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 \
and not test_get_satpos_from_satname \
and not test_distributed \
and not test_rayleigh_corrector \
and not test_rayleigh_with_angles \
and not test_float_write_with_unit_conversion \
and not test_aggregate \
and not test_median \
and not test_no_downloads_in_tests" \
--ignore=${TESTDIR}/reader_tests/test_insat3d_img_l1b_h5.py \
--ignore=${TESTDIR}/reader_tests/gms/test_gms5_vissr_l1b.py \
--ignore=${TESTDIR}/reader_tests/gms/test_gms5_vissr_navigation.py \
${TESTDIR}

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

%:
	dh $@ --with python3,numpy3,sphinxdoc --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 {} +
