Files
imagefind/scripts/prepare-fnos-dependencies.sh
T

30 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
PYTHON_BIN=${PYTHON:-python3}
WHEELHOUSE=${IMAGEFIND_WHEEL_CACHE:-$ROOT_DIR/.fnos-wheel-cache/python312}
DOWNLOAD_ROOT=${IMAGEFIND_DEPENDENCY_TMPDIR:-${TMPDIR:-/tmp}}
OPENCL_URL=https://deb.debian.org/debian/pool/main/o/ocl-icd/ocl-icd-libopencl1_2.2.14-2_amd64.deb
OPENCL_SHA256=f3367b78f2548e6211e23081b3e0f144babfcc906c5bdbbe0d5e41915de70128
command -v "$PYTHON_BIN" >/dev/null
for command_name in curl dpkg-deb find install sha256sum; do command -v "$command_name" >/dev/null; done
mkdir -p "$WHEELHOUSE" "$ROOT_DIR/vendor" "$DOWNLOAD_ROOT"
"$PYTHON_BIN" -m pip download --disable-pip-version-check --only-binary=:all: \
--implementation cp --python-version 312 --abi cp312 \
--platform manylinux_2_28_x86_64 --platform manylinux_2_27_x86_64 \
--platform manylinux2014_x86_64 --platform manylinux2010_x86_64 --platform manylinux1_x86_64 \
--dest "$WHEELHOUSE" --requirement "$ROOT_DIR/requirements/runtime-core.txt"
work_dir=$(mktemp -d "${DOWNLOAD_ROOT%/}/imagefind-opencl.XXXXXX")
trap 'rm -rf -- "$work_dir"' EXIT
curl --fail --location --retry 4 --retry-all-errors "$OPENCL_URL" --output "$work_dir/opencl.deb"
dpkg-deb -x "$work_dir/opencl.deb" "$work_dir/root"
source_file=$(find "$work_dir/root" -type f -name 'libOpenCL.so.1.*' -print -quit)
test -n "$source_file"
printf '%s %s\n' "$OPENCL_SHA256" "$source_file" | sha256sum --check --status
install -m 0644 "$source_file" "$ROOT_DIR/vendor/libOpenCL.so.1"
printf 'Prepared %s and %s\n' "$WHEELHOUSE" "$ROOT_DIR/vendor/libOpenCL.so.1"