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

EAPI=8

PYPI_NO_NORMALIZE=1
DISTUTILS_USE_PEP517=setuptools
PYTHON_COMPAT=( python3_{12..14} )

inherit distutils-r1 pypi

MY_PN="Telethon"
MY_PV="${PV/_alph/}"
DESCRIPTION="Full-featured Telegram client library for Python 3"
HOMEPAGE="
	https://pypi.org/project/tulir-telethon/
	https://github.com/tulir/Telethon/
"
SRC_URI="https://github.com/tulir/${MY_PN}/archive/refs/tags/v${MY_PV}.tar.gz -> ${P}.gh.tar.gz"
S="${WORKDIR}/${MY_PN}-${MY_PV}"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"

RDEPEND="
	dev-python/cryptg[${PYTHON_USEDEP}]
	dev-python/hachoir[${PYTHON_USEDEP}]
	dev-python/pillow[${PYTHON_USEDEP}]
	dev-python/pyaes[${PYTHON_USEDEP}]
	dev-python/pysocks[${PYTHON_USEDEP}]
	dev-python/python-socks[${PYTHON_USEDEP}]
	dev-python/rsa[${PYTHON_USEDEP}]
"

EPYTEST_PLUGINS=( pytest-asyncio )
EPYTEST_DESELECT=(
	# incompatible with recent pytest-asyncio changes
	tests/telethon/test_helpers.py::TestSyncifyAsyncContext
)

distutils_enable_tests pytest

python_test() {
	epytest tests/telethon
}
