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
Version : 1.6.0
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-03-15 08:59:16 +00:00
Patch0 : protobuf.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-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-pybind11-devel
BuildRequires : python-rpm-macros
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
%python_subpackages
%description
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.
%package devel
Summary : C/C++ - header files which are used for development
Requires : %{name} = %{version}
%description devel
The headers and other files needed for the development.
%prep
%setup -q -n onnx-%{version}
2020-02-24 14:53:41 +00:00
# avoid bundles
rm -rf third_party
2020-03-15 08:59:16 +00:00
%patch0 -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-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-02-25 11:53:19 +00:00
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON \
2020-02-24 15:44:01 +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 ` "
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
%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
%files %{python_files}
2020-01-08 10:06:57 +00:00
%doc README.md
2020-02-24 14:53:41 +00:00
%license LICENSE
2019-10-18 08:33:29 +00:00
%python3_only %{_bindir} /check-model
%python3_only %{_bindir} /check-node
%python3_only %{_bindir} /backend-test-tools
%{python_sitearch} /*
%exclude %{python_sitearch} /onnx/*.[hc]
%exclude %{python_sitearch} /onnx/common
%exclude %{python_sitearch} /onnx/optimizer
%exclude %{python_sitearch} /onnx/version_converter
%exclude %{python_sitearch} /onnx/shape_inference
%files %{python_files devel}
%{python_sitearch} /onnx/*.[hc]
%{python_sitearch} /onnx/common
%{python_sitearch} /onnx/optimizer
%{python_sitearch} /onnx/version_converter
%{python_sitearch} /onnx/shape_inference
%changelog