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

EAPI=8

DISTUTILS_EXT=1
DISTUTILS_USE_PEP517=standalone
PYTHON_COMPAT=( python3_13 )

inherit distutils-r1

DESCRIPTION="Triton compiler for PyTorch with the AMD ROCm backend"
HOMEPAGE="https://github.com/triton-lang/triton/ https://github.com/ROCm/triton/"
MY_WHEEL="pytorch_triton_rocm-${PV}-cp313-cp313-linux_x86_64.whl"
SRC_URI="https://download.pytorch.org/whl/${MY_WHEEL}"
S=${WORKDIR}

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

BDEPEND="app-arch/unzip"
DOCS=( licenses )

RDEPEND="
	>=dev-python/setuptools-40.8.0[${PYTHON_USEDEP}]
	sys-devel/gcc:*
"

QA_PREBUILT=( "usr/lib/python*/site-packages/triton/*" )

src_unpack() {
	unzip -j "${DISTDIR}/${MY_WHEEL}" '*.dist-info/licenses/*' -d licenses || die
}

python_compile() {
	distutils_wheel_install "${BUILD_DIR}/install" "${DISTDIR}/${MY_WHEEL}"
}