File python-rapidocr-onnxruntime.spec of Package python-rapidocr-onnxruntime
#
# spec file for package python-rapidocr-onnxruntime
#
# Copyright (c) 2024 SUSE LLC
#
# 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.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?sle15_python_module_pythons}
Name: python-rapidocr-onnxruntime
Version: 1.3.24
Release: 0
Summary: A cross platform OCR Library based on OnnxRuntime
License: Apache-2.0
URL: https://github.com/RapidAI/RapidOCR
Source0: RapidOCR-%{version}.tar.gz
# https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/required_for_whl_v1.3.0.zip
Source1: required_for_whl_v1.3.0.zip
# PATCH-FIX-OPENSUSE remove usage of get_latest_pypi_version
Patch0: remove_get_latest_pypi_version.patch
# PATCH-FIX-OPENSUSE python sources relocated during build
Patch1: test_inputs_relocated.patch
# Dependencies on requirements_ort.txt
BuildRequires: python-rpm-macros
BuildRequires: %{python_module pip}
BuildRequires: %{python_module wheel}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module pyclipper}
BuildRequires: %{python_module opencv}
%if 0%{?sle_version} == 150600
BuildRequires: %{python_module numpy}
%else
BuildRequires: %{python_module numpy1}
%endif
BuildRequires: %{python_module six}
BuildRequires: %{python_module Shapely}
BuildRequires: %{python_module PyYAML}
BuildRequires: %{python_module Pillow}
BuildRequires: %{python_module onnxruntime}
BuildRequires: unzip
BuildRequires: fdupes
BuildArch: noarch
Requires(post): update-alternatives
Requires(postun): update-alternatives
%python_subpackages
%description
A cross platform OCR Library based on OnnxRuntime.
%prep
%autosetup -p2 -n RapidOCR-%{version}/python
# from .github/workflows/gen_whl_to_pypi_rapidocr_ort.yml - extract the models
unzip %{SOURCE1}
zip_dir=$(basename %{SOURCE1} .zip)
mv ${zip_dir}/resources/models/*.onnx rapidocr_onnxruntime/models
rm -rf ${zip_dir} __MACOSX
# from .github/workflows/gen_whl_to_pypi_rapidocr_ort.yml - setup wheel build
mkdir rapidocr_onnxruntime_t
mv rapidocr_onnxruntime rapidocr_onnxruntime_t
mv rapidocr_onnxruntime_t rapidocr_onnxruntime
pushd rapidocr_onnxruntime
echo "from .rapidocr_onnxruntime.main import RapidOCR, VisRes" > __init__.py
popd
# generate setup.py, set package version and remove the clamp on python version
sed -e 's/@@VERSION@@/%{version}/' -e 's/,<3\.13//' < setup_onnxruntime.py > setup.py
# remove unnecessary files and directories
rm -f setup_*.py requirements_openvino.txt requirements_paddle.txt
rm -rf rapidocr_openvino rapidocr_paddle
rm -rf tests/test_paddle.py tests/test_vino.py
%build
%pyproject_wheel
%install
%pyproject_install
%python_clone -a %{buildroot}%{_bindir}/rapidocr_onnxruntime
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%pytest -v
%post
%python_install_alternative rapidocr_onnxruntime
%postun
%python_uninstall_alternative rapidocr_onnxruntime
%files %{python_files}
%{python_sitelib}/rapidocr_onnxruntime
%{python_sitelib}/rapidocr_onnxruntime-%{version}*-info
%python_alternative %{_bindir}/rapidocr_onnxruntime
%changelog