[packages/onnxruntime] Initial

arekm arekm at pld-linux.org
Sun Sep 20 21:22:49 CEST 2026


commit 886a8bc9a361a0e702979f642e7a52011f0fcb1b
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sun Sep 20 21:21:18 2026 +0200

    Initial

 onnxruntime-system-libs.patch |  93 +++++++++++++++++++++++++
 onnxruntime.spec              | 156 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 249 insertions(+)
---
diff --git a/onnxruntime.spec b/onnxruntime.spec
new file mode 100644
index 0000000..a2ecb85
--- /dev/null
+++ b/onnxruntime.spec
@@ -0,0 +1,156 @@
+# TODO:
+# - XNNPACK execution provider (needs XNNPACK + pthreadpool packages)
+#
+# Conditional build:
+%bcond_without	python3	# Python 3 bindings
+
+Summary:	ONNX Runtime - cross-platform inference engine for ONNX models
+Summary(pl.UTF-8):	ONNX Runtime - wieloplatformowy silnik wnioskowania dla modeli ONNX
+Name:		onnxruntime
+Version:	1.30.0
+Release:	1
+License:	MIT
+Group:		Libraries
+#Source0Download: https://github.com/microsoft/onnxruntime/releases
+Source0:	https://github.com/microsoft/onnxruntime/archive/v%{version}/%{name}-%{version}.tar.gz
+# Source0-md5:	da5e77a062530cad6cddae6655861967
+Patch0:		%{name}-system-libs.patch
+URL:		https://onnxruntime.ai/
+BuildRequires:	abseil-cpp-devel >= 20250814
+BuildRequires:	boost-devel >= 1.66
+BuildRequires:	cmake >= 3.28
+BuildRequires:	date-devel >= 3
+BuildRequires:	dlpack-devel
+BuildRequires:	eigen3 >= 3.4
+BuildRequires:	flatbuffers >= 23.5.9
+BuildRequires:	flatbuffers-devel >= 23.5.9
+BuildRequires:	libcpuinfo-devel
+BuildRequires:	libstdc++-devel >= 6:11
+BuildRequires:	microsoft-gsl-devel >= 4.0
+BuildRequires:	ninja
+BuildRequires:	nlohmann-json-devel >= 3.10
+BuildRequires:	onnx-devel
+BuildRequires:	protobuf-devel
+BuildRequires:	python3 >= 1:3.10
+%if %{with python3}
+BuildRequires:	python3-devel >= 1:3.10
+BuildRequires:	python3-numpy-devel
+BuildRequires:	python3-packaging
+BuildRequires:	python3-pybind11 >= 3.0
+BuildRequires:	python3-setuptools
+BuildRequires:	rpm-pythonprov
+%endif
+BuildRequires:	re2-devel
+BuildRequires:	rpmbuild(macros) >= 1.605
+BuildRequires:	safeint-devel
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+ONNX Runtime is a cross-platform inference and training accelerator
+for machine learning models in the ONNX format. This package contains
+the shared library with the CPU execution provider and the C/C++ API.
+
+%description -l pl.UTF-8
+ONNX Runtime to wieloplatformowy akcelerator wnioskowania i uczenia
+dla modeli uczenia maszynowego w formacie ONNX. Ten pakiet zawiera
+bibliotekę współdzieloną z dostawcą wykonania na CPU oraz API C/C++.
+
+%package devel
+Summary:	Header files for ONNX Runtime library
+Summary(pl.UTF-8):	Pliki nagłówkowe biblioteki ONNX Runtime
+Group:		Development/Libraries
+Requires:	%{name} = %{version}-%{release}
+
+%description devel
+Header files for ONNX Runtime library.
+
+%description devel -l pl.UTF-8
+Pliki nagłówkowe biblioteki ONNX Runtime.
+
+%package -n python3-onnxruntime
+Summary:	Python 3 bindings for ONNX Runtime
+Summary(pl.UTF-8):	Wiązania Pythona 3 do ONNX Runtime
+Group:		Libraries/Python
+Requires:	%{name} = %{version}-%{release}
+Requires:	python3-flatbuffers
+Requires:	python3-numpy >= 1.21.6
+Requires:	python3-packaging
+Requires:	python3-protobuf >= 4.25.8
+
+%description -n python3-onnxruntime
+Python 3 bindings for ONNX Runtime.
+
+%description -n python3-onnxruntime -l pl.UTF-8
+Wiązania Pythona 3 do ONNX Runtime.
+
+%prep
+%setup -q
+%patch -P0 -p1
+
+# generated headers hardcode the flatc version they came from; regenerate with the system flatc
+%{__python3} onnxruntime/core/flatbuffers/schema/compile_schema.py -f %{_bindir}/flatc -l cpp
+%{__python3} onnxruntime/lora/adapter_format/compile_schema.py -f %{_bindir}/flatc
+
+%build
+# unit tests need the ONNX model zoo test data, not shipped in the tarball
+%cmake -B build -S cmake -G Ninja \
+	-DFETCHCONTENT_FULLY_DISCONNECTED=ON \
+	-Donnxruntime_BUILD_BENCHMARKS=OFF \
+	-Donnxruntime_BUILD_SHARED_LIB=ON \
+	-Donnxruntime_BUILD_UNIT_TESTS=OFF \
+	-Donnxruntime_ENABLE_CPUINFO=ON \
+	-Donnxruntime_ENABLE_DLPACK=ON \
+	-Donnxruntime_ENABLE_PYTHON=%{__ON_OFF python3} \
+%if %{with python3}
+	-DPython_EXECUTABLE=%{__python3} \
+%endif
+	-Donnxruntime_USE_FULL_PROTOBUF=ON \
+	-Donnxruntime_USE_XNNPACK=OFF \
+	-Dsafeint_SOURCE_DIR=%{_includedir}/SafeInt
+
+%ninja_build -C build
+
+%if %{with python3}
+# cmake assembles the python package (sources + setup.py) in the build dir
+cd build
+%py3_build
+cd ..
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+%ninja_install -C build
+
+%if %{with python3}
+cd build
+%py3_install
+cd ..
+%endif
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post	-p /sbin/ldconfig
+%postun	-p /sbin/ldconfig
+
+%files
+%defattr(644,root,root,755)
+%doc LICENSE README.md ThirdPartyNotices.txt
+%{_libdir}/libonnxruntime.so.*.*.*
+%ghost %{_libdir}/libonnxruntime.so.1
+%{_libdir}/libonnxruntime_providers_shared.so
+
+%files devel
+%defattr(644,root,root,755)
+%{_libdir}/libonnxruntime.so
+%{_includedir}/onnxruntime
+%{_libdir}/cmake/onnxruntime
+%{_pkgconfigdir}/libonnxruntime.pc
+
+%if %{with python3}
+%files -n python3-onnxruntime
+%defattr(644,root,root,755)
+%{py3_sitedir}/onnxruntime
+%{py3_sitedir}/onnxruntime-%{version}-py*.egg-info
+%endif
diff --git a/onnxruntime-system-libs.patch b/onnxruntime-system-libs.patch
new file mode 100644
index 0000000..7c0a517
--- /dev/null
+++ b/onnxruntime-system-libs.patch
@@ -0,0 +1,93 @@
+Build against system Eigen, Boost.MP11 and cpuinfo instead of fetching them:
+these three are declared without FIND_PACKAGE_ARGS (or via FetchContent_Populate),
+so find_package() is never tried and the build tries to download at configure time.
+
+--- onnxruntime-1.30.0/cmake/external/onnxruntime_external_deps.cmake	2026-09-10 08:09:41.000000000 +0200
++++ onnxruntime-1.30.0/cmake/external/onnxruntime_external_deps.cmake	2026-09-20 20:12:50.908169462 +0200
+@@ -288,17 +288,8 @@
+      message(STATUS "Aliasing Boost::headers to Boost::mp11")
+      add_library(Boost::mp11 ALIAS Boost::headers)
+   else()
+-    onnxruntime_fetchcontent_declare(
+-     mp11
+-     URL ${DEP_URL_mp11}
+-     EXCLUDE_FROM_ALL
+-     FIND_PACKAGE_ARGS NAMES Boost
+-    )
+-    FetchContent_Populate(mp11)
+-    if(NOT TARGET Boost::mp11)
+-      add_library(Boost::mp11 IMPORTED INTERFACE)
+-      target_include_directories(Boost::mp11 INTERFACE $<BUILD_INTERFACE:${mp11_SOURCE_DIR}/include>)
+-    endif()
++    find_package(Boost REQUIRED)
++    add_library(Boost::mp11 ALIAS Boost::headers)
+   endif()
+ endif()
+ 
+@@ -363,52 +354,7 @@
+   set(CPUINFO_BUILD_UNIT_TESTS OFF CACHE INTERNAL "")
+   set(CPUINFO_BUILD_MOCK_TESTS OFF CACHE INTERNAL "")
+   set(CPUINFO_BUILD_BENCHMARKS OFF CACHE INTERNAL "")
+-  if(onnxruntime_USE_VCPKG AND NOT APPLE)
+-    find_package(cpuinfo CONFIG REQUIRED)
+-  else()
+-    if (onnxruntime_target_platform STREQUAL "ARM64EC" OR onnxruntime_target_platform STREQUAL "ARM64")
+-      message(STATUS "Applying patches for Windows ARM64/ARM64EC in cpuinfo")
+-      onnxruntime_fetchcontent_declare(
+-        pytorch_cpuinfo
+-        URL ${DEP_URL_pytorch_cpuinfo}
+-        URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
+-        EXCLUDE_FROM_ALL
+-        PATCH_COMMAND
+-          ${Patch_EXECUTABLE} -p1 < ${PROJECT_SOURCE_DIR}/patches/cpuinfo/patch_cpuinfo_h_for_arm64ec.patch &&
+-          # https://github.com/pytorch/cpuinfo/pull/324
+-          ${Patch_EXECUTABLE} -p1 < ${PROJECT_SOURCE_DIR}/patches/cpuinfo/patch_vcpkg_arm64ec_support.patch &&
+-          # https://github.com/pytorch/cpuinfo/pull/400
+-          ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 <
+-          ${PROJECT_SOURCE_DIR}/patches/cpuinfo/enable_deinit_refcounting.patch
+-      )
+-    elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+-      message(STATUS "Applying sysfs fallback patch for cpuinfo on Linux")
+-      onnxruntime_fetchcontent_declare(
+-        pytorch_cpuinfo
+-        URL ${DEP_URL_pytorch_cpuinfo}
+-        URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
+-        EXCLUDE_FROM_ALL
+-        PATCH_COMMAND
+-          # https://github.com/microsoft/onnxruntime/issues/10038
+-          ${Patch_EXECUTABLE} -p1 < ${PROJECT_SOURCE_DIR}/patches/cpuinfo/fix_missing_sysfs_fallback.patch &&
+-          # https://github.com/pytorch/cpuinfo/pull/400
+-          ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 <
+-          ${PROJECT_SOURCE_DIR}/patches/cpuinfo/enable_deinit_refcounting.patch
+-      )
+-    else()
+-      onnxruntime_fetchcontent_declare(
+-        pytorch_cpuinfo
+-        URL ${DEP_URL_pytorch_cpuinfo}
+-        URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
+-        EXCLUDE_FROM_ALL
+-        PATCH_COMMAND
+-          # https://github.com/pytorch/cpuinfo/pull/400
+-          ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 <
+-          ${PROJECT_SOURCE_DIR}/patches/cpuinfo/enable_deinit_refcounting.patch
+-      )
+-    endif()
+-    onnxruntime_fetchcontent_makeavailable(pytorch_cpuinfo)
+-  endif()
++  find_package(cpuinfo CONFIG REQUIRED)
+   if(TARGET cpuinfo::cpuinfo AND NOT TARGET cpuinfo)
+     message(STATUS "Aliasing cpuinfo::cpuinfo to cpuinfo")
+     add_library(cpuinfo ALIAS cpuinfo::cpuinfo)
+@@ -556,11 +502,7 @@
+   message(STATUS "Aliasing ONNX::onnx_proto to onnx_proto")
+   add_library(onnx_proto ALIAS ONNX::onnx_proto)
+ endif()
+-if(onnxruntime_USE_VCPKG)
+-  find_package(Eigen3 CONFIG REQUIRED)
+-else()
+-  include(external/eigen.cmake)
+-endif()
++find_package(Eigen3 CONFIG REQUIRED)
+ 
+ if(WIN32)
+   if(onnxruntime_USE_VCPKG)
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/onnxruntime.git/commitdiff/886a8bc9a361a0e702979f642e7a52011f0fcb1b



More information about the pld-cvs-commit mailing list