summaryrefslogtreecommitdiff
path: root/onnxruntime.spec
diff options
context:
space:
mode:
Diffstat (limited to 'onnxruntime.spec')
-rw-r--r--onnxruntime.spec162
1 files changed, 162 insertions, 0 deletions
diff --git a/onnxruntime.spec b/onnxruntime.spec
new file mode 100644
index 0000000..f21b9d9
--- /dev/null
+++ b/onnxruntime.spec
@@ -0,0 +1,162 @@
+%global _empty_manifest_terminate_build 0
+%global __brp_check_rpaths %{nil}
+%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: 0002-remove-nsync.patch
+Patch7: 0001-fix-forward-decl-flatbuffers.patch
+Patch8: 0001-add-onnxruntime_INSTALL_UNIT_TESTS-option.patch
+Patch9: 0001-gcc-false-positive.patch
+Patch10: 0001-versioned-onnxruntime_providers_shared.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
+%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 \
+ -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}" -j8 --verbose
+
+# Build python libs
+mv ./onnxruntime ./onnxruntime.src
+cp -R %{__cmake_build_dir}/onnxruntime ./onnxruntime
+cp %{__cmake_build_dir}/requirements.txt ./requirements.txt
+
+#mkdir -p %{buildroot}/.python_wheel
+#CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" TMPDIR="%{buildroot}/.pyproject-builddir" \
+# %{__python3} -m pip wheel --no-deps --use-pep517 --no-build-isolation --disable-pip-version-check \
+# --no-clean --progress-bar off --verbose \
+# --wheel-dir "%{buildroot}/pyproject-wheeldir"
+%pyproject_build
+
+%install
+DESTDIR="%{buildroot}" %{__cmake} --install "%{__cmake_build_dir}"
+mkdir -p "%{buildroot}/%{_docdir}/"
+cp --preserve=timestamps -r "./docs/" "%{buildroot}/%{_docdir}/%{name}"
+# /usr/bin/python3 -m pip install --root /builddir/build/BUILDROOT/onnxruntime-1.16.3-1.x86_64 \
+# --prefix /usr --no-deps --disable-pip-version-check --progress-bar off --verbose \
+# --ignore-installed --no-warn-script-location --no-index --no-cache-dir \
+# --find-links /builddir/build/BUILD/%{name}-%{version}/build \
+# %{name}==%{version}
+%pyproject_install
+# %pyproject_save_files onnxruntime
+
+%check
+export GTEST_FILTER=-CApiTensorTest.load_huge_tensor_with_external_data
+export LT_SYS_LIBRARY_PATH=/usr/lib64
+/usr/bin/ctest --test-dir "%{__cmake_build_dir}" --output-on-failure --force-new-ctest-process %{?_smp_mflags}
+# %ctest
+
+%files
+%license LICENSE
+%doc ThirdPartyNotices.txt
+%{_libdir}/libonnxruntime.so.%{version}
+%{_libdir}/libonnxruntime_providers_shared.so.%{version}
+
+%files devel
+%dir %{_includedir}/onnxruntime/
+%{_includedir}/onnxruntime/*
+%{_libdir}/libonnxruntime.so
+%{_libdir}/libonnxruntime_providers_shared.so
+%{_libdir}/pkgconfig/libonnxruntime.pc
+
+%files -n python3-onnxruntime -f %{pyproject_files}
+%{_bindir}/onnxruntime_test
+
+%files doc
+%{_docdir}/%{name}
+
+%changelog
+* Sun Jan 28 2024 Binshuo Zu <274620705z@gmail.com> - 1.16.3-1
+- Package init