#!/bin/sh
set -eu

# Use the system installed python3
PYTHONBIN="$( command -v python3 || command -v python || echo '' )"
if [ -z "$PYTHONBIN"  ]; then
    echo "Please install Python 3"
    exit 1
fi

# Check if python version is 3
PYTHONVERSION="$( "$PYTHONBIN" --version 2>&1 )"
case "$PYTHONVERSION" in
  "Python 3"*) ;;
  *) echo "Please install Python 3" && exit 1 ;;
esac

# Execute the "python" runtime bootstrap
export LAMBDA_RUNTIME_DIR="$(dirname "$0")/../python"
exec "$PYTHONBIN" "$LAMBDA_RUNTIME_DIR/bootstrap.py" "$@"
