about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pyacoustid
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/pyacoustid')
-rw-r--r--pkgs/development/python-modules/pyacoustid/default.nix34
-rw-r--r--pkgs/development/python-modules/pyacoustid/pyacoustid-py3.patch32
2 files changed, 66 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/pyacoustid/default.nix b/pkgs/development/python-modules/pyacoustid/default.nix
new file mode 100644
index 000000000000..ba7879554a83
--- /dev/null
+++ b/pkgs/development/python-modules/pyacoustid/default.nix
@@ -0,0 +1,34 @@
+{ stdenv
+, buildPythonPackage
+, fetchPypi
+, requests
+, audioread
+, pkgs
+}:
+
+buildPythonPackage rec {
+  pname = "pyacoustid";
+  version = "1.1.0";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "0117039cb116af245e6866e8e8bf3c9c8b2853ad087142bd0c2dfc0acc09d452";
+  };
+
+  propagatedBuildInputs = [ requests audioread ];
+
+  patches = [ ./pyacoustid-py3.patch ];
+
+  postPatch = ''
+    sed -i \
+        -e '/^FPCALC_COMMAND *=/s|=.*|= "${pkgs.chromaprint}/bin/fpcalc"|' \
+        acoustid.py
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Bindings for Chromaprint acoustic fingerprinting";
+    homepage = "https://github.com/sampsyo/pyacoustid";
+    license = licenses.mit;
+  };
+
+}
diff --git a/pkgs/development/python-modules/pyacoustid/pyacoustid-py3.patch b/pkgs/development/python-modules/pyacoustid/pyacoustid-py3.patch
new file mode 100644
index 000000000000..f79b35fd345e
--- /dev/null
+++ b/pkgs/development/python-modules/pyacoustid/pyacoustid-py3.patch
@@ -0,0 +1,32 @@
+From 19209469a709ec0914f82c9de23137e360e5e804 Mon Sep 17 00:00:00 2001
+From: Simon Chopin <chopin.simon@gmail.com>
+Date: Mon, 29 Sep 2014 10:38:20 +0200
+Subject: [PATCH] Explicit the UTF-8 encoding also when installing using Python
+ 3
+
+If the locale isn't UTF-8, or for some reason Python doesn't pick up on
+it, it will try to decode using ASCII, which will of course cause
+mayhem, crash and despair.
+
+This patch will be shipped with the Debian package 1.1.0-1
+---
+ setup.py | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index eafe5ea..0732fe3 100644
+--- a/setup.py
++++ b/setup.py
+@@ -18,9 +18,10 @@
+ 
+ def _read(fn):
+     path = os.path.join(os.path.dirname(__file__), fn)
+-    data = open(path).read()
+     if sys.version_info[0] < 3:
+-        data = data.decode('utf8')
++        data = open(path).read().decode('utf8')
++    else:
++        data = open(path, encoding='utf8').read()
+     # Special case some Unicode characters; PyPI seems to only like ASCII.
+     data = data.replace(u'\xe1', u'a')
+     data = data.replace(u'\u0161', u's')