2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
fetchFromGitHub,
|
|
|
|
buildPythonPackage,
|
|
|
|
rustPlatform,
|
|
|
|
cmake,
|
|
|
|
nasm,
|
|
|
|
substituteAll,
|
|
|
|
libiconv,
|
2024-05-15 15:35:15 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
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.
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libiconv;
|
|
|
|
|
|
|
|
cargoRoot = "py-kornia";
|
2024-06-05 15:53:02 +00:00
|
|
|
cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };
|
2024-05-15 15:35:15 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
maturinBuildFlags = [
|
|
|
|
"-m"
|
|
|
|
"py-kornia/Cargo.toml"
|
|
|
|
];
|
2024-05-15 15:35:15 +00:00
|
|
|
|
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|