This commit is contained in:
richarjiang
2026-09-24 10:04:41 +08:00
commit eae4df7d51
24 changed files with 2212 additions and 0 deletions

39
install.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Create the runtime venv, then register the launchd service and client hooks.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
HOME_DIR="${LAYA_ROUTER_HOME:-$HOME/.laya-router}"
if [[ "$(uname -s)" != "Darwin" ]]; then
echo "当前安装脚本只支持 macOS(launchd)。" >&2
exit 1
fi
if ! command -v uv >/dev/null 2>&1; then
echo "需要 uv。安装: https://docs.astral.sh/uv/getting-started/installation/" >&2
exit 1
fi
mkdir -p "$HOME_DIR"
if [[ ! -x "$HOME_DIR/.venv/bin/python" ]]; then
created=0
for version in 3.13 3.12 3.11 3.10; do
rm -rf "$HOME_DIR/.venv"
if uv venv "$HOME_DIR/.venv" --python "$version"; then
created=1
break
fi
done
if [[ "$created" -ne 1 ]]; then
echo "需要 Python 3.10 或更高版本。可先执行: uv python install 3.13" >&2
exit 1
fi
fi
# Install a real copy. An editable install points at this repo, which often lives
# under ~/Documents. launchd then blocks forever in open() on that directory.
uv pip install --python "$HOME_DIR/.venv/bin/python" --reinstall-package laya-router "$ROOT"
printf '%s\n' "$ROOT" > "$HOME_DIR/source.path"
exec "$HOME_DIR/.venv/bin/laya-router" install "$@"