about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pyturbojpeg/default.nix
blob: dea91c9c4469baf2bfb09dd04e6f51f3cbabda2c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchPypi,
  libjpeg_turbo,
  setuptools,
  numpy,
  python,
  substituteAll,
}:

buildPythonPackage rec {
  pname = "pyturbojpeg";
  version = "1.7.3";
  pyproject = true;

  src = fetchPypi {
    pname = "PyTurboJPEG";
    inherit version;
    hash = "sha256-edSOOrU0YVKP+4AJxCCYnQh6iewxVFTM1QmU88mukis=";
  };

  patches = [
    (substituteAll {
      src = ./lib-path.patch;
      libturbojpeg = "${libjpeg_turbo.out}/lib/libturbojpeg${stdenv.hostPlatform.extensions.sharedLibrary}";
    })
  ];

  nativeBuildInputs = [ setuptools ];

  propagatedBuildInputs = [ numpy ];

  # upstream has no tests, but we want to test whether the library is found
  checkPhase = ''
    ${python.interpreter} -c 'from turbojpeg import TurboJPEG; TurboJPEG()'
  '';

  pythonImportsCheck = [ "turbojpeg" ];

  meta = with lib; {
    description = "A Python wrapper of libjpeg-turbo for decoding and encoding JPEG image";
    homepage = "https://github.com/lilohuang/PyTurboJPEG";
    license = licenses.mit;
    maintainers = with maintainers; [ dotlambda ];
  };
}