first commit
This commit is contained in:
38
scripts/find_tk_python.sh
Executable file
38
scripts/find_tk_python.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user