2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
2023-02-16 17:41:37 +00:00
|
|
|
, python3
|
2022-04-27 09:35:20 +00:00
|
|
|
, bash
|
2021-12-06 16:07:01 +00:00
|
|
|
, cmake
|
2023-02-16 17:41:37 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, gtest
|
2020-04-24 23:36:52 +00:00
|
|
|
, isPy27
|
2021-12-06 16:07:01 +00:00
|
|
|
, nbval
|
2020-04-24 23:36:52 +00:00
|
|
|
, numpy
|
2021-12-06 16:07:01 +00:00
|
|
|
, protobuf
|
2023-02-16 17:41:37 +00:00
|
|
|
, pybind11
|
2021-04-26 19:14:03 +00:00
|
|
|
, pytestCheckHook
|
2021-12-06 16:07:01 +00:00
|
|
|
, six
|
2020-04-24 23:36:52 +00:00
|
|
|
, tabulate
|
2021-12-06 16:07:01 +00:00
|
|
|
, typing-extensions
|
2022-10-30 15:09:59 +00:00
|
|
|
, pythonRelaxDepsHook
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
let
|
|
|
|
gtestStatic = gtest.override { static = true; };
|
|
|
|
in buildPythonPackage rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "onnx";
|
2023-03-04 12:14:45 +00:00
|
|
|
version = "1.13.1";
|
2021-12-06 16:07:01 +00:00
|
|
|
format = "setuptools";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
disabled = isPy27;
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
|
|
|
rev = "refs/tags/v${version}";
|
2023-03-15 16:39:30 +00:00
|
|
|
hash = "sha256-10MH23XpAv/uDW/2tRFGS2lKU8hnaNBwbIBIgVc7Jpk=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
2022-10-30 15:09:59 +00:00
|
|
|
pythonRelaxDepsHook
|
2023-02-16 17:41:37 +00:00
|
|
|
pybind11
|
2021-12-06 16:07:01 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
pythonRelaxDeps = [ "protobuf" ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
protobuf
|
|
|
|
numpy
|
|
|
|
six
|
|
|
|
typing-extensions
|
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 = [
|
2020-04-24 23:36:52 +00:00
|
|
|
nbval
|
2021-12-06 16:07:01 +00:00
|
|
|
pytestCheckHook
|
2020-04-24 23:36:52 +00:00
|
|
|
tabulate
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
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
|
2023-02-16 17:41:37 +00:00
|
|
|
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace 'setup_requires.append("pytest-runner")' ""
|
|
|
|
|
|
|
|
# prevent from fetching & building own gtest
|
|
|
|
substituteInPlace CMakeLists.txt \
|
|
|
|
--replace 'include(googletest)' ""
|
|
|
|
substituteInPlace cmake/unittest.cmake \
|
|
|
|
--replace 'googletest)' ')'
|
2023-02-09 11:40:11 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
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"
|
2023-02-16 17:41:37 +00:00
|
|
|
'' + lib.optionalString doCheck ''
|
|
|
|
export CMAKE_ARGS+=" -Dgoogletest_STATIC_LIBRARIES=${gtestStatic}/lib/libgtest.a -Dgoogletest_INCLUDE_DIRS=${lib.getDev gtestStatic}/include"
|
|
|
|
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
|
|
|
doCheck = true;
|
|
|
|
preCheck = ''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
|
|
|
|
# detecting source dir as a python package confuses pytest
|
|
|
|
mv onnx/__init__.py onnx/__init__.py.hidden
|
|
|
|
'';
|
|
|
|
pytestFlagsArray = [ "onnx/test" "onnx/examples" ];
|
|
|
|
disabledTests = [
|
|
|
|
# attempts to fetch data from web
|
|
|
|
"test_bvlc_alexnet_cpu"
|
|
|
|
"test_densenet121_cpu"
|
|
|
|
"test_inception_v1_cpu"
|
|
|
|
"test_inception_v2_cpu"
|
|
|
|
"test_resnet50_cpu"
|
|
|
|
"test_shufflenet_cpu"
|
|
|
|
"test_squeezenet_cpu"
|
|
|
|
"test_vgg19_cpu"
|
|
|
|
"test_zfnet512_cpu"
|
|
|
|
];
|
|
|
|
disabledTestPaths = [
|
|
|
|
# Unexpected output fields from running code: {'stderr'}
|
|
|
|
"onnx/examples/np_array_tensorproto.ipynb"
|
|
|
|
];
|
|
|
|
postCheck = ''
|
|
|
|
# run "cpp" tests
|
|
|
|
.setuptools-cmake-build/onnx_gtests
|
|
|
|
'';
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"onnx"
|
|
|
|
];
|
|
|
|
|
|
|
|
meta = with lib; {
|
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";
|
2021-12-06 16:07:01 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ acairncross ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|