#!/bin/bash
set -e

# Build script specifically for Python UniFFI bindings

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
PYTHON_DIR="$PROJECT_ROOT/examples/python"

echo "Building Python UniFFI package for ProofMode..."

# Generate UniFFI bindings first
echo "Generating UniFFI bindings..."
"$SCRIPT_DIR/build_uniffi_bindings.sh"

# Build Python package
echo "Building Python package..."
cd "$PYTHON_DIR"

# Install build dependencies if needed
pip install build wheel

# Build the package
python -m build

echo "Python UniFFI package built successfully!"
echo "Package files:"
ls -la dist/

echo ""
echo "To install locally:"
echo "pip install dist/proofmode-*.whl"
echo ""
echo "To test:"
echo "python -c 'import proofmode; print(proofmode.version())'"