%global pkgvers 0 %global scdate0 20230509 %global schash0 a02166572855083b3b6f5a329ba438f8cd8635f9 %global branch0 main %global source0 https://github.com/onnx/onnx.git %global sshort0 %{expand:%%{lua:print(('%{schash0}'):sub(1,8))}} Name: onnx Version: %(curl -s https://raw.githubusercontent.com/onnx/onnx/main/VERSION_NUMBER | sed 's|[^[:digit:].]||g') Release: %{scdate0}.%{pkgvers}.git%{sshort0}%{?dist} Summary: Open Neural Network Exchange License: Apache URL: https://onnx.ai BuildRequires: doxygen cmake gcc-c++ git BuildRequires: python3-devel python3-setuptools protobuf-devel BuildRequires: pybind11-devel python3-pytest-runner python3-protobuf Requires: wget Requires: %{name}-python3 = %{version}-%{release} %description Open Neural Network Exchange %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} Requires: python3-protobuf python3-numpy python3-typing-extensions %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 log --format=fuller %build # external libraries rm -rf third_party/benchmark rm -rf third_party/pybind11 # python3 for f in `find . -name '*.py'`; do sed -i -e 's|#!/usr/bin/env python|#!/usr/bin/python3|' $f done # requirements sed -i '/wget/d' requirements.txt # libonnx_proto sed -i '/VISIBILITY_/d' CMakeLists.txt # fix protobuf > 3.11 sed -i 's|dllexport_decl=ONNX_API:||g' CMakeLists.txt sed -i '/gen_proto,/d' onnx/__init__.py # python36 sed -i 's|setuptools.find_namespace_packages|setuptools.find_packages|' setup.py # flags export ONNX_ML=0 export CMAKE_ARGS="-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_SKIP_RPATH=ON -DCMAKE_VERBOSE_MAKEFILE=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DONNX_USE_PROTOBUF_SHARED_LIBS=ON" # build %{__python3} setup.py build %{?_smp_mflags} %install pushd .setuptools-cmake-build make install DESTDIR=%{buildroot} popd # flags export ONNX_ML=0 export CMAKE_ARGS="-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_SKIP_RPATH=ON -DCMAKE_VERBOSE_MAKEFILE=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DONNX_USE_PROTOBUF_SHARED_LIBS=ON" # install %{__python3} setup.py install --root %{buildroot} # fix binaries mkdir -p %{buildroot}/%{_bindir}/ sed -i '1 i #!/usr/bin/python3' %{buildroot}/%{python3_sitearch}/onnx/bin/checker.py mv -f %{buildroot}/%{python3_sitearch}/onnx/bin/checker.py %{buildroot}/%{_bindir}/ sed -i '1 i #!/usr/bin/python3' %{buildroot}/%{python3_sitearch}/onnx/tools/net_drawer.py mv -f %{buildroot}/%{python3_sitearch}/onnx/tools/net_drawer.py %{buildroot}/%{_bindir}/ rm -rf %{buildroot}/%{python3_sitearch}/onnx/bin %{buildroot}/%{python3_sitearch}/onnx/tools chmod +x %{buildroot}/%{_bindir}/* # remove bogus rm -rf %{buildroot}/%{python3_sitearch}/onnx/backend/test rm -rf %{buildroot}/%{python3_sitearch}/onnx/gen_proto.py rm -rf %{buildroot}/%{python3_sitearch}/onnx/__pycache__/gen_proto*.pyc rm -rf %{buildroot}/%{python3_sitearch}/onnx/defs/gen_doc.py rm -rf %{buildroot}/%{python3_sitearch}/onnx/defs/__pycache__/gen_doc*.pyc sed -i 's|[<=>].*||g' %{buildroot}/%{python3_sitearch}/*egg-info/requires.txt # remove C & headers from python find %{buildroot}/%{python3_sitearch} -type f -regex '.*\.\(h\|c\|cc\)' -exec rm -rf {} \; for d in `find %{buildroot}/%{python3_sitearch} -type d -empty` do rm -rf $d | true done # fix cmake path sed -i -e 's|/lib/|/%{_lib}/|g' %{buildroot}/%{_libdir}/cmake/ONNX/ONNXTargets-*.cmake %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