-
Notifications
You must be signed in to change notification settings - Fork 324
Expand file tree
/
Copy pathlaunch.sh
More file actions
executable file
·56 lines (44 loc) · 1.2 KB
/
Copy pathlaunch.sh
File metadata and controls
executable file
·56 lines (44 loc) · 1.2 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
#!/usr/bin/env sh
set -eu
fail() {
printf 'Error: %s\n' "$*" >&2
exit 1
}
find_python() {
if [ -x "$VENV_PYTHON" ]; then
printf '%s\n' "$VENV_PYTHON"
return
fi
if command -v python >/dev/null 2>&1; then
command -v python
return
fi
if command -v python3 >/dev/null 2>&1; then
command -v python3
return
fi
return 1
}
resolve_script_dir() {
script=$0
case "$script" in
*/*) ;;
*)
found=$(command -v "$script" 2>/dev/null || true)
[ -n "$found" ] && script=$found
;;
esac
script_dir=$(CDPATH= cd "$(dirname "$script")" && pwd -P)
printf '%s\n' "$script_dir"
}
APP_DIR=$(resolve_script_dir)
VENV_DIR="${APP_DIR}/.venv"
VENV_PYTHON="${VENV_DIR}/bin/python"
ACTIVATE_SCRIPT="${VENV_DIR}/bin/activate"
cd "$APP_DIR"
PYTHON=$(find_python) || fail "Missing ${VENV_DIR} and no python executable was found. Run the macOS/Linux install command from README first."
if [ "$PYTHON" = "$VENV_PYTHON" ] && [ -f "$ACTIVATE_SCRIPT" ]; then
# Keep subprocess behavior consistent with a normal user-activated venv.
. "$ACTIVATE_SCRIPT"
fi
exec "$PYTHON" -m ballontranslator "$@"