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