-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun_gui.sh
More file actions
executable file
·91 lines (77 loc) · 2.83 KB
/
Copy pathrun_gui.sh
File metadata and controls
executable file
·91 lines (77 loc) · 2.83 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
# Launch PolyVox Studio using the local PolyVox virtual environment.
set -euo pipefail
export TRANSFORMERS_NO_TF=1
export TRANSFORMERS_NO_JAX=1
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_DIR_DEFAULT="${SCRIPT_DIR}/PolyVox"
ENV_DIR="${POLYVOX_ENV_DIR:-$ENV_DIR_DEFAULT}"
CONDA_ENV="${POLYVOX_CONDA_ENV:-}"
PYTHON_CMD=""
use_conda_env() {
if ! command -v conda >/dev/null 2>&1; then
echo "❌ Requested conda environment '${CONDA_ENV}' but conda is not installed or not on PATH." >&2
exit 1
fi
# shellcheck disable=SC1090
eval "$(conda shell.bash hook)"
conda activate "${CONDA_ENV}"
}
find_missing_dependencies() {
"${PYTHON_CMD}" - <<'PY'
import importlib.util
checks = {
"Pillow (PIL)": "PIL",
"spaCy": "spacy",
"PyTorch": "torch",
"CustomTkinter": "customtkinter",
}
missing = [name for name, module in checks.items() if importlib.util.find_spec(module) is None]
print(", ".join(missing))
PY
}
check_python_dependencies() {
local missing
missing="$(find_missing_dependencies)"
if [ -z "${missing}" ]; then
return
fi
echo "ℹ️ Missing required Python modules: ${missing}" >&2
echo " Attempting automatic repair from requirements_min.txt..." >&2
if "${PYTHON_CMD}" -m pip install -r "${SCRIPT_DIR}/requirements_min.txt" --upgrade; then
missing="$(find_missing_dependencies)"
fi
if [ -n "${missing}" ]; then
echo "❌ Missing required Python modules: ${missing}" >&2
echo " Your environment looks incomplete." >&2
echo " Recommended fix: run './install_linux.sh' and let it finish." >&2
echo " Advanced fix: activate this environment and run 'python -m pip install -r requirements_min.txt --upgrade'." >&2
exit 1
fi
}
if [ -d "${ENV_DIR}" ]; then
PYTHON_CMD="${ENV_DIR}/bin/python"
if [ ! -x "${PYTHON_CMD}" ]; then
echo "❌ Python executable not found at ${PYTHON_CMD}." >&2
echo " Re-run './install_linux.sh' to rebuild the default environment." >&2
exit 1
fi
elif [ -n "${CONDA_ENV}" ]; then
use_conda_env
PYTHON_CMD="python"
elif [ -n "${VIRTUAL_ENV:-}" ]; then
echo "ℹ️ Using already active virtual environment at ${VIRTUAL_ENV}" >&2
PYTHON_CMD="python"
elif [ -n "${CONDA_PREFIX:-}" ]; then
echo "ℹ️ Using active conda environment ${CONDA_DEFAULT_ENV:-$(basename "${CONDA_PREFIX}")}" >&2
PYTHON_CMD="python"
else
echo "❌ PolyVox environment not found at ${ENV_DIR}." >&2
echo " Activate your environment first (e.g. 'conda activate epub') or set POLYVOX_ENV_DIR/POLYVOX_CONDA_ENV." >&2
echo " You can also run './install_linux.sh' to create the default PolyVox virtualenv." >&2
exit 1
fi
echo "ℹ️ Using Python: $("${PYTHON_CMD}" -c 'import sys; print(sys.executable)')" >&2
check_python_dependencies
"${PYTHON_CMD}" -m app.main