1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 # runtime dependencies
6 numpy,
7 onnx,
8 requests,
9 six,
10 flatbuffers,
11 protobuf,
12 tensorflow,
13 # check dependencies
14 pytestCheckHook,
15 graphviz,
16 parameterized,
17 pytest-cov-stub,
18 pyyaml,
19 timeout-decorator,
20 onnxruntime,
21 keras,
22}:
23
24buildPythonPackage rec {
25 pname = "tf2onnx";
26 version = "1.16.1";
27 format = "setuptools";
28
29 src = fetchFromGitHub {
30 owner = "onnx";
31 repo = "tensorflow-onnx";
32 rev = "refs/tags/v${version}";
33 hash = "sha256-qtRzckw/KHWm3gjFwF+cPuBhGbfktjhYIwImwHn2CFk=";
34 };
35
36 postPatch = ''
37 substituteInPlace setup.py \
38 --replace-fail "'pytest-runner'" ""
39 '';
40
41 pythonRelaxDeps = [ "flatbuffers" ];
42
43 propagatedBuildInputs = [
44 numpy
45 onnx
46 requests
47 six
48 flatbuffers
49 protobuf
50 tensorflow
51 onnxruntime
52 ];
53
54 pythonImportsCheck = [ "tf2onnx" ];
55
56 nativeCheckInputs = [
57 pytestCheckHook
58 graphviz
59 parameterized
60 pytest-cov-stub
61 pyyaml
62 timeout-decorator
63 keras
64 ];
65
66 # TODO investigate the failures
67 disabledTestPaths = [
68 "tests/test_backend.py"
69 "tests/test_einsum_helper.py"
70 "tests/test_einsum_optimizers.py"
71 ];
72
73 disabledTests = [ "test_profile_conversion_time" ];
74
75 meta = with lib; {
76 description = "Convert TensorFlow, Keras, Tensorflow.js and Tflite models to ONNX";
77 homepage = "https://github.com/onnx/tensorflow-onnx";
78 license = licenses.asl20;
79 maintainers = with maintainers; [ happysalada ];
80 # Duplicated `protobuf` in the derivation:
81 # - version 4.24.4 (from onnx), the default version of protobuf in nixpkgs
82 # - version 4.21.12 (from tensorflow), pinned as such because tensorflow is outdated and does
83 # not support more recent versions of protobuf
84 broken = true;
85 };
86}