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
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto committed 2026-09-11 21:55:10 +00:00
1 parent f5eb09f329
commit cce7a9e441
3 files changed
+21 -22

No files matched your search

+5 -2
View File
@@ -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..."
+2 -2
View File
@@ -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
+14 -18
View File
@@ -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"