%global pypi_name executorch Name: python-%{pypi_name} Version: 1.3.1 Release: 0%{?dist} Summary: On-device AI across mobile, embedded and edge for PyTorch License: BSD-3-Clause URL: https://pytorch.org/executorch/ Source0: https://github.com/pytorch/executorch/archive/%{version}.tar.gz#/%{pypi_name}-%{version}.tar.gz Source1: torchcodec-rocm-prelude.cmake # Patches to use various systems libraries, the intention # is to work to get these upstream (if possible) Patch1: executorch-toplevel-system-libs.patch Patch2: executorch-use-system-libs.patch Patch3: executorch-xnnpack-dependencies.patch Patch4: executorch-xnnpack-cmakelists.patch Patch5: executorch-toplevel-tokenizers.patch Patch6: executorch-toplevel-system-pybind11.patch Patch7: executorch-use-system-flatcc.patch Patch8: executorch-eigenblas-system.patch Patch9: executorch-system-flatc-wheel.patch # Upstream backport Patch10: executorch-All-lib-installs-target-CMake-install-libdir-20879.patch ExclusiveArch: x86_64 aarch64 BuildRequires: chrpath BuildRequires: git-core BuildRequires: gcc gcc-c++ BuildRequires: cpuinfo-devel BuildRequires: flatbuffers-devel BuildRequires: flatbuffers-compiler BuildRequires: flatcc-devel BuildRequires: flexiblas-devel BuildRequires: fxdiv-devel BuildRequires: gflags-devel BuildRequires: json-devel BuildRequires: pthreadpool-devel BuildRequires: pocketfft-devel BuildRequires: pybind11-devel BuildRequires: python3-cmake BuildRequires: python3-devel BuildRequires: python3-pip BuildRequires: python3-setuptools BuildRequires: python3-torch BuildRequires: python3-pytorch-tokenizers-devel BuildRequires: xnnpack-devel # ROCm doesn't appear to be used but is needed as torch is built with it %ifarch x86_64 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 %global _description %{expand: ExecuTorch is PyTorch's unified solution for deploying AI models on-device—from smartphones to microcontrollers—built for privacy, performance, and portability. It powers Meta's on-device AI across Instagram, WhatsApp, Quest 3, Ray-Ban Meta Smart Glasses, and more. Deploy LLMs, vision, speech, and multimodal models with the same PyTorch APIs you already know—accelerating research to production with seamless model export, optimization, and deployment. No manual C++ rewrites. No format conversions. No vendor lock-in. } %description %_description %package -n python3-%{pypi_name} Summary: %{summary} Requires: flatbuffers-compiler %description -n python3-%{pypi_name} %_description %package -n lib%{pypi_name} Summary: Core library for %{pypi_name} %description -n lib%{pypi_name} Core library for %{pypi_name} %package -n lib%{pypi_name}-devel Summary: Development headers for %{pypi_name} Requires: lib%{pypi_name} = %{version} %description -n lib%{pypi_name}-devel Development headers for %{pypi_name} %prep %autosetup -p1 -n %{pypi_name}-%{version} # build expects a directory of executorch ln -s %{pypi_name}-%{version} ../%{pypi_name} # Allow for versioned executorch directories sed -i 's/STREQUAL "executorch"/MATCHES "^executorch(-.*)?$"/' CMakeLists.txt # Adjust for Fedora python version minimums sed -i 's/>=3.10,<3.14/>=3.10/' pyproject.toml # Adjust for Fedora cmake versions sed -i 's/,<4.0.0//g' pyproject.toml sed -i 's/, <4.0.0//g' requirements-dev.txt # Fedora has 1.4.x sed -i 's/mpmath==1.3.0/mpmath>=1.3.0/' pyproject.toml # Fedora has 1.8 sed -i 's/scikit-learn==1.7.1/scikit-learn>=1.7.1/' pyproject.toml # Fedora has 9.x sed -i 's/pytest<9.0/pytest/' pyproject.toml # Fedora has 15.0 sed -i 's/pytest-rerunfailures==15.1/pytest-rerunfailures==15.0/' pyproject.toml install -D -m 644 %{SOURCE1} %{_builddir}/rocm-prelude.cmake %generate_buildrequires %pyproject_buildrequires %build %ifarch x86_64 export PYTORCH_ROCM_ARCH="gfx900;gfx906;gfx908;gfx90a;gfx942;gfx1030;gfx1100" %endif %cmake -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DEXECUTORCH_USE_SYSTEM_LIBS=ON \ -DEXECUTORCH_BUILD_SHARED=ON \ -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \ -DEXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON \ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON %cmake_build export CMAKE_ARGS="-DEXECUTORCH_USE_SYSTEM_LIBS=ON \ -DEXECUTORCH_XNNPACK_USE_SYSTEM_LIBS=ON -DEXECUTORCH_BUILD_XNNPACK=OFF \ -DEXECUTORCH_BUILD_OPENVINO=OFF -DEXECUTORCH_BUILD_DEVTOOLS=OFF \ -DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \ -DEXECUTORCH_BUILD_EXTENSION_LLM=OFF -DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=OFF \ -DEXECUTORCH_BUILD_COREML=OFF -DEXECUTORCH_BUILD_KERNELS_LLM_AOT=OFF " # Fix torchao headers: -DEXECUTORCH_BUILD_KERNELS_LLM_AOT=OFF # xnnpack needs newer rev -DEXECUTORCH_BUILD_XNNPACK=OFF # all four exist from commit 7aeb36915 (30 Oct 2024) %ifarch x86_64 export CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_PROJECT_INCLUDE=%{_builddir}/rocm-prelude.cmake" %endif %pyproject_wheel %install %cmake_install %pyproject_install %pyproject_save_files -l %{pypi_name} find %{buildroot} -name '*.a' -delete find %{buildroot}%{python3_sitearch}/executorch -name '*.so' | while read -r f; do rp=$(chrpath -l "$f" | sed -n 's/^.*: R\(UN\)\{0,1\}PATH=//p') [ -n "$rp" ] || continue chrpath -r "$(echo "$rp" | sed -E 's/:+/:/g; s/^://; s/:$//')" "$f" > /dev/null done %files -n python3-%{pypi_name} -f %{pyproject_files} %doc README.md %files -n lib%{pypi_name} %license LICENSE %{_libdir}/lib%{pypi_name}*.so.* %files -n lib%{pypi_name}-devel %{_includedir}/%{pypi_name}/ %{_libdir}/lib%{pypi_name}*.so %{_libdir}/pkgconfig/executorch.pc %{_libdir}/cmake/ExecuTorch/ %changelog * Sun Oct 19 2025 Peter Robinson - 1.0.0-1 - Initial package