1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8
9 # dependencies
10 flatbuffers,
11 numpy,
12 onnx,
13 onnxruntime,
14 protobuf,
15 requests,
16 six,
17 tensorflow,
18}:
19
20buildPythonPackage rec {
21 pname = "tf2onnx";
22 version = "1.16.1";
23 pyproject = true;
24
25 src = fetchFromGitHub {
26 owner = "onnx";
27 repo = "tensorflow-onnx";
28 tag = "v${version}";
29 hash = "sha256-qtRzckw/KHWm3gjFwF+cPuBhGbfktjhYIwImwHn2CFk=";
30 };
31
32 postPatch = ''
33 substituteInPlace setup.py \
34 --replace-fail "'pytest-runner'" ""
35 '';
36
37 build-system = [
38 setuptools
39 ];
40
41 pythonRelaxDeps = [
42 "protobuf"
43 ];
44
45 dependencies = [
46 flatbuffers
47 numpy
48 onnx
49 onnxruntime
50 protobuf
51 requests
52 six
53 tensorflow
54 ];
55
56 pythonImportsCheck = [ "tf2onnx" ];
57
58 # All tests fail at import with:
59 # AttributeError: `...` is not available with Keras 3.
60 doCheck = false;
61
62 meta = {
63 description = "Convert TensorFlow, Keras, Tensorflow.js and Tflite models to ONNX";
64 homepage = "https://github.com/onnx/tensorflow-onnx";
65 changelog = "https://github.com/onnx/tensorflow-onnx/releases/tag/v${version}";
66 license = lib.licenses.asl20;
67 maintainers = with lib.maintainers; [ happysalada ];
68 badPlatforms = [
69 # Segmentation fault on darwin
70 lib.systems.inspect.patterns.isDarwin
71 ];
72 };
73}