#!/usr/bin/env bash
set -euo pipefail

PYTHON_BIN="${PYTHON_BIN:-python3}"
export PYTHON_BIN

if [ -n "${CI_PYTHONS:-}" ]; then
  qt_smoke_python=""
  for py in ${CI_PYTHONS}; do
    PYTHON_BIN="$py" scripts/ci/check
    if [ -z "$qt_smoke_python" ]; then
      qt_smoke_python="$py"
    fi
  done
  PYTHON_BIN="$qt_smoke_python"
else
  scripts/ci/check
fi

if "$PYTHON_BIN" - <<'PY' >/dev/null 2>&1
from PyQt6.QtWidgets import QApplication
app = QApplication([])
app.quit()
PY
then
  echo "Qt smoke OK"
else
  echo "Qt smoke skipped or unavailable on this host"
fi
