From 7c400364c027efb47e484ed99bb3e895c8422059 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 26 Jan 2026 15:16:58 +0000 Subject: [PATCH 1/2] python3Packages.rapidocr-onnxruntime: use finalAttrs --- .../rapidocr-onnxruntime/default.nix | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix b/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix index 1783e28f58a3..869ff38fc791 100644 --- a/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix +++ b/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix @@ -25,15 +25,6 @@ rapidocr-onnxruntime, }: let - version = "1.4.4"; - - src = fetchFromGitHub { - owner = "RapidAI"; - repo = "RapidOCR"; - tag = "v${version}"; - hash = "sha256-x0VELDKOffxbV3v0aDFJFuDC4YfsGM548XWgINmRc3M="; - }; - models = fetchzip { url = "https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/required_for_whl_v1.3.0.zip"; @@ -42,12 +33,19 @@ let } + "/required_for_whl_v1.3.0/resources/models"; in -buildPythonPackage { +buildPythonPackage (finalAttrs: { pname = "rapidocr-onnxruntime"; - inherit version src; + version = "1.4.4"; pyproject = true; - sourceRoot = "${src.name}/python"; + src = fetchFromGitHub { + owner = "RapidAI"; + repo = "RapidOCR"; + tag = "v${finalAttrs.version}"; + hash = "sha256-x0VELDKOffxbV3v0aDFJFuDC4YfsGM548XWgINmRc3M="; + }; + + sourceRoot = "${finalAttrs.src.name}/python"; # HACK: # Upstream uses a very unconventional structure to organize the packages, and we have to coax the @@ -61,7 +59,7 @@ buildPythonPackage { # hence we patch that out and get the version from the build environment directly. patches = [ (replaceVars ./setup-py-override-version-checking.patch { - inherit version; + inherit (finalAttrs) version; }) ]; @@ -141,11 +139,11 @@ buildPythonPackage { }); meta = { - changelog = "https://github.com/RapidAI/RapidOCR/releases/tag/${src.tag}"; + changelog = "https://github.com/RapidAI/RapidOCR/releases/tag/${finalAttrs.src.tag}"; description = "Cross platform OCR Library based on OnnxRuntime"; homepage = "https://github.com/RapidAI/RapidOCR"; license = lib.licenses.asl20; maintainers = with lib.maintainers; [ wrvsrx ]; mainProgram = "rapidocr_onnxruntime"; }; -} +}) From aecf396c4c1f574c8fc4cf2a8548d2d01efc9194 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 26 Jan 2026 15:28:26 +0000 Subject: [PATCH 2/2] python3Packages.rapidocr-onnruntime: disable checks on aarch64-linux --- .../rapidocr-onnxruntime/default.nix | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix b/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix index 869ff38fc791..2a61da96c617 100644 --- a/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix +++ b/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix @@ -1,5 +1,6 @@ { lib, + stdenv, config, buildPythonPackage, fetchFromGitHub, @@ -32,6 +33,8 @@ let stripRoot = false; } + "/required_for_whl_v1.3.0/resources/models"; + + isNotAarch64Linux = !(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64); in buildPythonPackage (finalAttrs: { pname = "rapidocr-onnxruntime"; @@ -99,7 +102,13 @@ buildPythonPackage (finalAttrs: { tqdm ]; - pythonImportsCheck = [ "rapidocr_onnxruntime" ]; + # aarch64-linux fails cpuinfo test, because /sys/devices/system/cpu/ does not exist in the sandbox: + # terminate called after throwing an instance of 'onnxruntime::OnnxRuntimeException' + # + # -> Skip all tests that require importing markitdown + pythonImportsCheck = lib.optionals isNotAarch64Linux [ + "rapidocr_onnxruntime" + ]; nativeCheckInputs = [ pytestCheckHook @@ -117,10 +126,14 @@ buildPythonPackage (finalAttrs: { "test_long_img" ]; - # Tests require access to a physical GPU to work, otherwise the interpreter crashes: - # Fatal Python error: Aborted - # File "/nix/store/..onnxruntime/capi/onnxruntime_inference_collection.py", line 561 in _create_inference_session - doCheck = !cudaSupport; + doCheck = + # Tests require access to a physical GPU to work, otherwise the interpreter crashes: + # Fatal Python error: Aborted + # File "/nix/store/..onnxruntime/capi/onnxruntime_inference_collection.py", line 561 in _create_inference_session + (!cudaSupport) + # See comment above + # 'onnxruntime::OnnxRuntimeException' + && isNotAarch64Linux; # rapidocr-onnxruntime has been renamed to rapidocr by upstream since 2.0.0. However, some packages like open-webui still requires rapidocr-onnxruntime 1.4.4. Therefore we set no auto update here. # nixpkgs-update: no auto update