|
| 1 | +# Copyright 2020-2024 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | + |
| 6 | +PYTHON_COMPAT=( python3_{11..12} ) |
| 7 | +DISTUTILS_SINGLE_IMPL=1 |
| 8 | +DISTUTILS_USE_PEP517=setuptools |
| 9 | +DISTUTILS_EXT=1 |
| 10 | +ROCM_SKIP_GLOBALS=1 |
| 11 | +inherit cuda distutils-r1 multiprocessing rocm |
| 12 | + |
| 13 | +DESCRIPTION="Data manipulation and transformation for audio signal processing" |
| 14 | +HOMEPAGE="https://github.com/pytorch/audio" |
| 15 | +SRC_URI="https://github.com/pytorch/audio/archive/v${PV}.tar.gz -> ${P}.tar.gz" |
| 16 | +S="${WORKDIR}/audio-${PV}" |
| 17 | + |
| 18 | +LICENSE="BSD" |
| 19 | +SLOT="0" |
| 20 | +KEYWORDS="~amd64" |
| 21 | +IUSE="cuda rocm ffmpeg +soundfile openmp +rnnt" |
| 22 | +REQUIRED_USE="?? ( cuda rocm )" |
| 23 | +RESTRICT="!test? ( test )" |
| 24 | + |
| 25 | +DEPEND=" |
| 26 | + ffmpeg? ( media-video/ffmpeg:= ) |
| 27 | + sci-libs/caffe2[cuda?,rocm?,openmp?] |
| 28 | + sci-libs/pytorch[${PYTHON_SINGLE_USEDEP}] |
| 29 | +" |
| 30 | +RDEPEND=" |
| 31 | + ${DEPEND} |
| 32 | + $(python_gen_cond_dep ' |
| 33 | + soundfile? ( dev-python/soundfile[${PYTHON_USEDEP}] ) |
| 34 | + ') |
| 35 | +" |
| 36 | +BDEPEND=" |
| 37 | + test? ( |
| 38 | + $(python_gen_cond_dep ' |
| 39 | + dev-python/expecttest[${PYTHON_USEDEP}] |
| 40 | + dev-python/numpy[${PYTHON_USEDEP}] |
| 41 | + dev-python/typing-extensions[${PYTHON_USEDEP}] |
| 42 | + dev-python/parameterized[${PYTHON_USEDEP}] |
| 43 | + dev-python/scipy[${PYTHON_USEDEP}] |
| 44 | + dev-python/scikit-learn[${PYTHON_USEDEP}] |
| 45 | + ') |
| 46 | + ) |
| 47 | +" |
| 48 | + |
| 49 | +distutils_enable_tests pytest |
| 50 | + |
| 51 | +src_compile() { |
| 52 | + export MAX_JOBS="$(makeopts_jobs)" # Let ninja respect MAKEOPTS |
| 53 | + |
| 54 | + export USE_CUDA=$(usex cuda 1 0) |
| 55 | + export USE_ROCM=$(usex rocm 1 0) |
| 56 | + use rocm && addpredict /dev/kfd |
| 57 | + export USE_OPENMP=$(usex openmp 1 0) |
| 58 | + export USE_FFMPEG=$(usex ffmpeg 1 0) |
| 59 | + export BUILD_SOX=0 |
| 60 | + export BUILD_RNNT=$(usex rnnt 1 0) |
| 61 | + use ffmpeg && export FFMPEG_ROOT=${EPREFIX}/usr |
| 62 | + |
| 63 | + distutils-r1_src_compile |
| 64 | +} |
| 65 | + |
| 66 | +python_test() { |
| 67 | + use rocm && check_amdgpu |
| 68 | + |
| 69 | + epytest -p expecttest |
| 70 | +} |
0 commit comments