From bbb3c208e10322033dce520ee192e493faa046f8 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sat, 23 Aug 2025 16:53:37 -0400 Subject: [PATCH] python313Packages.rapidocr-onnxruntime: fix build --- .../rapidocr-onnxruntime/default.nix | 42 ++++++++++--------- .../setup-py-override-version-checking.patch | 29 +++++++------ 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix b/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix index 1ead42bb779b..97295a4216b2 100644 --- a/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix +++ b/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix @@ -7,8 +7,10 @@ replaceVars, setuptools, + colorlog, pyclipper, opencv-python, + omegaconf, numpy, six, shapely, @@ -62,44 +64,46 @@ buildPythonPackage { ]; postPatch = '' - mv setup_onnxruntime.py setup.py - mkdir -p rapidocr_onnxruntime/models + mkdir -p rapidocr/models - ln -s ${models}/* rapidocr_onnxruntime/models + ln -s ${models}/* rapidocr/models # Magic patch from upstream - what does this even do?? - echo "from .rapidocr_onnxruntime.main import RapidOCR, VisRes" > __init__.py + echo "from .rapidocr.main import RapidOCR, VisRes" > __init__.py ''; - # Upstream expects the source files to be under rapidocr_onnxruntime/rapidocr_onnxruntime - # instead of rapidocr_onnxruntime for the wheel to build correctly. + # Upstream expects the source files to be under rapidocr/rapidocr + # instead of rapidocr for the wheel to build correctly. preBuild = '' - mkdir rapidocr_onnxruntime_t - mv rapidocr_onnxruntime rapidocr_onnxruntime_t - mv rapidocr_onnxruntime_t rapidocr_onnxruntime + mkdir rapidocr_t + mv rapidocr rapidocr_t + mv rapidocr_t rapidocr ''; # Revert the above hack postBuild = '' - mv rapidocr_onnxruntime rapidocr_onnxruntime_t - mv rapidocr_onnxruntime_t/* . + mv rapidocr rapidocr_t + mv rapidocr_t/* . ''; build-system = [ setuptools ]; dependencies = [ - pyclipper - opencv-python + colorlog numpy - six - shapely - pyyaml - pillow + omegaconf onnxruntime + opencv-python + pillow + pyclipper + pyyaml + requests + shapely + six tqdm ]; - pythonImportsCheck = [ "rapidocr_onnxruntime" ]; + pythonImportsCheck = [ "rapidocr" ]; # As of version 2.1.0, 61 out of 70 tests require internet access. # It's just not plausible to manually pick out ones that actually work @@ -115,6 +119,6 @@ buildPythonPackage { homepage = "https://github.com/RapidAI/RapidOCR"; license = with lib.licenses; [ asl20 ]; maintainers = with lib.maintainers; [ pluiedev ]; - mainProgram = "rapidocr_onnxruntime"; + mainProgram = "rapidocr"; }; } diff --git a/pkgs/development/python-modules/rapidocr-onnxruntime/setup-py-override-version-checking.patch b/pkgs/development/python-modules/rapidocr-onnxruntime/setup-py-override-version-checking.patch index 3800ded38c6a..f940c1c29dc1 100644 --- a/pkgs/development/python-modules/rapidocr-onnxruntime/setup-py-override-version-checking.patch +++ b/pkgs/development/python-modules/rapidocr-onnxruntime/setup-py-override-version-checking.patch @@ -1,22 +1,25 @@ -diff --git i/setup_onnxruntime.py w/setup_onnxruntime.py -index e9572e9..f5f3b32 100644 ---- i/setup_onnxruntime.py -+++ w/setup_onnxruntime.py +diff --git a/setup.py b/setup.py +index 16938a4..5167972 100644 +--- a/setup.py ++++ b/setup.py @@ -6,7 +6,6 @@ from pathlib import Path from typing import List, Union - + import setuptools -from get_pypi_latest_version import GetPyPiLatestVersion - - + + def read_txt(txt_path: Union[Path, str]) -> List[str]: -@@ -25,17 +24,7 @@ def get_readme(): - - - MODULE_NAME = "rapidocr_onnxruntime" +@@ -25,20 +24,7 @@ def get_readme(): + + + MODULE_NAME = "rapidocr" - -obtainer = GetPyPiLatestVersion() --latest_version = obtainer(MODULE_NAME) +-try: +- latest_version = obtainer(MODULE_NAME) +-except Exception as e: +- latest_version = "0.0.0" -VERSION_NUM = obtainer.version_add_one(latest_version, add_patch=True) - -if len(sys.argv) > 2: @@ -26,6 +29,6 @@ index e9572e9..f5f3b32 100644 - VERSION_NUM = matched_versions -sys.argv = sys.argv[:2] +VERSION_NUM = "@version@" - + project_urls = { "Documentation": "https://rapidai.github.io/RapidOCRDocs",