From f192fada2667dff0d97ab08749e09c7bd9b81eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Sun, 27 Oct 2024 10:24:07 -0700 Subject: [PATCH] python312Packages.easyocr: modernize --- .../python-modules/easyocr/default.nix | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/pkgs/development/python-modules/easyocr/default.nix b/pkgs/development/python-modules/easyocr/default.nix index 6babbe500e1c..a75434c018ae 100644 --- a/pkgs/development/python-modules/easyocr/default.nix +++ b/pkgs/development/python-modules/easyocr/default.nix @@ -2,9 +2,9 @@ lib, buildPythonPackage, fetchFromGitHub, + setuptools, hdf5, numpy, - onnx, opencv-python-headless, pillow, pyaml, @@ -16,12 +16,13 @@ shapely, torch, torchvision, + python, }: buildPythonPackage rec { pname = "easyocr"; version = "1.7.2"; - format = "setuptools"; + pyproject = true; disabled = pythonOlder "3.7"; @@ -32,12 +33,19 @@ buildPythonPackage rec { hash = "sha256-9mrAxt2lphYtLW81lGO5SYHsnMnSA/VpHiY2NffD/Js="; }; - postPatch = '' - substituteInPlace requirements.txt \ - --replace "ninja" "" - ''; + build-system = [ + setuptools + ]; - propagatedBuildInputs = [ + pythonRelaxDeps = [ + "torchvision" + ]; + + pythonRemoveDeps = [ + "ninja" + ]; + + dependencies = [ hdf5 numpy opencv-python-headless @@ -52,7 +60,19 @@ buildPythonPackage rec { torchvision ]; - nativeCheckInputs = [ onnx ]; + checkPhase = '' + runHook preCheck + + export HOME="$(mktemp -d)" + pushd unit_test + ${python.interpreter} run_unit_test.py --easyocr "$out/${python.sitePackages}/easyocr" + popd + + runHook postCheck + ''; + + # downloads detection model from the internet + doCheck = false; pythonImportsCheck = [ "easyocr" ];