mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-28 10:27:30 -04:00
On darwin arm64 the fish-speech editable install (pip install
--no-build-isolation -e) compiles the transitive `tokenizers` Python
package's Rust extension from source, because there is no prebuilt
manylinux wheel for that platform (Linux builds never compile it, so this
only breaks on macOS). The pinned tokenizers crate fish-speech's stack
resolves to contains a `&T` -> `&mut T` cast that the macOS CI runner's
newer Rust toolchain rejects via the now-deny-by-default
`invalid_reference_casting` lint:
error: casting `&T` to `&mut T` is undefined behavior ...
error: could not compile `tokenizers` (lib) due to 1 previous error
ERROR: Failed building wheel for tokenizers
This failed the fish-speech darwin/metal (mps) backend image build in the
v4.5.5 release CI while all Linux variants built fine.
Fix: export RUSTFLAGS with `-A invalid_reference_casting` (appended to any
existing value, not clobbering) before installRequirements so the
unchanged third-party crate compiles as it did under the older toolchain.
Version-agnostic and harmless on Linux, where no Rust compile happens.
Assisted-by: Claude:claude-opus-4-8 [Claude Code]
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
63 lines
2.4 KiB
Bash
63 lines
2.4 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
EXTRA_PIP_INSTALL_FLAGS="--no-build-isolation"
|
|
|
|
backend_dir=$(dirname $0)
|
|
if [ -d $backend_dir/common ]; then
|
|
source $backend_dir/common/libbackend.sh
|
|
else
|
|
source $backend_dir/../common/libbackend.sh
|
|
fi
|
|
|
|
# fish-speech uses pyrootutils which requires a .project-root marker
|
|
touch "${backend_dir}/.project-root"
|
|
|
|
# On darwin arm64 the transitive `tokenizers` dep compiles its Rust extension
|
|
# from source (Linux uses prebuilt manylinux wheels, so it never compiles
|
|
# there). The pinned tokenizers crate that fish-speech's stack resolves to
|
|
# contains a `&T` -> `&mut T` cast that trips the now-deny-by-default
|
|
# `invalid_reference_casting` lint in the macOS runner's newer Rust toolchain,
|
|
# breaking the build (seen in the v4.5.5 release CI fish-speech darwin/metal
|
|
# job). Allow that lint so the unchanged third-party crate compiles as before.
|
|
# Append rather than clobber any pre-existing RUSTFLAGS; harmless on Linux
|
|
# where no Rust compile happens.
|
|
export RUSTFLAGS="${RUSTFLAGS:-} -A invalid_reference_casting"
|
|
|
|
installRequirements
|
|
|
|
# Clone fish-speech source (the pip package doesn't include inference modules)
|
|
FISH_SPEECH_DIR="${EDIR}/fish-speech-src"
|
|
FISH_SPEECH_REPO="https://github.com/fishaudio/fish-speech.git"
|
|
FISH_SPEECH_BRANCH="main"
|
|
|
|
if [ ! -d "${FISH_SPEECH_DIR}" ]; then
|
|
echo "Cloning fish-speech source..."
|
|
git clone --depth 1 --branch "${FISH_SPEECH_BRANCH}" "${FISH_SPEECH_REPO}" "${FISH_SPEECH_DIR}"
|
|
else
|
|
echo "Updating fish-speech source..."
|
|
cd "${FISH_SPEECH_DIR}" && git pull && cd -
|
|
fi
|
|
|
|
# Remove pyaudio from fish-speech deps — it's only used by the upstream client tool
|
|
# (tools/api_client.py) for speaker playback, not by our gRPC backend server.
|
|
# It requires native portaudio libs which aren't available on all build environments.
|
|
sed -i.bak '/"pyaudio"/d' "${FISH_SPEECH_DIR}/pyproject.toml"
|
|
|
|
# Install fish-speech deps from source (without the package itself since we use PYTHONPATH)
|
|
ensureVenv
|
|
if [ "x${USE_PIP}" == "xtrue" ]; then
|
|
pip install ${EXTRA_PIP_INSTALL_FLAGS:-} -e "${FISH_SPEECH_DIR}"
|
|
else
|
|
uv pip install ${EXTRA_PIP_INSTALL_FLAGS:-} -e "${FISH_SPEECH_DIR}"
|
|
fi
|
|
|
|
# fish-speech transitive deps (wandb, tensorboard) may downgrade protobuf to 3.x
|
|
# but our generated backend_pb2.py requires protobuf 5+
|
|
ensureVenv
|
|
if [ "x${USE_PIP}" == "xtrue" ]; then
|
|
pip install "protobuf>=5.29.0"
|
|
else
|
|
uv pip install "protobuf>=5.29.0"
|
|
fi
|