From a271b0b73e47b2ff09422cdb89819f91311d9042 Mon Sep 17 00:00:00 2001 From: localai-org-maint-bot <306269227+localai-org-maint-bot@users.noreply.github.com> Date: Tue, 18 Aug 2026 12:03:40 +0000 Subject: [PATCH] fix(fish-speech): resolve relocated source The editable install records the backend build path, which does not exist after LocalAI relocates the packaged backend. Add the runtime source directory to PYTHONPATH so inference modules remain importable. Assisted-by: Codex:gpt-5 --- backend/python/fish-speech/Makefile | 7 +++++-- backend/python/fish-speech/run.sh | 4 +++- backend/python/fish-speech/run_test.sh | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 backend/python/fish-speech/run_test.sh diff --git a/backend/python/fish-speech/Makefile b/backend/python/fish-speech/Makefile index e5036de89ab5..d855239de83e 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 eae121f37b0b..2c0daf8e962a 100644 --- a/backend/python/fish-speech/run.sh +++ b/backend/python/fish-speech/run.sh @@ -1,9 +1,11 @@ #!/bin/bash -backend_dir=$(dirname $0) +backend_dir=$(dirname "$(realpath "$0")") if [ -d $backend_dir/common ]; then source $backend_dir/common/libbackend.sh else source $backend_dir/../common/libbackend.sh fi +export PYTHONPATH="${backend_dir}/fish-speech-src${PYTHONPATH:+:${PYTHONPATH}}" + startBackend $@ diff --git a/backend/python/fish-speech/run_test.sh b/backend/python/fish-speech/run_test.sh new file mode 100644 index 000000000000..bd45f063591c --- /dev/null +++ b/backend/python/fish-speech/run_test.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -euo pipefail + +SCRIPT_DIR=$(dirname "$(realpath "$0")") +WORK_DIR=$(mktemp -d) +trap 'rm -rf "$WORK_DIR"' EXIT + +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_DIR/runtime/fish-speech-src/fish_speech/inference_engine.py" <<'PY' +IMPORT_OK = True +PY + +cat > "$WORK_DIR/runtime/common/libbackend.sh" <<'SH' +startBackend() { + python3 -c 'from fish_speech.inference_engine import IMPORT_OK; assert IMPORT_OK' +} +SH + +bash "$WORK_DIR/runtime/run.sh" + +echo "PASS: runtime launcher imports relocated fish-speech source"