about summary refs log tree commit diff
path: root/pkgs/development/python-modules/onnx/default.nix
blob: b21f343db32a19e014f5daadea34dee1cd5dec52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{ lib
, buildPythonPackage
, bash
, cmake
, fetchPypi
, isPy27
, nbval
, numpy
, protobuf
, pytestCheckHook
, six
, tabulate
, typing-extensions
, pythonRelaxDepsHook
, pytest-runner
}:

buildPythonPackage rec {
  pname = "onnx";
  version = "1.13.0";
  format = "setuptools";

  disabled = isPy27;

  src = fetchPypi {
    inherit pname version;
    sha256 = "sha256-QQs5lQNnhX+XtlCTaB/iSVouI9Y3d6is6vlsVqFtFm4=";
  };

  nativeBuildInputs = [
    cmake
    pythonRelaxDepsHook
  ];

  pythonRelaxDeps = [ "protobuf" ];

  propagatedBuildInputs = [
    protobuf
    numpy
    six
    typing-extensions
  ];

  nativeCheckInputs = [
    nbval
    pytestCheckHook
    pytest-runner
    tabulate
  ];

  postPatch = ''
    chmod +x tools/protoc-gen-mypy.sh.in
    patchShebangs tools/protoc-gen-mypy.sh.in
  '';

  # Set CMAKE_INSTALL_LIBDIR to lib explicitly, because otherwise it gets set
  # to lib64 and cmake incorrectly looks for the protobuf library in lib64
  preConfigure = ''
    export CMAKE_ARGS="-DCMAKE_INSTALL_LIBDIR=lib -DONNX_USE_PROTOBUF_SHARED_LIBS=ON"
  '';

  preBuild = ''
    export MAX_JOBS=$NIX_BUILD_CORES
  '';

  disabledTestPaths = [
    # Unexpected output fields from running code: {'stderr'}
    "onnx/examples/np_array_tensorproto.ipynb"
  ];

  # The executables are just utility scripts that aren't too important
  postInstall = ''
    rm -r $out/bin
  '';

  # The setup.py does all the configuration
  dontUseCmakeConfigure = true;

  pythonImportsCheck = [
    "onnx"
  ];

  meta = with lib; {
    description = "Open Neural Network Exchange";
    homepage = "https://onnx.ai";
    license = licenses.asl20;
    maintainers = with maintainers; [ acairncross ];
  };
}