1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, libjpeg_turbo
6, numpy
7, python
8, substituteAll
9}:
10
11buildPythonPackage rec {
12 pname = "pyturbojpeg";
13 version = "1.7.0";
14 format = "setuptools";
15
16 src = fetchPypi {
17 pname = "PyTurboJPEG";
18 inherit version;
19 hash = "sha256-9c7lfeM6PXF6CR3JtLi1NPmTwEbrv9Kh1kvdDQbskuI=";
20 };
21
22 patches = [
23 (substituteAll {
24 src = ./lib-path.patch;
25 libturbojpeg = "${libjpeg_turbo.out}/lib/libturbojpeg${stdenv.hostPlatform.extensions.sharedLibrary}";
26 })
27 ];
28
29 propagatedBuildInputs = [
30 numpy
31 ];
32
33 # upstream has no tests, but we want to test whether the library is found
34 checkPhase = ''
35 ${python.interpreter} -c 'from turbojpeg import TurboJPEG; TurboJPEG()'
36 '';
37
38 pythonImportsCheck = [
39 "turbojpeg"
40 ];
41
42 meta = with lib; {
43 description = "A Python wrapper of libjpeg-turbo for decoding and encoding JPEG image";
44 homepage = "https://github.com/lilohuang/PyTurboJPEG";
45 license = licenses.mit;
46 maintainers = with maintainers; [ dotlambda ];
47 };
48}