# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DISTUTILS_USE_PEP517=setuptools
PYTHON_COMPAT=( python3_{11..14} )

inherit distutils-r1

DESCRIPTION="Extract icons from Windows PE files (.exe/.dll)"
HOMEPAGE="
	https://github.com/jlu5/icoextract/
	https://pypi.org/project/icoextract/
"
# The PyPI sdist ships the tests without the executables they read; the tag
# archive has the sources and Makefile that build them.
SRC_URI="https://github.com/jlu5/icoextract/archive/refs/tags/${PV}.tar.gz -> ${P}.gh.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~arm64 ~x86"
# The test executables need both mingw targets, i686 is x86-only.
RESTRICT="arm64? ( test )"

RDEPEND="
	dev-python/pefile[${PYTHON_USEDEP}]
	dev-python/pillow[${PYTHON_USEDEP}]
"
BDEPEND="
	test? (
		!arm64? ( dev-util/mingw64-toolchain[abi_x86_32] )
		media-gfx/imagemagick
	)
"

EPYTEST_PLUGINS=()
distutils_enable_tests pytest

src_test() {
	emake -C tests
	distutils-r1_src_test
}