diff --git a/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix b/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix index 6e4f3efadadb..1783e28f58a3 100644 --- a/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix +++ b/pkgs/development/python-modules/rapidocr-onnxruntime/default.nix @@ -1,5 +1,6 @@ { lib, + config, buildPythonPackage, fetchFromGitHub, @@ -19,6 +20,9 @@ pytestCheckHook, requests, + + cudaSupport ? config.cudaSupport, + rapidocr-onnxruntime, }: let version = "1.4.4"; @@ -115,10 +119,27 @@ buildPythonPackage { "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; + # 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 passthru.skipBulkUpdate = true; + passthru.gpuCheck = rapidocr-onnxruntime.overridePythonAttrs (old: { + requiredSystemFeatures = [ "cuda" ]; + doCheck = true; + + disabledTests = + (old.disabledTests or [ ]) + ++ lib.optionals cudaSupport [ + # IndexError: list index out of range + "test_ort_cuda_warning" + ]; + }); + meta = { changelog = "https://github.com/RapidAI/RapidOCR/releases/tag/${src.tag}"; description = "Cross platform OCR Library based on OnnxRuntime";