From c26864122d7c6304fc2ce372075e7a91e0f10714 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Wed, 21 Mar 2018 14:44:41 +0100 Subject: [PATCH] pythonPackages.face_recognition: init at 1.2.1 Adds the python package `face_recognition` and its dependency `face_recognition_models`. This package is a wrapper for `dlib` which is able to detect faces in a given image. I checked the package with the following expression: ``` with import ./. { }; stdenv.mkDerivation { name = "facetest"; src = null; buildInputs = with pythonPackages; [ face_recognition ]; } ``` The package works perfectly fine in a `nix-shell`: ``` $ nix-shell [nix-shell:~]$ python Python 2.7.14 (default, Sep 16 2017, 17:49:51) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import face_recognition >>> img = face_recognition.load_image_file("/home/ma27/me.jpg") >>> print(face_recognition.face_locations(img)) ``` --- .../face_recognition/default.nix | 33 +++++++++++++++++++ .../face_recognition_models/default.nix | 21 ++++++++++++ pkgs/top-level/python-packages.nix | 4 +++ 3 files changed, 58 insertions(+) create mode 100644 pkgs/development/python-modules/face_recognition/default.nix create mode 100644 pkgs/development/python-modules/face_recognition_models/default.nix diff --git a/pkgs/development/python-modules/face_recognition/default.nix b/pkgs/development/python-modules/face_recognition/default.nix new file mode 100644 index 00000000000..3b9a2c15b6e --- /dev/null +++ b/pkgs/development/python-modules/face_recognition/default.nix @@ -0,0 +1,33 @@ +{ buildPythonPackage, fetchFromGitHub, pillow, click, dlib, numpy +, face_recognition_models, scipy, stdenv, flake8, tox, pytest, glibcLocales +}: + +buildPythonPackage rec { + pname = "face_recognition"; + version = "1.2.1"; + + src = fetchFromGitHub { + repo = pname; + owner = "ageitgey"; + rev = "fe421d4acd76e8a19098e942b7bd9c3bbef6ebc4"; # no tags available in Git, pure revs are pushed to pypi + sha256 = "0wv5qxkg7xv1cr43zhhbixaqgj08xw2l7yvwl8g3fb2kdxyndw1c"; + }; + + postPatch = '' + substituteInPlace setup.py --replace "flake8==2.6.0" "flake8" + ''; + + propagatedBuildInputs = [ pillow click dlib numpy face_recognition_models scipy ]; + + checkInputs = [ flake8 tox pytest glibcLocales ]; + checkPhase = '' + LC_ALL="en_US.UTF-8" py.test + ''; + + meta = with stdenv.lib; { + license = licenses.mit; + homepage = https://github.com/ageitgey/face_recognition; + maintainers = with maintainers; [ ma27 ]; + description = "The world's simplest facial recognition api for Python and the command line"; + }; +} diff --git a/pkgs/development/python-modules/face_recognition_models/default.nix b/pkgs/development/python-modules/face_recognition_models/default.nix new file mode 100644 index 00000000000..960bffb903d --- /dev/null +++ b/pkgs/development/python-modules/face_recognition_models/default.nix @@ -0,0 +1,21 @@ +{ buildPythonPackage, stdenv, fetchPypi }: + +buildPythonPackage rec { + pname = "face_recognition_models"; + version = "0.3.0"; + + src = fetchPypi { + inherit pname version; + sha256 = "1kwnv3qpy5bhspk780bkyg8jd9n5f6p91ja6sjlwk1wcm00d56xp"; + }; + + # no module named `tests` as no tests are available + doCheck = false; + + meta = with stdenv.lib; { + homepage = https://github.com/ageitgey/face_recognition_models; + license = licenses.cc0; + maintainers = with maintainers; [ ma27 ]; + description = "Trained models for the face_recognition python library"; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 5c49b6bc0c8..43082c4f16e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4209,6 +4209,10 @@ in { }; }; + face_recognition = callPackage ../development/python-modules/face_recognition { }; + + face_recognition_models = callPackage ../development/python-modules/face_recognition_models { }; + faker = callPackage ../development/python-modules/faker { }; fake_factory = buildPythonPackage rec {