|
3 | 3 | echo "Sourcing get-kernel-check-hook.sh" |
4 | 4 |
|
5 | 5 | _getKernelCheckHook() { |
6 | | - if [ ! -z "${getKernelCheck}" ]; then |
7 | | - echo "Checking loading kernel with get_kernel" |
8 | | - echo "Check whether the kernel can be loaded with get-kernel: ${getKernelCheck}" |
9 | | - |
10 | | - # We strip the full library paths from the extension. Unfortunately, |
11 | | - # in a Nix environment, the library dependencies cannot be found |
12 | | - # anymore. So we have to add the Torch library directory to the |
13 | | - # dynamic linker path to get it to pick it up. |
14 | | - if [ $(uname -s) == "Darwin" ]; then |
15 | | - TORCH_DIR=$(python -c "from pathlib import Path; import torch; print(Path(torch.__file__).parent)") |
16 | | - export DYLD_LIBRARY_PATH="${TORCH_DIR}/lib:${DYLD_LIBRARY_PATH}" |
17 | | - fi |
18 | | - |
19 | | - TMPDIR=$(mktemp -d -t test.XXXXXX) || exit 1 |
20 | | - trap "rm -rf '$TMPDIR'" EXIT |
21 | | - |
22 | | - # Some kernels want to write stuff (especially when they use Triton). |
23 | | - HOME=$(mktemp -d -t test.XXXXXX) || exit 1 |
24 | | - trap "rm -rf '$HOME'" EXIT |
25 | | - |
26 | | - # Emulate the bundle layout that kernels expects. This even works |
27 | | - # for universal kernels, since kernels checks the non-universal |
28 | | - # path first. |
29 | | - BUILD_VARIANT=$(python -c "from kernels.utils import build_variant; print(build_variant())") |
30 | | - mkdir -p "${TMPDIR}/build" |
31 | | - ln -s "$out" "${TMPDIR}/build/${BUILD_VARIANT}" |
32 | | - |
33 | | - python -c "from pathlib import Path; import kernels; kernels.get_local_kernel(Path('${TMPDIR}'), '${getKernelCheck}')" |
| 6 | + echo "Checking loading kernel with get_kernel" |
| 7 | + |
| 8 | + if [ -z ${extensionName+x} ]; then |
| 9 | + echo "extensionName must be set in derivation" |
| 10 | + exit 1 |
| 11 | + fi |
| 12 | + |
| 13 | + echo "Check whether the kernel can be loaded with get-kernel: ${extensionName}" |
| 14 | + |
| 15 | + # We strip the full library paths from the extension. Unfortunately, |
| 16 | + # in a Nix environment, the library dependencies cannot be found |
| 17 | + # anymore. So we have to add the Torch library directory to the |
| 18 | + # dynamic linker path to get it to pick it up. |
| 19 | + if [ $(uname -s) == "Darwin" ]; then |
| 20 | + TORCH_DIR=$(python -c "from pathlib import Path; import torch; print(Path(torch.__file__).parent)") |
| 21 | + export DYLD_LIBRARY_PATH="${TORCH_DIR}/lib:${DYLD_LIBRARY_PATH}" |
34 | 22 | fi |
| 23 | + |
| 24 | + TMPDIR=$(mktemp -d -t test.XXXXXX) || exit 1 |
| 25 | + trap "rm -rf '$TMPDIR'" EXIT |
| 26 | + |
| 27 | + # Some kernels want to write stuff (especially when they use Triton). |
| 28 | + HOME=$(mktemp -d -t test.XXXXXX) || exit 1 |
| 29 | + trap "rm -rf '$HOME'" EXIT |
| 30 | + |
| 31 | + # Emulate the bundle layout that kernels expects. This even works |
| 32 | + # for universal kernels, since kernels checks the non-universal |
| 33 | + # path first. |
| 34 | + BUILD_VARIANT=$(python -c "from kernels.utils import build_variant; print(build_variant())") |
| 35 | + mkdir -p "${TMPDIR}/build" |
| 36 | + ln -s "$out" "${TMPDIR}/build/${BUILD_VARIANT}" |
| 37 | + |
| 38 | + python -c "from pathlib import Path; import kernels; kernels.get_local_kernel(Path('${TMPDIR}'), '${extensionName}')" |
35 | 39 | } |
36 | 40 |
|
37 | 41 | postInstallCheckHooks+=(_getKernelCheckHook) |
0 commit comments