From b263dec17d54ef080357734056a6e5cad6fdfc75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Sun, 27 Oct 2024 09:53:13 -0700 Subject: [PATCH 1/7] python312Packages.opencv-python-headless: init at 4.9.0 --- .../opencv-python-headless/default.nix | 14 ++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 pkgs/development/python-modules/opencv-python-headless/default.nix diff --git a/pkgs/development/python-modules/opencv-python-headless/default.nix b/pkgs/development/python-modules/opencv-python-headless/default.nix new file mode 100644 index 000000000000..7a379d39b879 --- /dev/null +++ b/pkgs/development/python-modules/opencv-python-headless/default.nix @@ -0,0 +1,14 @@ +{ + mkPythonMetaPackage, + opencv4, +}: + +mkPythonMetaPackage { + pname = "opencv-python-headless"; + inherit (opencv4) version; + dependencies = [ opencv4 ]; + optional-dependencies = opencv4.optional-dependencies or { }; + meta = { + inherit (opencv4.meta) description homepage; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 0e4926959ab1..76e5e1f13dbb 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -9368,6 +9368,8 @@ self: super: with self; { pythonPackages = self; }); + opencv-python-headless = callPackage ../development/python-modules/opencv-python-headless { }; + openerz-api = callPackage ../development/python-modules/openerz-api { }; openevsewifi = callPackage ../development/python-modules/openevsewifi { }; From c2488054647f390bf52266fd8f8dec15d42fcaf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Sun, 27 Oct 2024 09:56:19 -0700 Subject: [PATCH 2/7] immich-machine-learning: clean up dependencies --- pkgs/by-name/im/immich-machine-learning/package.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/im/immich-machine-learning/package.nix b/pkgs/by-name/im/immich-machine-learning/package.nix index 1029055a3b0f..53842090fb5a 100644 --- a/pkgs/by-name/im/immich-machine-learning/package.nix +++ b/pkgs/by-name/im/immich-machine-learning/package.nix @@ -25,9 +25,12 @@ python.pkgs.buildPythonApplication rec { pythonRelaxDeps = [ "pydantic-settings" + ]; + + pythonRemoveDeps = [ + # https://github.com/immich-app/immich/pull/13762 "setuptools" ]; - pythonRemoveDeps = [ "opencv-python-headless" ]; build-system = with python.pkgs; [ poetry-core @@ -38,7 +41,7 @@ python.pkgs.buildPythonApplication rec { with python.pkgs; [ insightface - opencv4 + opencv-python-headless pillow fastapi uvicorn @@ -47,7 +50,6 @@ python.pkgs.buildPythonApplication rec { aiocache rich ftfy - setuptools python-multipart orjson gunicorn From d792caed67b354f5848cc9e74b58e8fe39b4259c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Sun, 27 Oct 2024 09:58:23 -0700 Subject: [PATCH 3/7] open-webui: use opencv-python-headless and psycopg2-binary --- pkgs/by-name/op/open-webui/package.nix | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkgs/by-name/op/open-webui/package.nix b/pkgs/by-name/op/open-webui/package.nix index e401e72d0ff3..b2b92282dc38 100644 --- a/pkgs/by-name/op/open-webui/package.nix +++ b/pkgs/by-name/op/open-webui/package.nix @@ -55,10 +55,6 @@ python3.pkgs.buildPythonApplication rec { pythonRelaxDeps = true; pythonRemoveDeps = [ - # using `opencv4` - "opencv-python-headless" - # using `psycopg2` instead - "psycopg2-binary" "docker" "pytest" "pytest-docker" @@ -97,14 +93,14 @@ python3.pkgs.buildPythonApplication rec { markdown nltk openai - opencv4 + opencv-python-headless openpyxl pandas passlib peewee peewee-migrate psutil - psycopg2 + psycopg2-binary pydub pyjwt pymilvus From a15122931b76ea891ef0bbea289fbb2381f94a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Sun, 27 Oct 2024 10:00:31 -0700 Subject: [PATCH 4/7] python312Packages.easyocr: use opencv-python-headless --- pkgs/development/python-modules/easyocr/default.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/easyocr/default.nix b/pkgs/development/python-modules/easyocr/default.nix index a1ff17f2b360..6babbe500e1c 100644 --- a/pkgs/development/python-modules/easyocr/default.nix +++ b/pkgs/development/python-modules/easyocr/default.nix @@ -5,7 +5,7 @@ hdf5, numpy, onnx, - opencv4, + opencv-python-headless, pillow, pyaml, pyclipper, @@ -34,14 +34,13 @@ buildPythonPackage rec { postPatch = '' substituteInPlace requirements.txt \ - --replace "opencv-python-headless" "" \ --replace "ninja" "" ''; propagatedBuildInputs = [ hdf5 numpy - opencv4 + opencv-python-headless pillow pyaml pyclipper From 3c80dcf63a56f85c8ce88e7638d7f945af66dd9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Sun, 27 Oct 2024 10:04:02 -0700 Subject: [PATCH 5/7] python312Packages.labelbox: use opencv-python-headless --- pkgs/development/python-modules/labelbox/default.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/labelbox/default.nix b/pkgs/development/python-modules/labelbox/default.nix index 060b8d94441e..684880426f71 100644 --- a/pkgs/development/python-modules/labelbox/default.nix +++ b/pkgs/development/python-modules/labelbox/default.nix @@ -10,7 +10,7 @@ nbconvert, nbformat, numpy, - opencv4, + opencv-python-headless, pillow, pydantic, pyproj, @@ -47,8 +47,6 @@ buildPythonPackage rec { pythonRelaxDeps = [ "python-dateutil" ]; - pythonRemoveDeps = [ "opencv-python-headless" ]; - build-system = [ hatchling ]; dependencies = [ @@ -67,7 +65,7 @@ buildPythonPackage rec { shapely numpy pillow - opencv4 + opencv-python-headless typeguard imagesize pyproj From 942369cf08ed7245c8a2b48fc30d87f1f4c541f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Sun, 27 Oct 2024 10:08:34 -0700 Subject: [PATCH 6/7] python312Packages.labelbox: unpin mypy --- pkgs/development/python-modules/labelbox/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/labelbox/default.nix b/pkgs/development/python-modules/labelbox/default.nix index 684880426f71..b81962cd7d9d 100644 --- a/pkgs/development/python-modules/labelbox/default.nix +++ b/pkgs/development/python-modules/labelbox/default.nix @@ -45,7 +45,10 @@ buildPythonPackage rec { sourceRoot = "${src.name}/libs/labelbox"; - pythonRelaxDeps = [ "python-dateutil" ]; + pythonRelaxDeps = [ + "mypy" + "python-dateutil" + ]; build-system = [ hatchling ]; 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 7/7] 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" ];