#!/usr/bin/make -f
export PYBUILD_TEST_ARGS=--no-cov --ignore=tests/test_api.py --ignore=tests/test_a01_api.py -k "not test_device_trait_command_parsing" --snapshot-warn-unused
export PYBUILD_AFTER_BUILD=find {build_dir} -type f -name "*.py" -exec sed -i 's/^from Crypto\./from Cryptodome./g' {{}} +
export PYBUILD_AFTER_INSTALL=rm -rf {destdir}/usr/lib/python3*/dist-packages/roborock/devices/README.md

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	for py in `py3versions -s`; do \
	    build_dir=".pybuild/cpython3_$${py#python}/build"; \
	    cp -a tests pyproject.toml "$$build_dir/"; \
	    cd "$$build_dir"; \
	    find tests -type f -name "*.py" -exec sed -i 's/^from Crypto\./from Cryptodome./g' {} +; \
	    $${py} -m pytest tests ${PYBUILD_TEST_ARGS}; \
	    rm -r tests pyproject.toml; \
		cd $(CURDIR); \
	done
endif
