2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
2024-10-11 05:15:48 +00:00
|
|
|
|
|
|
|
# build-system
|
|
|
|
cmake,
|
|
|
|
pybind11,
|
|
|
|
setuptools,
|
|
|
|
|
|
|
|
# nativeBuildInputs
|
|
|
|
protobuf-core,
|
|
|
|
|
|
|
|
# buildInputs
|
|
|
|
abseil-cpp,
|
|
|
|
protobuf,
|
2024-06-05 15:53:02 +00:00
|
|
|
gtest,
|
2024-10-11 05:15:48 +00:00
|
|
|
|
|
|
|
# dependencies
|
2024-06-05 15:53:02 +00:00
|
|
|
numpy,
|
2024-10-11 05:15:48 +00:00
|
|
|
|
|
|
|
google-re2,
|
|
|
|
nbval,
|
2024-06-05 15:53:02 +00:00
|
|
|
parameterized,
|
2024-10-11 05:15:48 +00:00
|
|
|
pillow,
|
2024-06-05 15:53:02 +00:00
|
|
|
pytestCheckHook,
|
|
|
|
tabulate,
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
let
|
|
|
|
gtestStatic = gtest.override { static = true; };
|
2024-06-05 15:53:02 +00:00
|
|
|
in
|
|
|
|
buildPythonPackage rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "onnx";
|
2024-10-11 05:15:48 +00:00
|
|
|
version = "1.17.0";
|
|
|
|
pyproject = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
src = fetchFromGitHub {
|
2024-10-11 05:15:48 +00:00
|
|
|
owner = "onnx";
|
|
|
|
repo = "onnx";
|
2023-02-16 17:41:37 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-10-11 05:15:48 +00:00
|
|
|
hash = "sha256-9oORW0YlQ6SphqfbjcYb0dTlHc+1gzy9quH/Lj6By8Q=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
build-system = [
|
2021-12-06 16:07:01 +00:00
|
|
|
cmake
|
2024-10-11 05:15:48 +00:00
|
|
|
protobuf
|
|
|
|
setuptools
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
protobuf-core # `protoc` required
|
2021-12-06 16:07:01 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
buildInputs = [
|
|
|
|
abseil-cpp
|
2024-07-27 06:49:29 +00:00
|
|
|
gtestStatic
|
2024-10-11 05:15:48 +00:00
|
|
|
pybind11
|
2023-10-09 19:29:22 +00:00
|
|
|
];
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
dependencies = [
|
2020-04-24 23:36:52 +00:00
|
|
|
protobuf
|
|
|
|
numpy
|
2021-04-26 19:14:03 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2024-10-11 05:15:48 +00:00
|
|
|
google-re2
|
2020-04-24 23:36:52 +00:00
|
|
|
nbval
|
2023-05-24 13:37:59 +00:00
|
|
|
parameterized
|
2024-10-11 05:15:48 +00:00
|
|
|
pillow
|
2021-12-06 16:07:01 +00:00
|
|
|
pytestCheckHook
|
2020-04-24 23:36:52 +00:00
|
|
|
tabulate
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2024-10-11 05:15:48 +00:00
|
|
|
rm -r third_party
|
|
|
|
|
2021-03-20 04:20:00 +00:00
|
|
|
chmod +x tools/protoc-gen-mypy.sh.in
|
2023-02-09 11:40:11 +00:00
|
|
|
patchShebangs tools/protoc-gen-mypy.sh.in
|
|
|
|
'';
|
|
|
|
|
|
|
|
preConfigure = ''
|
2023-02-16 17:41:37 +00:00
|
|
|
# Set CMAKE_INSTALL_LIBDIR to lib explicitly, because otherwise it gets set
|
|
|
|
# to lib64 and cmake incorrectly looks for the protobuf library in lib64
|
2023-02-09 11:40:11 +00:00
|
|
|
export CMAKE_ARGS="-DCMAKE_INSTALL_LIBDIR=lib -DONNX_USE_PROTOBUF_SHARED_LIBS=ON"
|
2024-10-11 05:15:48 +00:00
|
|
|
export CMAKE_ARGS+=" -Dgoogletest_STATIC_LIBRARIES=${gtestStatic}/lib/libgtest.a"
|
2023-02-16 17:41:37 +00:00
|
|
|
export ONNX_BUILD_TESTS=1
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
preBuild = ''
|
|
|
|
export MAX_JOBS=$NIX_BUILD_CORES
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# The executables are just utility scripts that aren't too important
|
|
|
|
postInstall = ''
|
|
|
|
rm -r $out/bin
|
|
|
|
'';
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
# The setup.py does all the configuration
|
|
|
|
dontUseCmakeConfigure = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
|
|
|
|
# detecting source dir as a python package confuses pytest
|
|
|
|
mv onnx/__init__.py onnx/__init__.py.hidden
|
|
|
|
'';
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
pytestFlagsArray = [
|
|
|
|
"onnx/test"
|
2024-10-11 05:15:48 +00:00
|
|
|
"examples"
|
2023-02-16 17:41:37 +00:00
|
|
|
];
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
postCheck = ''
|
|
|
|
# run "cpp" tests
|
|
|
|
.setuptools-cmake-build/onnx_gtests
|
|
|
|
'';
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonImportsCheck = [ "onnx" ];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2024-10-11 05:15:48 +00:00
|
|
|
meta = {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Open Neural Network Exchange";
|
2022-01-03 16:56:52 +00:00
|
|
|
homepage = "https://onnx.ai";
|
2024-10-11 05:15:48 +00:00
|
|
|
changelog = "https://github.com/onnx/onnx/releases/tag/${lib.removePrefix "refs/tags/" src.rev}";
|
|
|
|
license = lib.licenses.asl20;
|
|
|
|
maintainers = with lib.maintainers; [ acairncross ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|