%global _empty_manifest_terminate_build 0 %global __cmake_build_dir "./cmake-build" Name: onnxruntime Version: 1.16.3 Release: 1 Summary: ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator License: MIT URL: https://github.com/microsoft/onnxruntime Source0: https://github.com/microsoft/onnxruntime/archive/v%{version}/%{name}-%{version}.tar.gz Patch0: 0001-downgrade-cmake-from-3.26-to-3.24.patch Patch1: 0001-use-system-Flatbuffers.patch Patch2: 0001-use-system-cpuinfo.patch Patch3: 0001-use-system-protobuf.patch Patch4: 0001-use-system-python.patch Patch5: 0001-remove-nsync.patch Patch6: 0001-fix-forward-decl-flatbuffers.patch Patch7: 0001-add-onnxruntime_INSTALL_UNIT_TESTS-option.patch Patch8: 0001-gcc-false-positive.patch Patch9: 0001-versioned-onnxruntime-providers_shared.patch Patch10: 0001-use-system-gtest.patch BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-setuptools_scm BuildRequires: python3-pbr BuildRequires: python3-pip BuildRequires: python3-wheel BuildRequires: python3-hatchling BuildRequires: python3-numpy BuildRequires: pybind11-devel BuildRequires: abseil-cpp-devel BuildRequires: protobuf-devel BuildRequires: eigen3-devel BuildRequires: boost-devel BuildRequires: bzip2 BuildRequires: cmake BuildRequires: g++ BuildRequires: flatbuffers-compiler BuildRequires: flatbuffers-devel >= 23.5.26 BuildRequires: cpuinfo-devel BuildRequires: gtest-devel BuildRequires: gmock-devel BuildRequires: zlib-devel BuildRequires: gsl-devel %description onnxruntime is a cross-platform inferencing and training accelerator compatible with many popular ML/DNN frameworks, including PyTorch, TensorFlow/Keras, scikit-learn, and more. %package devel Summary: The development part of the %{name} package Requires: %{name} = %{version}-%{release} %description devel The development part of the %{name} package %package -n python3-onnxruntime Summary: %{summary} Requires: %{name} = %{version}-%{release} %description -n python3-onnxruntime Python bindings for the %{name} package %package doc Summary: Documentation files for the %{name} package %description doc Documentation files for the %{name} package %prep # rm -rf %{_sourcedir}/onnxruntime-1.16.3.tar.gz # cat %{_sourcedir}/onnxruntime-1.16.3.tar.gz* > %{_sourcedir}/onnxruntime-1.16.3.tar.gz %autosetup -p1 -n %{name}-%{version} %build # Broken test in aarch64 %ifarch aarch64 rm -v onnxruntime/test/optimizer/nhwc_transformer_test.cc %endif # Re-generate flatbuffer headers %{__python3} onnxruntime/core/flatbuffers/schema/compile_schema.py --flatc %{_bindir}/flatc # Overrides BUILD_SHARED_LIBS flag since onnxruntime compiles individual components as static, and links # all together into a single shared library when onnxruntime_BUILD_SHARED_LIB is ON. # The array-bounds and dangling-reference checks have false positives. %cmake \ %_cmake_skip_rpath \ -DCMAKE_INSTALL_LIBDIR=%{_lib} \ -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \ -Donnxruntime_BUILD_SHARED_LIB=ON \ -Donnxruntime_BUILD_UNIT_TESTS=ON \ -Donnxruntime_INSTALL_UNIT_TESTS=OFF \ -Donnxruntime_BUILD_BENCHMARKS=OFF \ -Donnxruntime_USE_PREINSTALLED_EIGEN=OFF \ -Donnxruntime_USE_FULL_PROTOBUF=ON \ -DPYTHON_VERSION=%{python3_version} \ -Donnxruntime_ENABLE_CPUINFO=ON \ -Donnxruntime_DISABLE_ABSEIL=ON \ -Donnxruntime_ENABLE_PYTHON=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -B "%{__cmake_build_dir}" \ -S cmake \ %{__cmake} --build "%{__cmake_build_dir}" %{?_smp_mflags} --verbose # Build python libs mv ./onnxruntime ./onnxruntime.src cp -R %{__cmake_build_dir}/onnxruntime ./onnxruntime cp %{__cmake_build_dir}/requirements.txt ./requirements.txt %pyproject_build %install DESTDIR="%{buildroot}" %{__cmake} --install "%{__cmake_build_dir}" find %{__cmake_build_dir}/ -name "*.so" -exec cp {} "%{buildroot}/%{_libdir}" \; mkdir -p "%{buildroot}/%{_docdir}/" cp --preserve=timestamps -r "./docs/" "%{buildroot}/%{_docdir}/%{name}" %pyproject_install %check export GTEST_FILTER=-CApiTensorTest.load_huge_tensor_with_external_data export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%{buildroot}/usr/lib64/ /usr/bin/ctest --test-dir "%{__cmake_build_dir}" --output-on-failure --force-new-ctest-process %{?_smp_mflags} %files %license LICENSE %doc ThirdPartyNotices.txt %{_libdir}/libonnx.so %{_libdir}/libonnx_proto.so %{_libdir}/libonnxruntime.so.%{version} %{_libdir}/libonnxruntime_providers_shared.so.%{version} %files devel %dir %{_includedir}/onnxruntime/ %{_includedir}/onnxruntime/* %{_libdir}/cmake %{_libdir}/*.so* # %{_libdir}/libgmock.so.* # %{_libdir}/libgtest.so.* # %{_libdir}/libonnx_proto.so # %{_libdir}/libonnx.so # %{_libdir}/libonnxruntime.so # %{_libdir}/libonnxruntime_providers_shared.so %{_libdir}/pkgconfig/libonnxruntime.pc %files -n python3-onnxruntime %{_libdir}/python3.11/site-packages/* %{_bindir}/onnxruntime_test %files doc %{_docdir}/%{name} %changelog * Sun Jan 28 2024 Binshuo Zu <274620705z@gmail.com> - 1.16.3-1 - Package init