1{ lib
2, fetchpatch
3, buildPythonPackage
4, fetchPypi
5, pythonOlder
6, isPy27
7, cmake
8, protobuf
9, numpy
10, six
11, typing-extensions
12, typing
13, pytestrunner
14, pytest
15, nbval
16, tabulate
17}:
18
19buildPythonPackage rec {
20 pname = "onnx";
21 version = "1.6.0";
22
23 # Due to Protobuf packaging issues this build of Onnx with Python 2 gives
24 # errors on import
25 disabled = isPy27;
26
27 src = fetchPypi {
28 inherit pname version;
29 sha256 = "0ig33jl3591041lyylxp52yi20rfrcqx3i030hd6al8iabzc721v";
30 };
31
32 # Remove the unqualified requirement for the typing package for running the
33 # tests. typing is already required for the installation, where it is
34 # correctly qualified so as to only be required for sufficiently old Python
35 # versions.
36 # This patch should be in the next release (>1.6).
37 patches = [
38 (fetchpatch {
39 url = "https://github.com/onnx/onnx/commit/c963586d0f8dd5740777b2fd06f04ec60816de9f.patch";
40 sha256 = "1hl26cw5zckc91gmh0bdah87jyprccxiw0f4i5h1gwkq28hm6wbj";
41 })
42 ];
43
44 nativeBuildInputs = [ cmake ];
45
46 propagatedBuildInputs = [
47 protobuf
48 numpy
49 six
50 typing-extensions
51 ] ++ lib.optional (pythonOlder "3.5") [ typing ];
52
53 checkInputs = [
54 pytestrunner
55 pytest
56 nbval
57 tabulate
58 ];
59
60 postPatch = ''
61 patchShebangs tools/protoc-gen-mypy.py
62 '';
63
64 # The executables are just utility scripts that aren't too important
65 postInstall = ''
66 rm -r $out/bin
67 '';
68
69 # The setup.py does all the configuration (running CMake)
70 dontConfigure = true;
71
72 meta = {
73 homepage = http://onnx.ai;
74 description = "Open Neural Network Exchange";
75 license = lib.licenses.mit;
76 maintainers = [ lib.maintainers.acairncross ];
77 };
78}