File tree Expand file tree Collapse file tree
backend/python/fish-speech Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- .PHONY : fish-speech
2- fish-speech :
1+ .PHONY : fish-speech test-source-preparation
2+ fish-speech : test-source-preparation
33 bash install.sh
44
5+ test-source-preparation :
6+ bash prepare-source_test.sh
7+
58.PHONY : run
69run : fish-speech
710 @echo " Running fish-speech..."
Original file line number Diff line number Diff line change 3939 cd " ${FISH_SPEECH_DIR} " && git pull && cd -
4040fi
4141
42- # Remove pyaudio from fish-speech deps — it's only used by the upstream client tool
43- # (tools/api_client.py) for speaker playback, not by our gRPC backend server.
44- # It requires native portaudio libs which aren't available on all build environments .
45- sed -i.bak ' /"pyaudio"/d ' " ${FISH_SPEECH_DIR} /pyproject.toml"
42+ # Keep the platform-specific PyTorch installed above. Upstream pins the generic
43+ # PyPI torch wheel, which replaces ROCm builds with a CUDA wheel during the
44+ # editable install. pyaudio is only used by the upstream playback client .
45+ bash " ${backend_dir} /prepare-source.sh " " ${BUILD_TYPE :- } " " ${FISH_SPEECH_DIR} /pyproject.toml"
4646
4747# Install fish-speech deps from source (without the package itself since we use PYTHONPATH)
4848ensureVenv
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -euo pipefail
3+
4+ build_type=${1:- }
5+ pyproject=${2:? usage: prepare-source.sh BUILD_TYPE PYPROJECT}
6+ prepared=$( mktemp " ${pyproject} .XXXXXX" )
7+ trap ' rm -f "$prepared"' EXIT
8+
9+ awk -v build_type=" $build_type " '
10+ /^dependencies = \[$/ { in_project_dependencies = 1 }
11+ build_type == "hipblas" && in_project_dependencies && /^[[:space:]]*"(torch|torchaudio)[^"]*",?[[:space:]]*$/ { next }
12+ in_project_dependencies && /^[[:space:]]*"pyaudio",?[[:space:]]*$/ { next }
13+ { print }
14+ in_project_dependencies && /^\]$/ { in_project_dependencies = 0 }
15+ ' " $pyproject " > " $prepared "
16+
17+ mv " $prepared " " $pyproject "
18+ trap - EXIT
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -euo pipefail
3+
4+ SCRIPT_DIR=$( dirname " $( realpath " $0 " ) " )
5+ WORK_DIR=$( mktemp -d)
6+ trap ' rm -rf "$WORK_DIR"' EXIT
7+
8+ write_fixture () {
9+ cat > " $1 " << 'EOF '
10+ [project]
11+ dependencies = [
12+ "numpy",
13+ "torch==2.8.0",
14+ "torchaudio==2.8.0",
15+ "pyaudio",
16+ ]
17+
18+ [project.optional-dependencies]
19+ stable = [
20+ "torch==2.8.0",
21+ "torchaudio",
22+ ]
23+ EOF
24+ }
25+
26+ write_fixture " $WORK_DIR /rocm.toml"
27+ write_fixture " $WORK_DIR /cuda.toml"
28+ write_fixture " $WORK_DIR /cpu.toml"
29+
30+ bash " $SCRIPT_DIR /prepare-source.sh" hipblas " $WORK_DIR /rocm.toml"
31+ bash " $SCRIPT_DIR /prepare-source.sh" cublas " $WORK_DIR /cuda.toml"
32+ bash " $SCRIPT_DIR /prepare-source.sh" " " " $WORK_DIR /cpu.toml"
33+
34+ cat > " $WORK_DIR /expected-rocm.toml" << 'EOF '
35+ [project]
36+ dependencies = [
37+ "numpy",
38+ ]
39+
40+ [project.optional-dependencies]
41+ stable = [
42+ "torch==2.8.0",
43+ "torchaudio",
44+ ]
45+ EOF
46+
47+ cat > " $WORK_DIR /expected-default.toml" << 'EOF '
48+ [project]
49+ dependencies = [
50+ "numpy",
51+ "torch==2.8.0",
52+ "torchaudio==2.8.0",
53+ ]
54+
55+ [project.optional-dependencies]
56+ stable = [
57+ "torch==2.8.0",
58+ "torchaudio",
59+ ]
60+ EOF
61+
62+ diff -u " $WORK_DIR /expected-rocm.toml" " $WORK_DIR /rocm.toml"
63+ diff -u " $WORK_DIR /expected-default.toml" " $WORK_DIR /cuda.toml"
64+ diff -u " $WORK_DIR /expected-default.toml" " $WORK_DIR /cpu.toml"
65+
66+ echo " PASS: source preparation preserves each platform's PyTorch dependencies"
Original file line number Diff line number Diff line change 88 source $backend_dir /../common/libbackend.sh
99fi
1010
11+ bash " ${backend_dir} /prepare-source_test.sh"
1112runUnittests
You can’t perform that action at this time.
0 commit comments