at 25.11-pre 2.3 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 6 # build-system 7 cmake, 8 pybind11, 9 setuptools, 10 11 # buildInputs 12 abseil-cpp, 13 protobuf, 14 gtest, 15 16 # dependencies 17 numpy, 18 19 google-re2, 20 nbval, 21 parameterized, 22 pillow, 23 pytestCheckHook, 24 tabulate, 25}: 26 27let 28 gtestStatic = gtest.override { static = true; }; 29in 30buildPythonPackage rec { 31 pname = "onnx"; 32 version = "1.17.0"; 33 pyproject = true; 34 35 src = fetchFromGitHub { 36 owner = "onnx"; 37 repo = "onnx"; 38 tag = "v${version}"; 39 hash = "sha256-9oORW0YlQ6SphqfbjcYb0dTlHc+1gzy9quH/Lj6By8Q="; 40 }; 41 42 build-system = [ 43 cmake 44 protobuf 45 setuptools 46 ]; 47 48 buildInputs = [ 49 abseil-cpp 50 gtestStatic 51 pybind11 52 ]; 53 54 dependencies = [ 55 protobuf 56 numpy 57 ]; 58 59 nativeCheckInputs = [ 60 google-re2 61 nbval 62 parameterized 63 pillow 64 pytestCheckHook 65 tabulate 66 ]; 67 68 postPatch = '' 69 rm -r third_party 70 71 chmod +x tools/protoc-gen-mypy.sh.in 72 patchShebangs tools/protoc-gen-mypy.sh.in 73 ''; 74 75 preConfigure = '' 76 # Set CMAKE_INSTALL_LIBDIR to lib explicitly, because otherwise it gets set 77 # to lib64 and cmake incorrectly looks for the protobuf library in lib64 78 export CMAKE_ARGS="-DCMAKE_INSTALL_LIBDIR=lib -DONNX_USE_PROTOBUF_SHARED_LIBS=ON" 79 export CMAKE_ARGS+=" -Dgoogletest_STATIC_LIBRARIES=${gtestStatic}/lib/libgtest.a" 80 export ONNX_BUILD_TESTS=1 81 ''; 82 83 preBuild = '' 84 export MAX_JOBS=$NIX_BUILD_CORES 85 ''; 86 87 # The executables are just utility scripts that aren't too important 88 postInstall = '' 89 rm -r $out/bin 90 ''; 91 92 # The setup.py does all the configuration 93 dontUseCmakeConfigure = true; 94 95 preCheck = '' 96 export HOME=$(mktemp -d) 97 98 # detecting source dir as a python package confuses pytest 99 mv onnx/__init__.py onnx/__init__.py.hidden 100 ''; 101 102 pytestFlagsArray = [ 103 "onnx/test" 104 "examples" 105 ]; 106 107 __darwinAllowLocalNetworking = true; 108 109 postCheck = '' 110 # run "cpp" tests 111 .setuptools-cmake-build/onnx_gtests 112 ''; 113 114 pythonImportsCheck = [ "onnx" ]; 115 116 meta = { 117 description = "Open Neural Network Exchange"; 118 homepage = "https://onnx.ai"; 119 changelog = "https://github.com/onnx/onnx/releases/tag/v${version}"; 120 license = lib.licenses.asl20; 121 maintainers = with lib.maintainers; [ acairncross ]; 122 }; 123}