Files
mt5-quant/scripts/build-executable.sh
T
Devid HW 3cfd374160 Add PyInstaller build support for deployment
- Add PyInstaller spec files (onefile and onedir modes)
- Add build scripts for executable creation
- Add MCP hooks for PyInstaller compatibility
- Add test script for MCP server validation
- Add Windsurf integration setup guide
- Update main.py with better error reporting
- Successfully tested MCP server works with ONEDIR build (45MB)

Features:
- Single executable deployment without Python dependency
- ONEDIR mode preserves stdio communication for MCP
- Build scripts with deployment instructions
- Windsurf config integration guide

Files added:
- mt5-quant.spec (PyInstaller spec)
- mt5-quant-onedir.spec (directory mode)
- scripts/build-executable.sh (onefile)
- scripts/build-executable-onedir.sh (directory)
- hooks/hook-mcp.py (PyInstaller hook)
- test_mcp.py (validation script)
- WINDSURF_SETUP.md (integration guide)
2026-04-18 13:00:28 +07:00

84 lines
2.3 KiB
Bash

#!/bin/bash
# Build MT5-Quant as a single executable using PyInstaller
# Output: dist/mt5-quant
set -e
# Get script directory and project root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
cd "$PROJECT_ROOT"
echo "=== MT5-Quant PyInstaller Build ==="
echo "Project root: $PROJECT_ROOT"
echo ""
# Determine Python interpreter
if [ -f "$PROJECT_ROOT/.venv/bin/python3" ]; then
PYTHON="$PROJECT_ROOT/.venv/bin/python3"
elif [ -f "$PROJECT_ROOT/.venv/bin/python" ]; then
PYTHON="$PROJECT_ROOT/.venv/bin/python"
else
PYTHON="python3"
fi
echo "Using Python: $PYTHON"
echo ""
# Ensure dependencies are installed
echo "Installing dependencies..."
$PYTHON -m pip install pyinstaller mcp pyyaml --quiet
# Clean previous builds
echo "Cleaning previous builds..."
rm -rf "$PROJECT_ROOT/build" "$PROJECT_ROOT/dist"
# Build the executable
echo "Building executable (this may take 1-2 minutes)..."
cd "$PROJECT_ROOT"
$PYTHON -m PyInstaller \
--clean \
--noconfirm \
--distpath "$PROJECT_ROOT/dist" \
--workpath "$PROJECT_ROOT/build" \
"$PROJECT_ROOT/mt5-quant.spec"
# Report results
echo ""
echo "=== Build Complete ==="
echo ""
echo "Executable location:"
ls -lh dist/mt5-quant
echo ""
echo "Size breakdown:"
du -sh dist/ 2>/dev/null || echo " dist/: $(du -sh dist/mt5-quant 2>/dev/null | cut -f1)"
echo ""
echo "To test:"
echo " ./dist/mt5-quant --help"
echo ""
echo "To register with Claude Code:"
echo " claude mcp add MT5-Quant -- $(pwd)/dist/mt5-quant"
echo ""
echo "=== Deployment to Multiple Machines ==="
echo ""
echo "1. Copy this single binary to target machines:"
echo " scp dist/mt5-quant user@server:/usr/local/bin/"
echo " ssh user@server chmod +x /usr/local/bin/mt5-quant"
echo ""
echo "2. Copy config directory (includes mt5-quant.yaml):"
echo " scp -r config/ user@server:~/.config/mt5-quant/"
echo ""
echo "3. Or use bundled config (minimal):"
echo " MT5_MCP_HOME=/path/to/config ./mt5-quant"
echo ""
echo "4. Register on target machine:"
echo " claude mcp add MT5-Quant -- /usr/local/bin/mt5-quant"
echo ""
echo "Requirements on target machine:"
echo " - MetaTrader 5 installed (via Wine on macOS/Linux)"
echo " - Config file at ~/.config/mt5-quant/config/mt5-quant.yaml"
echo " - NO Python installation required!"