about summary refs log tree commit diff
path: root/pkgs/development/python-modules/kornia-rs/default.nix
blob: 57aaa325d2b61b47422a7f159fd4b8e53825236b (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
49
50
51
52
53
54
55
56
{ lib
, fetchFromGitHub
, buildPythonPackage
, rustPlatform
, cmake
, nasm
, substituteAll
}:

buildPythonPackage rec {
  pname = "kornia-rs";
  version = "0.1.2";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "kornia";
    repo = "kornia-rs";
    rev = "refs/tags/v${version}";
    hash = "sha256-7toCMaHzFAzm6gThVLBxKLgQVgFJatdJseDlfdeS8RE=";
  };

  nativeBuildInputs = [
    rustPlatform.maturinBuildHook
    rustPlatform.cargoSetupHook
    cmake # Only for dependencies.
    nasm # Only for dependencies.
  ];

  cargoRoot = "py-kornia";
  cargoDeps = rustPlatform.importCargoLock {
    lockFile = ./Cargo.lock;
  };

  # The path dependency doesn't vendor the dependencies correctly, so get kornia-rs from crates instead.
  patches = [
    (substituteAll {
      src = ./kornia-rs-from-crates.patch;
      inherit version;
    })
  ];

  prePatch = ''
    cp ${./Cargo.lock} py-kornia/Cargo.lock
  '';

  maturinBuildFlags = [ "-m" "py-kornia/Cargo.toml" ];

  dontUseCmakeConfigure = true; # We only want to use CMake to build some Rust dependencies.

  meta = with lib; {
    homepage = "https://github.com/kornia/kornia-rs";
    description = "Python bindings to Low-level Computer Vision library in Rust";
    license = licenses.asl20;
    maintainers = with maintainers; [ chpatrick ];
  };
}