-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-launcher
More file actions
33 lines (27 loc) · 939 Bytes
/
Copy pathpython-launcher
File metadata and controls
33 lines (27 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
set -euo pipefail
APP_DIR="$(cd "$(dirname "$0")" && pwd)"
CACHE="$APP_DIR/.python-path"
PYTHON=""
if [[ -r "$CACHE" ]]; then
IFS= read -r candidate < "$CACHE" || true
if [[ -x "$candidate" ]] &&
"$candidate" -c 'import tkinter' >/dev/null 2>&1; then
PYTHON="$candidate"
fi
fi
if [[ -z "$PYTHON" ]]; then
for candidate in /opt/local/bin/python3.15 /opt/local/bin/python3.14 /opt/local/bin/python3.13 /opt/local/bin/python3.12 /opt/local/bin/python3.11 /usr/local/bin/python3 /opt/homebrew/bin/python3 /opt/local/bin/python /usr/bin/python3; do
if [[ -x "$candidate" ]] &&
"$candidate" -c 'import tkinter' >/dev/null 2>&1; then
PYTHON="$candidate"
printf '%s\n' "$PYTHON" > "$CACHE"
break
fi
done
fi
if [[ -z "$PYTHON" ]]; then
echo "No Python installation with tkinter was found." >&2
exit 1
fi
exec "$PYTHON" "$@"