39 lines
908 B
Bash
Executable File
39 lines
908 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
candidates=(
|
|
"${PYTHON:-}"
|
|
"/usr/local/bin/python3"
|
|
"/Library/Frameworks/Python.framework/Versions/Current/bin/python3"
|
|
"/Library/Frameworks/Python.framework/Versions/3.13/bin/python3"
|
|
"/Library/Frameworks/Python.framework/Versions/3.12/bin/python3"
|
|
"/usr/bin/python3"
|
|
"/opt/homebrew/bin/python3"
|
|
"python3"
|
|
)
|
|
|
|
seen=""
|
|
for py in "${candidates[@]}"; do
|
|
[[ -n "$py" ]] || continue
|
|
if [[ "$py" != /* ]]; then
|
|
resolved="$(command -v "$py" 2>/dev/null || true)"
|
|
else
|
|
resolved="$py"
|
|
fi
|
|
[[ -x "$resolved" ]] || continue
|
|
case ":$seen:" in
|
|
*":$resolved:"*) continue ;;
|
|
esac
|
|
seen="$seen:$resolved"
|
|
if "$resolved" - <<'PY' >/dev/null 2>&1
|
|
import tkinter
|
|
PY
|
|
then
|
|
printf '%s\n' "$resolved"
|
|
exit 0
|
|
fi
|
|
done
|
|
|
|
echo "No Python with tkinter support found. Install Python from python.org or a Tk-enabled Python runtime." >&2
|
|
exit 1
|