Files
nixpkgs/pkgs/development/python-modules/ai-edge-litert/default.nix
T
Martin Weinelt 6259a4d1da frigate: migrate to ai-edge-litert interpreter
The combination of tensorflow-bin and onnxruntime in the same Python
interpreter is super fragile. This problem does not seem to exist
with tflite-runtime (used upstream) or ai-edge-litert (the successor
to tflite).

Fixes: #476181
2026-01-16 01:45:43 +01:00

88 lines
1.7 KiB
Nix

{
autoPatchelfHook,
buildPythonPackage,
fetchurl,
lib,
python,
pythonAtLeast,
stdenv,
# dependencies
backports-strenum,
flatbuffers,
numpy,
protobuf,
tqdm,
typing-extensions,
# optional-dependencies
lark,
ml-dtypes,
}:
let
release = builtins.fromJSON (builtins.readFile ./release.json);
platforms = release.src;
platform =
platforms.${stdenv.hostPlatform.system}
or (throw "ai-edge-litert: unsupported platform (${stdenv.hostPlatform.system})");
pythonMajorMinor = lib.versions.majorMinor python.version;
source =
platform.${pythonMajorMinor}
or (throw "ai-edge-litert: unsupported python version (${pythonMajorMinor})");
in
buildPythonPackage {
pname = "ai-edge-litert";
version = release.version;
format = "wheel";
src = fetchurl {
inherit (source)
url
hash
;
};
nativeBuildInputs = [ autoPatchelfHook ];
dependencies = [
backports-strenum
flatbuffers
numpy
protobuf
tqdm
typing-extensions
];
optional-dependencies = {
model-utils = [
lark
ml-dtypes
# TODO :xdsl
];
# TODO: npu-sdk
};
pythonRemoveDeps = lib.optionals (pythonAtLeast "3.12") [
# https://github.com/google-ai-edge/LiteRT/pull/5298
"backports.strenum"
];
pythonImportsCheck = [
"ai_edge_litert"
"ai_edge_litert.interpreter"
];
passthru.updateScript = ./update.py;
meta = {
description = "LiteRT is for mobile and embedded devices";
downloadPage = "https://github.com/google-ai-edge/LiteRT";
homepage = "https://www.tensorflow.org/lite/";
license = lib.licenses.asl20;
platforms = lib.attrNames platforms;
maintainers = with lib.maintainers; [ hexa ];
};
}