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

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

include /usr/share/dpkg/pkg-info.mk

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 \
and not test_hvplot_basic_with_area \
and not test_hvplot_basic_with_swath \
and not test_hvplot_rgb_with_area \
and not test_loading_lon_lat \
and not test_loading_sensor_angles \
and not test_loading_solar_angles \
and not test_get_ti_lon_lats \
and not test_distributed \
and not test_correct_area_clearsky_different_resolutions \
and not test_available_reader \
and not test_find_registerable \
and not test_filenames_as_path \
and not test_no_parameters \
and not test_bad_sensor \
and not test_sensor \
and not test_sensor_no_files \
and not test_no_reader \
and not test_basic_check_satpy \
and not test_plugin_reader_available_readers \
and not test_filenames_only \
and not test_add_grid_mapping_oblique_mercator \
and not test_palettize \
and not test_viirs \
and not test_basic_default_provided \
and not test_scene_dynamic_available_datasets \
and not test_read_real_segment \
and not test_read_physical_seviri_nat_file" \
--ignore=${TESTDIR}/reader_tests/gms/test_gms5_vissr_l1b.py \
--ignore=${TESTDIR}/reader_tests/gms/test_gms5_vissr_navigation.py \
--ignore=${TESTDIR}/reader_tests/test_viirs_edr_active_fires.py \
--ignore=${TESTDIR}/reader_tests/test_mviri_l1b_fiduceo_nc.py \
${TESTDIR}

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

ifneq (,$(filter $(DEB_BUILD_ARCH),arm64))
PYBUILD_TEST_ARGS+=--ignore=${TESTDIR}/test_regressions.py
export PYBUILD_TEST_ARGS
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)))
	cp debian/area_def_list.rst doc/source
	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 {} +
	find debian/python*satpy -name 'image_comparison.feature' -exec chmod -x {} +