diff options
Diffstat (limited to 'onnx.spec')
-rw-r--r-- | onnx.spec | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/onnx.spec b/onnx.spec new file mode 100644 index 0000000..ef2816a --- /dev/null +++ b/onnx.spec @@ -0,0 +1,130 @@ +Name: onnx +Version: 1.18.0 +Release: 1%{?dist} +Summary: Open standard for machine learning interoperability +License: Apache-2.0 + +URL: https://github.com/onnx/onnx +Source0: https://github.com/onnx/onnx/archive/v%{version}/%{name}-%{version}.tar.gz + +# Build shared libraries and fix install location +Patch0: 0000-Build-shared-libraries-and-fix-install-location.patch +# Let pyproject_build use binaries from cmake_build +Patch1: 0001-Let-pyproject_build-use-binaries-from-cmake_build.patch +# Add fixes for use with onnxruntime +Patch2: 0002-Add-fixes-for-use-with-onnxruntime.patch + +BuildRequires: cmake >= 3.24 +BuildRequires: make +BuildRequires: findutils +BuildRequires: gcc +BuildRequires: gcc-c++ +BuildRequires: zlib-devel +BuildRequires: python3-devel +BuildRequires: python3-pip +BuildRequires: python3-wheel +BuildRequires: python3-pybind11 >= 2.12.0 +BuildRequires: protobuf-devel >= 25.1 +BuildRequires: protobuf-compiler >= 25.1 +BuildRequires: python3-build +BuildRequires: python3-parameterized +BuildRequires: pytest +BuildRequires: python3-pytest-cov +BuildRequires: python3-pytest-xdist +BuildRequires: python3-setuptools +BuildRequires: python3-pillow +BuildRequires: python3-numpy +BuildRequires: python3-protobuf + +%global _description %{expand: +%{name} provides an open source format for AI models, both deep learning and +traditional ML. It defines an extensible computation graph model, as well as +definitions of built-in operators and standard data types.} + +%description %_description + +%package libs +Summary: Libraries for %{name} + +%description libs %_description + +%package devel +Summary: Development files for %{name} +Requires: %{name}-libs = %{version}-%{release} + +%description devel %_description + +%package -n python3-onnx +Summary: %{summary} +Requires: %{name}-libs = %{version}-%{release} + +%description -n python3-onnx %_description + +%prep +%autosetup -p1 -n %{name}-%{version} + +# Drop nbval options from pytest. Plugin is not available in openEuler. +sed -r \ + -e 's/--nbval //' \ + -e 's/--nbval-current-env //' \ + -i pyproject.toml + +%build +%cmake \ + -DONNX_USE_LITE_PROTO=OFF \ + -DONNX_USE_PROTOBUF_SHARED_LIBS=ON \ + -DONNX_BUILD_PYTHON=ON \ + -DONNX_ML=1 \ + -DPython3_EXECUTABLE=%{__python3} \ + -DPY_SITEARCH=%{python3_sitearch} \ + -DCMAKE_SKIP_RPATH:BOOL=ON + + + +# Generate protobuf header and source files +%cmake_build -- gen_onnx_proto +# Build +%cmake_build +# Build python libs +%pyproject_build + +%install +%cmake_install +# Need to remove empty directories +# find "%{buildroot}%{_includedir}" -type d -empty -delete +# find "%{buildroot}%{python3_sitearch}" -type d -empty -delete +# Install *.proto files +install -p "./onnx/"*.proto -t "%{buildroot}/%{_includedir}/onnx/" + +%pyproject_install + +%check +export LD_LIBRARY_PATH=%{buildroot}%{_libdir} +export PYTHONPATH=%{buildroot}%{python3_sitearch} +%pytest \ + --ignore=onnx/test/helper_test.py \ + --ignore=onnx/test/numpy_helper_test.py \ + --ignore=onnx/test/test_backend_reference.py \ + --ignore=onnx/test/reference_evaluator_test.py + +%files libs +%license LICENSE +%doc README.md +%{_libdir}/libonnx.so.%{version} +%{_libdir}/libonnx_proto.so.%{version} + +%files devel +%{_libdir}/libonnx.so +%{_libdir}/libonnx_proto.so +%{_libdir}/cmake/ONNX +%{_includedir}/%{name}/ + +%files -n python3-onnx +%{python3_sitearch}/onnx* +%{_bindir}/backend-test-tools +%{_bindir}/check-model +%{_bindir}/check-node + +%changelog +* Fri Jul 4 2025 zhihang <zhihang161013@outlook.com> - 1.18.0-1 +- Init package |