# Copyright 1999-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 DISTUTILS_USE_PEP517=no PYTHON_COMPAT=( python3_{12..14} ) inherit distutils-r1 MY_PN=${PN//-/_} MY_BASE="https://files.pythonhosted.org/packages" DESCRIPTION="NVIDIA CUTLASS Python DSL — base shared libs" HOMEPAGE=" https://github.com/NVIDIA/cutlass https://pypi.org/project/nvidia-cutlass-dsl-libs-base/ " SRC_URI=" python_targets_python3_12? ( ${MY_BASE}/d6/ba/f8c3f7db3de25be75e13527cd88a3019f0036370c9769ceefd1cf8165c76/${MY_PN}-${PV}-cp312-cp312-manylinux_2_28_x86_64.whl ) python_targets_python3_13? ( ${MY_BASE}/2a/bf/b33e5cecde6ea3cecbb604b8dee8d8b0c07a42c886f2929a709fdcd86f8b/${MY_PN}-${PV}-cp313-cp313-manylinux_2_28_x86_64.whl ) python_targets_python3_14? ( ${MY_BASE}/f0/47/aab054ab9f2400f803233d1506019f4e5d93ef9c30e8000fc62902a516cb/${MY_PN}-${PV}-cp314-cp314-manylinux_2_28_x86_64.whl ) " S="${WORKDIR}" LICENSE="NVIDIA-CUTLASS" SLOT="0" KEYWORDS="-* ~amd64" # The CUTLASS EULA prohibits redistributing the binary payload. RESTRICT="bindist mirror strip" # Wheel-only binary subpackage required by nvidia-cutlass-dsl's base install. # verified 2026-08-04 RDEPEND=" >=dev-python/cuda-python-12.8[${PYTHON_USEDEP}] dev-python/numpy[${PYTHON_USEDEP}] dev-python/typing-extensions[${PYTHON_USEDEP}] " QA_PREBUILT="usr/lib/python3.*/site-packages/nvidia_cutlass_dsl/*" src_unpack() { mkdir -p "${S}/wheel" || die local f for f in ${A}; do cp "${DISTDIR}/${f}" "${S}/wheel/" || die done } python_install() { local pyver=${EPYTHON#python} local cptag=cp${pyver//./} local whl="${MY_PN}-${PV}-${cptag}-${cptag}-manylinux_2_28_x86_64.whl" [[ -f ${S}/wheel/${whl} ]] || die "expected wheel ${whl} not found" ${EPYTHON} -m installer --destdir="${D}" "${S}/wheel/${whl}" || die # The base and cu13 wheels overlap with differing content. Mirror pip's # cu13-overwrites-base result by retaining only base's two unique files; # Portage would otherwise reject 179 collisions. # verified 2026-08-04 local sp="${D}$(${EPYTHON} -c 'import sysconfig; print(sysconfig.get_path("purelib"))')" local nvdir="${sp}/nvidia_cutlass_dsl" local keep_re='^(LICENSE|lib/libcuda_dialect_runtime_static\.a)$' local f rel while IFS= read -r -d '' f; do rel=${f#${nvdir}/} if [[ ! ${rel} =~ ${keep_re} ]]; then rm -f "${f}" || die "rm ${f} failed" fi done < <(find "${nvdir}" -type f -print0) find "${nvdir}" -type d -empty -delete # Let cu13 own its identical .pth that enables the cutlass import path. rm -f "${sp}/nvidia_cutlass_dsl.pth" || die python_optimize }