2019-10-18 08:33:29 +00:00
#
# spec file for package python-onnx
#
2020-01-08 10:06:57 +00:00
# Copyright (c) 2020 SUSE LLC
2019-10-18 08:33:29 +00:00
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
2020-01-08 10:06:57 +00:00
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
2019-10-18 08:33:29 +00:00
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
2020-02-25 13:58:12 +00:00
%define skip_python2 1
2019-10-18 08:33:29 +00:00
Name : python-onnx
2020-07-07 09:38:30 +00:00
Version : 1.7.0
2019-10-18 08:33:29 +00:00
Release : 0
2020-02-25 13:58:12 +00:00
Summary : Open Neural Network eXchange
2020-01-08 10:06:57 +00:00
License : MIT
URL : https://onnx.ai/
2019-10-18 08:33:29 +00:00
Source0 : https://github.com/onnx/onnx/archive/v%{version} .tar.gz#/onnx-%{version}.tar.gz
2019-10-28 13:15:22 +00:00
Source1 : %{name} -rpmlintrc
2020-04-23 11:56:53 +00:00
Patch1 : no-python2.patch
2020-08-17 06:37:58 +00:00
Patch2 : using-onnxruntime-proto.patch
2019-10-18 08:33:29 +00:00
BuildRequires : %{python_module devel}
2020-02-25 13:58:12 +00:00
BuildRequires : %{python_module numpy}
BuildRequires : %{python_module protobuf}
2020-04-23 10:35:54 +00:00
BuildRequires : %{python_module pybind11-devel}
2020-02-24 15:44:01 +00:00
BuildRequires : %{python_module pybind11}
2020-02-25 13:58:12 +00:00
BuildRequires : %{python_module pytest-xdist}
BuildRequires : %{python_module pytest}
2020-01-08 10:06:57 +00:00
BuildRequires : %{python_module setuptools}
2020-02-25 13:58:12 +00:00
BuildRequires : %{python_module six}
2019-10-18 08:33:29 +00:00
BuildRequires : cmake
2020-01-08 10:06:57 +00:00
BuildRequires : fdupes
2019-10-18 08:33:29 +00:00
BuildRequires : gcc-c++
BuildRequires : protobuf-devel
2020-01-08 10:06:57 +00:00
BuildRequires : python-rpm-macros
2020-08-17 06:37:58 +00:00
Requires : libonnx == %version
Requires : libonnx_proto == %version
Requires : libonnxifi_dummy == %version
2019-10-18 08:33:29 +00:00
Requires : python-numpy
Requires : python-protobuf
Requires : python-six
Requires : python-typing_extensions >= 3.6.2.1
2020-05-21 08:59:21 +00:00
Requires(post) : update-alternatives
Requires(postun) : update-alternatives
2020-03-23 15:09:14 +00:00
Provides : python-onnx-devel = %{version} -%{release}
Obsoletes : python-onnx-devel < %{version} -%{release}
2019-10-18 08:33:29 +00:00
%python_subpackages
%description
2020-03-18 17:33:28 +00:00
Open format to represent deep learning models. With ONNX, AI developers can
more easily move models between state-of-the-art tools and choose the
combination that is best for them. ONNX is developed and supported by a
community of partners.
2019-10-18 08:33:29 +00:00
2020-08-17 06:37:58 +00:00
%package -n onnx-devel
Summary : Header files of onnx
Requires : libonnx == %version
Requires : libonnx_proto == %version
Requires : libonnxifi_dummy == %version
%description -n onnx-devel
Header files of ONNX.
%package -n libonnxifi_dummy
Summary : Library for ONNX Interface for Framework Integration
%description -n libonnxifi_dummy
This package exists to create libonnx_proto, so you do no want
to install this package.
%package -n libonnx
Summary : Shared library for onnx
%description -n libonnx
This package exists to create libonnx_proto, so you do no want
to install this package.
%package -n libonnx_proto
Summary : Shared library for onnx protocul bufer
%description -n libonnx_proto
Shared library for the protocol buffer library, packaged separately to be
used by external project.
%package -n onnx-backend-test
Summary : Test data
%description -n onnx-backend-test
This packages includes the data for testing the backend.
2019-10-18 08:33:29 +00:00
%prep
%setup -q -n onnx-%{version}
2020-02-24 14:53:41 +00:00
# avoid bundles
rm -rf third_party
2020-04-23 11:56:53 +00:00
%autopatch -p1
2020-02-24 14:53:41 +00:00
# say that the cmake was already built (we used our macros)
sed -i -e 's:built = False:built = True:g' setup.py
2020-02-25 13:58:12 +00:00
# do not require extra pytest modules
sed -i -e '/addopts/d' setup.cfg
# do not pull in pytest-runner as it is deprecated
sed -i -e '/pytest-runner/d' setup.py
2019-10-18 08:33:29 +00:00
%build
2020-02-24 14:53:41 +00:00
# define same folder like is used for the setup.py later
%define __builddir .setuptools-cmake-build
2020-05-21 08:59:21 +00:00
# FIXME: you should use %%cmake macros
2020-02-25 11:53:19 +00:00
# Force the cmake to build static libs as otherwise we end
# up with unresolvable package.
2020-02-24 15:44:01 +00:00
%{python_expand # we need to generate for each python
2020-02-24 14:53:41 +00:00
%cmake \
-DONNX_USE_PROTOBUF_SHARED_LIBS=ON \
-DONNX_WERROR=OFF \
-DBUILD_ONNX_PYTHON=ON \
2020-08-17 06:37:58 +00:00
-DBUILD_SHARED_LIBS=ON \
-DBUILD_STATIC_LIBS=OFF \
2020-04-23 11:56:53 +00:00
-DPYTHON_EXECUTABLE=" %{_bindir} / $ p y t h o n " \
2020-08-17 06:37:58 +00:00
-DPY_EXT_SUFFIX=" ` $ p y t h o n - c o n f i g - - e x t e n s i o n - s u f f i x ` " \
%{nil}
2020-02-24 14:53:41 +00:00
%cmake_build ; cd ..
2020-02-24 15:44:01 +00:00
}
2019-10-18 08:33:29 +00:00
%python_build
%install
%python_install
2020-08-17 06:37:58 +00:00
%cmake_install
2020-05-21 08:59:21 +00:00
%python_clone -a %{buildroot} %{_bindir} /backend-test-tools
%python_clone -a %{buildroot} %{_bindir} /check-node
%python_clone -a %{buildroot} %{_bindir} /check-model
2019-10-18 08:33:29 +00:00
%python_expand %fdupes %{buildroot} %{$python_sitearch}
2019-10-21 08:46:18 +00:00
shebang_files=" %{python_sitearch} / o n n x / b a c k e n d / t e s t / s t a t _ c o v e r a g e . p y %{python_sitearch} / o n n x / d e f s / g e n _ d o c . p y %{python_sitearch} / o n n x / g e n _ p r o t o . p y "
2019-10-18 08:33:29 +00:00
for file in $shebang_files ; do
2020-02-24 14:53:41 +00:00
sed -i 's@%{_bindir}/env python@%{_bindir}/python3@' %{buildroot} /$file
2019-10-18 08:33:29 +00:00
chmod 755 %{buildroot} /$file
done
2020-02-24 14:53:41 +00:00
%check
2020-02-25 13:58:12 +00:00
export PYTHONDONTWRITEBYTECODE=1
# copy inplace for tests
cp %{__builddir} /*cpp2py* ./onnx/
# skip online tests
%pytest_arch -n auto -k 'not (test_bvlc_alexnet_cpu or test_shufflenet_cpu or test_densenet121_cpu or test_squeezenet_cpu or test_inception_v1_cpu or test_vgg19_cpu or test_inception_v2_cpu or test_zfnet512_cpu or test_resnet50_cpu)'
2019-10-18 08:33:29 +00:00
2020-05-21 08:59:21 +00:00
%post
%python_install_alternative backend-test-tools
%python_install_alternative check-node
%python_install_alternative check-model
%postun
%python_uninstall_alternative backend-test-tools
%python_uninstall_alternative check-node
%python_uninstall_alternative check-model
2019-10-18 08:33:29 +00:00
%files %{python_files}
2020-01-08 10:06:57 +00:00
%doc README.md
2020-02-24 14:53:41 +00:00
%license LICENSE
2020-05-21 08:59:21 +00:00
%python_alternative %{_bindir} /check-model
%python_alternative %{_bindir} /check-node
%python_alternative %{_bindir} /backend-test-tools
2020-03-18 17:33:28 +00:00
%{python_sitearch} /onnx*
2019-10-18 08:33:29 +00:00
2020-08-17 06:37:58 +00:00
%files -n onnx-devel
%{_includedir} /onnx
%{_libdir} /cmake/*
%exclude %{_includedir} /onnx/backend
%files -n onnx-backend-test
%{_includedir} /onnx/backend
%files -n libonnxifi_dummy
%{_libdir} /libonnxifi*.so
%{_libdir} /libonnxifi_loader.*
/usr/lib/libonnxifi.so
%files -n libonnx
%{_libdir} /libonnx.so
%files -n libonnx_proto
%{_libdir} /libonnx_proto.so
2019-10-18 08:33:29 +00:00
%changelog