Files
nixpkgs/pkgs/development/python-modules/onnxruntime/default.nix
T
Peder Bergebakken Sundt 5aba99242e treewide: fix typos in comments
Made with

```shell
git restore .
fd '\.nix$' pkgs/ --type f -j1 -x bash -xc "$(cat <<"EOF"
    typos --no-check-filenames --write-changes "$1"
    git diff --exit-code "$1" && exit
    #( git diff "$1" | grep -qE "^\+ +[^# ]") && git restore "$1"
    count1="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> ' | wc -l )"
    count2="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> (<span style="color:#f8f8f2;"> *</span>)?<span style="color:#75715e;">.*</span>$' | wc -l )"
    [[ $count1 -ne $count2 ]] && git restore "$1"
EOF
)" -- {}
```

and filtered with `GIT_DIFF_OPTS='--unified=15' git -c interactive.singleKey=true add --patch`

I initially tried using the tree-sitter cli, python bindings and even ast-grep through various means, but this is what I ended up with.
2025-02-24 10:44:41 +01:00

84 lines
2.2 KiB
Nix

{
lib,
stdenv,
buildPythonPackage,
autoPatchelfHook,
onnxruntime,
coloredlogs,
numpy,
packaging,
oneDNN,
re2,
}:
# onnxruntime requires an older protobuf.
# Doing an override in protobuf in the python-packages set
# can give you a functioning Python package but note not
# all Python packages will be compatible then.
#
# Because protobuf is not always needed we remove it
# as a runtime dependency from our wheel.
#
# We do include here the non-Python protobuf so the shared libs
# link correctly. If you do also want to include the Python
# protobuf, you can add it to your Python env, but be aware
# the version likely mismatches with what is used here.
buildPythonPackage {
inherit (onnxruntime) pname version;
format = "wheel";
src = onnxruntime.dist;
unpackPhase = ''
cp -r $src dist
chmod +w dist
'';
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
# This project requires fairly large dependencies such as sympy which we really don't always need.
pythonRemoveDeps = [
"flatbuffers"
"protobuf"
"sympy"
];
# Libraries are not linked correctly.
buildInputs =
[
oneDNN
re2
onnxruntime.protobuf
# https://github.com/NixOS/nixpkgs/pull/357656 patches the onnx lib to ${pkgs.onnxruntime}/lib
# but these files are copied into this package too. If the original non-python onnxruntime
# package is GC-ed, cuda support in this python package will break.
# Two options, rebuild onnxruntime twice with the different paths hard-coded, or just hold a runtime
# dependency between the two. Option 2, because onnxruntime takes forever to build with cuda support.
onnxruntime
]
++ lib.optionals onnxruntime.passthru.cudaSupport (
with onnxruntime.passthru.cudaPackages;
[
libcublas # libcublasLt.so.XX libcublas.so.XX
libcurand # libcurand.so.XX
libcufft # libcufft.so.XX
cudnn # libcudnn.soXX
cuda_cudart # libcudart.so.XX
nccl # libnccl.so.XX
]
);
propagatedBuildInputs = [
coloredlogs
# flatbuffers
numpy
packaging
# protobuf
# sympy
];
meta = onnxruntime.meta;
}