DenseFeed / scripts /setup-gradio-local
j14i's picture
chore: add local gradio submodule and setup script
65a4727
Raw
History Blame Contribute Delete
1.58 kB
#!/usr/bin/env bash
set -euo pipefail
# Setup local gradio build from submodule for unpublished features.
# Run once after cloning or when you need to rebuild.
cd "$(dirname "$0")/.."
ROOT="$(pwd)"
GRADIO_DIR="$ROOT/gradio"
# --- 1. Add submodule if missing ---
if [ ! -d "$GRADIO_DIR/.git" ]; then
echo "==> Adding gradio submodule..."
git submodule add --force https://github.com/gradio-app/gradio gradio
fi
echo "==> Updating submodule..."
git submodule update --init --force gradio
cd "$GRADIO_DIR"
# --- 2. Install Python packages in editable mode ---
echo "==> Installing gradio (editable)..."
uv pip install -e .
echo "==> Installing gradio-client (editable)..."
uv pip install -e client/python
# --- 3. Generate theme ---
echo "==> Generating theme..."
uv run python scripts/generate_theme.py
# --- 4. Install frontend deps + build ---
if ! command -v pnpm &>/dev/null; then
echo "==> Installing pnpm..."
npm install -g pnpm
fi
echo "==> Installing frontend dependencies..."
export NODE_OPTIONS="--max-old-space-size=8192"
pnpm i --frozen-lockfile --ignore-scripts
echo "==> Building frontend..."
pnpm build
# --- 5. Download offline assets ---
echo "==> Downloading offline assets..."
uv run python scripts/download_offline_assets.py
echo ""
echo "✅ Gradio local build complete!"
echo " Source: $GRADIO_DIR"
echo " Version: $(grep '"version"' gradio/package.json | head -1 | sed 's/.*: "//;s/".*//')"
echo ""
echo " pyproject.toml should have:"
echo ' [tool.uv.sources]'
echo ' gradio = { path = "./gradio", editable = true }'