From 89f53b21711caa825f7a2cb157b94a3f1ccb7249 Mon Sep 17 00:00:00 2001 From: HHR2020 <76608828+HHR2020@users.noreply.github.com> Date: Tue, 14 Jul 2026 18:45:47 +0800 Subject: [PATCH] python3Packages.face-recognition-models: unpin setuptools --- .../0001-use-importlib-resources.patch | 42 +++++++++++++++++++ .../face-recognition/models.nix | 10 ++++- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/python-modules/face-recognition/0001-use-importlib-resources.patch diff --git a/pkgs/development/python-modules/face-recognition/0001-use-importlib-resources.patch b/pkgs/development/python-modules/face-recognition/0001-use-importlib-resources.patch new file mode 100644 index 000000000000..5447a4dd2741 --- /dev/null +++ b/pkgs/development/python-modules/face-recognition/0001-use-importlib-resources.patch @@ -0,0 +1,42 @@ +From c142485d6f34c633d67c5e7ccbbc0baf7a1d695f Mon Sep 17 00:00:00 2001 +From: Erik Janssen <30315129+janssen70@users.noreply.github.com> +Date: Thu, 6 Nov 2025 22:29:41 +0100 +Subject: [PATCH] Refactor from pkg_resources to importlib.resources + +Eliminate startup warning by replacing pkg_resources with importlib.resources.files() for accessing package data files. Includes fallback to importlib_resources for Python 3.7-3.8 compatibility. +--- + face_recognition_models/__init__.py | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +diff --git a/face_recognition_models/__init__.py b/face_recognition_models/__init__.py +index 6201432..2f2a29e 100644 +--- a/face_recognition_models/__init__.py ++++ b/face_recognition_models/__init__.py +@@ -4,17 +4,22 @@ + __email__ = 'ageitgey@gmail.com' + __version__ = '0.1.0' + +-from pkg_resources import resource_filename ++try: ++ # Python 3.9+ ++ from importlib.resources import files ++except ImportError: ++ # Python 3.7-3.8 fallback ++ from importlib_resources import files + + def pose_predictor_model_location(): +- return resource_filename(__name__, "models/shape_predictor_68_face_landmarks.dat") ++ return str(files(__name__).joinpath("models", "shape_predictor_68_face_landmarks.dat")) + + def pose_predictor_five_point_model_location(): +- return resource_filename(__name__, "models/shape_predictor_5_face_landmarks.dat") ++ return str(files(__name__).joinpath("models", "shape_predictor_5_face_landmarks.dat")) + + def face_recognition_model_location(): +- return resource_filename(__name__, "models/dlib_face_recognition_resnet_model_v1.dat") ++ return str(files(__name__).joinpath("models", "dlib_face_recognition_resnet_model_v1.dat")) + + def cnn_face_detector_model_location(): +- return resource_filename(__name__, "models/mmod_human_face_detector.dat") ++ return str(files(__name__).joinpath("models", "mmod_human_face_detector.dat")) + diff --git a/pkgs/development/python-modules/face-recognition/models.nix b/pkgs/development/python-modules/face-recognition/models.nix index aa2ef447dab8..0b710f3c9c74 100644 --- a/pkgs/development/python-modules/face-recognition/models.nix +++ b/pkgs/development/python-modules/face-recognition/models.nix @@ -2,7 +2,7 @@ buildPythonPackage, lib, fetchPypi, - setuptools_80, + setuptools, }: buildPythonPackage (finalAttrs: { @@ -16,7 +16,13 @@ buildPythonPackage (finalAttrs: { hash = "sha256-t5vSAKiMh8mp1EbJkK5xxaYm0fNzAXTm1XAVf/HYls8="; }; - build-system = [ setuptools_80 ]; + patches = [ + # Replace deprecated pkg_resources with importlib.resources + # https://github.com/ageitgey/face_recognition_models/pull/24 + ./0001-use-importlib-resources.patch + ]; + + build-system = [ setuptools ]; # no tests doCheck = false;