%define pypi_name torchcodec # Broken %define with_tests 0 Name: python-%{pypi_name} Version: 0.16.0 Release: 2%{?dist} Summary: A library for audio and signal processing with PyTorch License: BSD-3-Clause URL: https://github.com/meta-pytorch/torchcodec Source0: %{url}/archive/%{version}.tar.gz#/%{pypi_name}-%{version}.tar.gz # These might take a little to upstream # Fix for building with ROCm Source100: torchcodec-rocm-prelude.cmake # Use System libavif Patch1: torchcodec-use-system-avif.patch # Fix giflib linking Patch2: torchcodec-gif-lto-uninit-fix.patch # Use system giflib Patch3: torchcodec-use-system-giflib.patch Patch4: torchcodec-decodegif-include.patch ExclusiveArch: aarch64 x86_64 BuildRequires: gcc gcc-c++ BuildRequires: fmt-devel BuildRequires: giflib-devel BuildRequires: libavcodec-free-devel BuildRequires: libavdevice-free-devel BuildRequires: libavfilter-free-devel BuildRequires: libavformat-free-devel BuildRequires: libavif-devel BuildRequires: libheif-devel BuildRequires: libjpeg-turbo-devel BuildRequires: libpng-devel BuildRequires: libswscale-free-devel BuildRequires: libwebp-devel BuildRequires: protobuf-devel BuildRequires: pybind11-devel BuildRequires: python3-cmake BuildRequires: python3-numpy BuildRequires: python3-pillow BuildRequires: python3-pytest BuildRequires: python3-setuptools BuildRequires: python3-torch BuildRequires: zlib-devel # ROCm doesn't appear to be used but is needed as torch is built with it %ifarch x86_64 BuildRequires: rocm-rpm-macros BuildRequires: rocm-compilersupport-macros BuildRequires: hipblas-devel BuildRequires: hipfft-devel BuildRequires: hiprand-devel BuildRequires: rocblas-devel BuildRequires: rocm-hip-devel BuildRequires: rocm-smi-devel BuildRequires: miopen-devel BuildRequires: hipsparse-devel BuildRequires: rocprim-devel BuildRequires: hipcub-devel BuildRequires: rocthrust-devel BuildRequires: hipsolver-devel BuildRequires: rocsolver-devel BuildRequires: hipblaslt-devel BuildRequires: hipsparselt-devel BuildRequires: rocm-runtime-devel BuildRequires: rocm-comgr-devel BuildRequires: rocrand-devel %endif # For check %if 0%{?with_tests} BuildRequires: python3-pytest %endif %global _description %{expand: TorchCodec is a Python library for decoding video and audio data into PyTorch tensors, on CPU and CUDA GPU. It also supports video and audio encoding on CPU! It aims to be fast, easy to use, and well integrated into the PyTorch ecosystem. If you want to use PyTorch to train ML models on videos and audio, TorchCodec is how you turn these into data. We achieve these capabilities through: * Pythonic APIs that mirror Python and PyTorch conventions. * Relying on FFmpeg to do the decoding and encoding. TorchCodec uses the version of FFmpeg you already have installed. FFmpeg is a mature library with broad coverage available on most systems. It is, however, not easy to use. TorchCodec abstracts FFmpeg's complexity to ensure it is used correctly and efficiently. * Returning data as PyTorch tensors, ready to be fed into PyTorch transforms or used directly to train models. } %description %_description %package -n python3-%{pypi_name} Summary: %{summary} %description -n python3-%{pypi_name} %_description %prep %autosetup -p1 -n %{pypi_name}-%{version} %generate_buildrequires %if 0%{?with_tests} %pyproject_buildrequires -r %else %pyproject_buildrequires %endif %build export I_CONFIRM_THIS_IS_NOT_A_LICENSE_VIOLATION=1 %ifarch x86_64 install -D -m 644 %{SOURCE100} %{_builddir}/rocm-prelude.cmake export HIP_CLANG_PATH=%{rocmllvm_bindir} export PYTORCH_ROCM_ARCH=%{rocm_gpu_list_default} export CMAKE_ARGS="-DTORCHCODEC_USE_SYSTEM_AVIF=ON -DTORCHCODEC_USE_SYSTEM_GIFLIB=ON -DCMAKE_PROJECT_INCLUDE=%{_builddir}/rocm-prelude.cmake" %else export CMAKE_ARGS="-DTORCHCODEC_USE_SYSTEM_AVIF=ON -DTORCHCODEC_USE_SYSTEM_GIFLIB=ON" %endif %pyproject_wheel %install export I_CONFIRM_THIS_IS_NOT_A_LICENSE_VIOLATION=1 %pyproject_install %pyproject_save_files -l %{pypi_name} %if 0%{?with_tests} %check %pyproject_check_import %endif %files -n python3-%{pypi_name} -f %{pyproject_files} %doc README.md %changelog * Thu Oct 29 2026 Peter Robinson - 0.16.0-2 - Fixes for ROCm builds * Tue Sep 22 2026 Peter Robinson - 0.16.0-1 - Initial version