blob: ef2816aa01f872979fc3f351e670b5329ae25a1c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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
|