forked from LvcidPsyche/auto-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_env.sh
More file actions
executable file
·58 lines (48 loc) · 1.21 KB
/
Copy pathpython_env.sh
File metadata and controls
executable file
·58 lines (48 loc) · 1.21 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
resolve_python310_bin() {
local candidate
local -a candidates=()
if [[ -n "${AUTO_BROWSER_PYTHON_BIN:-}" ]]; then
candidates+=("${AUTO_BROWSER_PYTHON_BIN}")
fi
candidates+=(python3 python3.11)
for candidate in "${candidates[@]}"; do
[[ -n "${candidate}" ]] || continue
if ! command -v "${candidate}" >/dev/null 2>&1; then
continue
fi
if "${candidate}" - <<'PY' >/dev/null 2>&1
import sys
raise SystemExit(0 if sys.version_info >= (3, 10) else 1)
PY
then
printf '%s\n' "${candidate}"
return 0
fi
done
return 1
}
require_python310_bin() {
local python_bin=""
local detected_version=""
if python_bin="$(resolve_python310_bin)"; then
printf '%s\n' "${python_bin}"
return 0
fi
if command -v python3 >/dev/null 2>&1; then
detected_version="$(python3 - <<'PY'
import sys
print(sys.version.split()[0])
PY
)"
else
detected_version="python3 not found"
fi
cat >&2 <<EOF
Python 3.10+ is required for local auto-browser developer scripts.
Detected: ${detected_version}
Install Python 3.10+ or set AUTO_BROWSER_PYTHON_BIN to a compatible interpreter.
If you only need the containerized path, use \`make test\`.
EOF
exit 1
}