1{
2 lib,
3 fetchFromGitHub,
4 buildPythonPackage,
5
6 # nativeBuildInputs
7 rustPlatform,
8 cmake,
9 nasm,
10
11 # tests
12 numpy,
13 pytestCheckHook,
14 torch,
15}:
16
17buildPythonPackage rec {
18 pname = "kornia-rs";
19 version = "0.1.9";
20 pyproject = true;
21
22 src = fetchFromGitHub {
23 owner = "kornia";
24 repo = "kornia-rs";
25 tag = "v${version}";
26 hash = "sha256-0Id1Iyd/xyqSqFvg/TXnlX1DgMUWuMS9KbtDXduwU+Y=";
27 };
28
29 nativeBuildInputs = [
30 rustPlatform.maturinBuildHook
31 rustPlatform.cargoSetupHook
32 cmake # Only for dependencies.
33 nasm # Only for dependencies.
34 ];
35
36 cargoRoot = "kornia-py";
37 cargoDeps = rustPlatform.importCargoLock {
38 lockFile = ./Cargo.lock;
39 };
40
41 postPatch = ''
42 ln -s ${./Cargo.lock} kornia-py/Cargo.lock
43 '';
44
45 maturinBuildFlags = [
46 "-m"
47 "kornia-py/Cargo.toml"
48 ];
49
50 dontUseCmakeConfigure = true; # We only want to use CMake to build some Rust dependencies.
51
52 nativeCheckInputs = [
53 numpy
54 pytestCheckHook
55 torch
56 ];
57
58 meta = {
59 homepage = "https://github.com/kornia/kornia-rs";
60 description = "Python bindings to Low-level Computer Vision library in Rust";
61 changelog = "https://github.com/kornia/kornia-rs/releases/tag/v${version}";
62 license = lib.licenses.asl20;
63 maintainers = with lib.maintainers; [ chpatrick ];
64 badPlatforms = [
65 # error: could not compile `kornia-3d` (lib)
66 # error: rustc interrupted by SIGSEGV
67 "aarch64-linux"
68 ];
69 };
70}