%global pkgvers 0 %global scdate0 20250802 %global schash0 5094dcfaa55e8aa5fba309731a0e40a52050679b %global branch0 main %global source0 https://github.com/onnx/optimizer.git %global sshort0 %{expand:%%{lua:print(('%{schash0}'):sub(1,8))}} Name: onnx-optimizer Version: %(curl -s https://raw.githubusercontent.com/onnx/optimizer/%{schash0}/VERSION_NUMBER | sed 's|[^[:digit:].]||g') Release: %{scdate0}.%{pkgvers}.git%{sshort0}%{?dist} Summary: Open Neural Network Exchange Optimizer License: Apache URL: https://github.com/onnx/optimizer BuildRequires: doxygen cmake gcc-c++ git BuildRequires: python3-devel python3-setuptools python3-pip python3-wheel BuildRequires: pybind11-devel python3-pytest-runner onnx-devel BuildRequires: protobuf-compat-devel >= 3.21 %if 0%{?rhel} == 10 BuildRequires: pyproject-rpm-macros %endif %description Open Neural Network Exchange Optimizer %package devel Summary: Development files for onnx Requires: %{name} = %{version}-%{release} %description devel This package contains development files for onnx. %package python3 Summary: Python files for onnx Requires: %{name} = %{version}-%{release} %description python3 This package contains python files for onnx. %prep %setup -T -c -n %{name} git clone --depth 1 -n -b %{branch0} %{source0} . git fetch --depth 1 origin %{schash0} git reset --hard %{schash0} git --no-pager log --format=fuller # cmake version sed -i 's|VERSION 3.22|VERSION 3.20|g' CMakeLists.txt # external libs rm -rf third_party/onnx rm -rf third_party/protobuf sed -i '/third_party\/protobuf/d' CMakeLists.txt sed -i '/add_subdirectory.*(${ONNX_ROOT}/d' CMakeLists.txt sed -i '/Utils.cmake/d' cmake/utils.cmake sed -i 's|onnx_optimizer PUBLIC ${ONNX_TARGET_NAME}|onnx_optimizer PUBLIC ${ONNX_TARGET_NAME} protobuf onnx_proto|g' CMakeLists.txt %generate_buildrequires %pyproject_buildrequires %build %global cmake_config \\\ -DCMAKE_INSTALL_PREFIX=%{_prefix} \\\ -DBUILD_SHARED_LIBS=ON \\\ -DCMAKE_SKIP_RPATH=ON \\\ -DCMAKE_VERBOSE_MAKEFILE=OFF \\\ -DCMAKE_BUILD_TYPE=RelWithDebInfo export ONNX_ML=1 export ONNX_NAMESPACE=onnx export CXXFLAGS="%{optflags} -DONNX_NAMESPACE=onnx -DONNX_ML=1" %cmake %cmake_config %cmake_build export CMAKE_ARGS="%cmake_config" %pyproject_wheel %install export ONNX_ML=1 export ONNX_NAMESPACE=onnx export CXXFLAGS="%{optflags} -DONNX_NAMESPACE=onnx -DONNX_ML=1" %cmake_install export CMAKE_ARGS="%cmake_config" %pyproject_install mkdir -p %{buildroot}/%{_bindir} mkdir -p %{buildroot}/%{_includedir}/onnx ln -sf %{_includedir}/onnxoptimizer %{buildroot}/%{_includedir}/onnx/optimizer install -pm 0755 .setuptools-cmake-build%{python3_version}/onnx_optimizer_exec %{buildroot}/%{_bindir}/ # fix requirements sed -i '/mypy/d' %{buildroot}%{python3_sitearch}/*.dist-info/METADATA %files %doc README.md %license LICENSE %{_bindir}/* %{_libdir}/lib*.so* %files devel %{_includedir}/* %{_libdir}/cmake/* %files python3 %{python3_sitearch}/* %changelog * Tue Mar 26 2019 Balint Cristian - github update releases