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"