diff --git a/backend/python/fish-speech/Makefile b/backend/python/fish-speech/Makefile index a4033f105..53721204e 100644 --- a/backend/python/fish-speech/Makefile +++ b/backend/python/fish-speech/Makefile @@ -1,10 +1,13 @@ -.PHONY: fish-speech test-source-preparation -fish-speech: test-source-preparation +.PHONY: fish-speech test-source-preparation test-runtime-import +fish-speech: test-source-preparation test-runtime-import bash install.sh test-source-preparation: bash prepare-source_test.sh +test-runtime-import: + bash run_test.sh + .PHONY: run run: fish-speech @echo "Running fish-speech..." diff --git a/backend/python/fish-speech/run.sh b/backend/python/fish-speech/run.sh index db6656e18..58960297e 100644 --- a/backend/python/fish-speech/run.sh +++ b/backend/python/fish-speech/run.sh @@ -1,5 +1,5 @@ #!/bin/bash -backend_dir=$(dirname $0) +backend_dir=$(dirname "$(realpath "$0")") if [ -d $backend_dir/common ]; then source $backend_dir/common/libbackend.sh else @@ -8,7 +8,7 @@ fi # Editable installs record their build-time absolute source path, which becomes # stale when the backend is relocated under /backends at install time. -export PYTHONPATH="${EDIR}/fish-speech-src${PYTHONPATH:+:${PYTHONPATH}}" +export PYTHONPATH="${backend_dir}/fish-speech-src${PYTHONPATH:+:${PYTHONPATH}}" cuda_home=${CUDA_HOME:-/usr/local/cuda} if [ -z "${TRITON_PTXAS_PATH:-}" ] && [ -x "$cuda_home/bin/ptxas" ]; then diff --git a/backend/python/fish-speech/run_test.sh b/backend/python/fish-speech/run_test.sh index 65affb91f..bd45f0635 100644 --- a/backend/python/fish-speech/run_test.sh +++ b/backend/python/fish-speech/run_test.sh @@ -1,27 +1,23 @@ #!/bin/bash -# SPDX-License-Identifier: MIT set -euo pipefail -backend_dir=$(cd "$(dirname "$0")" && pwd) -work=$(mktemp -d) -trap 'rm -rf "$work"' EXIT +SCRIPT_DIR=$(dirname "$(realpath "$0")") +WORK_DIR=$(mktemp -d) +trap 'rm -rf "$WORK_DIR"' EXIT -mkdir -p "$work/backend/common" "$work/backend/fish-speech-src" -cp "$backend_dir/run.sh" "$work/backend/run.sh" +mkdir -p "$WORK_DIR/runtime/common" "$WORK_DIR/runtime/fish-speech-src/fish_speech" +cp "$SCRIPT_DIR/run.sh" "$WORK_DIR/runtime/run.sh" -cat > "$work/backend/common/libbackend.sh" <<'EOF' -EDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +cat > "$WORK_DIR/runtime/fish-speech-src/fish_speech/inference_engine.py" <<'PY' +IMPORT_OK = True +PY + +cat > "$WORK_DIR/runtime/common/libbackend.sh" <<'SH' startBackend() { - printf '%s\n' "$PYTHONPATH" + python3 -c 'from fish_speech.inference_engine import IMPORT_OK; assert IMPORT_OK' } -EOF +SH -actual=$(PYTHONPATH=/existing/path bash "$work/backend/run.sh") -expected="$work/backend/fish-speech-src:/existing/path" +bash "$WORK_DIR/runtime/run.sh" -if [ "$actual" != "$expected" ]; then - printf 'expected PYTHONPATH %s, got %s\n' "$expected" "$actual" >&2 - exit 1 -fi - -echo "PASS: relocated fish-speech source is importable" +echo "PASS: runtime launcher imports relocated fish-speech source"