#!/usr/bin/env python3
"""
Build script for Amicus MCP packaged executable using PyInstaller.
"""
import os
import subprocess
import sys
import shutil
from pathlib import Path
def build():
print("๐ Starting Amicus MCP binary build...")
# Check for PyInstaller
try:
import PyInstaller
except ImportError:
print("โ PyInstaller not found. Installing...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "pyinstaller"])
# Resolve paths
root_dir = Path(__file__).parent.parent
server_script = root_dir / "server.py"
dist_dir = root_dir / "dist"
build_dir = root_dir / "build"
# Clean previous builds
if dist_dir.exists():
print("๐งน Cleaning dist/...")
shutil.rmtree(dist_dir)
if build_dir.exists():
print("๐งน Cleaning build/...")
shutil.rmtree(build_dir)
# PyInstaller command
cmd = [
"pyinstaller",
"--onefile",
"--name", "amicus-mcp",
"--add-data", f"prompts{os.pathsep}prompts",
str(server_script)
]
print(f"๐ฆ Running: {' '.join(cmd)}")
try:
subprocess.check_call(cmd)
print("\nโ
Build successful!")
binary_path = dist_dir / ("amicus-mcp.exe" if os.name == "nt" else "amicus-mcp")
print(f"๐ Binary location: {binary_path}")
print("\nTo use the binary, point your MCP client to this path.")
except subprocess.CalledProcessError as e:
print(f"โ Build failed: {e}")
sys.exit(1)
if __name__ == "__main__":
build()