setup.sh: robust interpreter selection (--python flag, 3.10-3.12 wheel-range guard)

Clean-venv build executed end-to-end on Pascal hardware: slimmed
requirements.txt boots the full pipeline; torch 2.6.0+cu124, sm_61 detected.
This commit is contained in:
plean committed 2026-11-18 02:37:57 +00:00
1 parent 61a0f353cd
commit 392fa6326f
2 files changed
+27 -16

No files matched your search

+4
View File
@@ -52,6 +52,10 @@ git clone https://git.plean.rip/plean/omniparse-mcp.git && cd omniparse-mcp
curl -s http://127.0.0.1:8898/healthz curl -s http://127.0.0.1:8898/healthz
``` ```
setup.sh needs a Python **3.10–3.12** venv (the pinned numpy/torch wheels stop
at cp312). If your default `python3` is newer or lacks venv support, point at
any suitable interpreter: `./setup.sh --python /path/to/python3.12`.
`start.sh` binds **127.0.0.1 by default** — the bearer token is a static `start.sh` binds **127.0.0.1 by default** — the bearer token is a static
secret, so LAN exposure is an explicit opt-in: `OMNI_API_HOST=0.0.0.0 secret, so LAN exposure is an explicit opt-in: `OMNI_API_HOST=0.0.0.0
./start.sh` (firewall it yourself). The token lives **outside the repo** ./start.sh` (firewall it yourself). The token lives **outside the repo**
+23 -16
View File
@@ -7,29 +7,36 @@
# ./setup.sh --skip-weights keep existing weights/ # ./setup.sh --skip-weights keep existing weights/
set -euo pipefail set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")" cd "$(dirname "${BASH_SOURCE[0]}")"
PASCAL=0; SKIP_WEIGHTS=0 PASCAL=0; SKIP_WEIGHTS=0; PYCAND=""
for a in "$@"; do while [[ $# -gt 0 ]]; do
case "$a" in case "$1" in
--pascal) PASCAL=1 ;; --pascal) PASCAL=1 ;;
--skip-weights) SKIP_WEIGHTS=1 ;; --skip-weights) SKIP_WEIGHTS=1 ;;
*) echo "unknown flag: $a"; exit 1 ;; --python) PYCAND="${2:?--python needs a path}"; shift ;;
--python=*) PYCAND="${1#*=}" ;;
*) echo "unknown flag: $1"; exit 1 ;;
esac esac
shift
done done
command -v python3 >/dev/null || { echo "python3 required (3.10+)"; exit 1; } command -v python3 >/dev/null || { echo "python3 required (3.10-3.12)"; exit 1; }
python3 -c 'import sys; assert sys.version_info >= (3, 10)' || { echo "python >= 3.10 required"; exit 1; }
echo "== venv" echo "== venv"
if ! python3 -m venv .venv 2>/dev/null; then # numpy 1.26.4 / torch 2.6 ship cp310-cp312 wheels only: pick an interpreter
# Debian/Ubuntu ship python3 without ensurepip (python3-venv package): # in range whose venv works (some distros ship python3 without ensurepip).
if command -v conda >/dev/null 2>&1; then [[ -z "$PYCAND" ]] || VENV_PY="$(command -v "$PYCAND" || echo "$PYCAND")"
echo "(system python3 lacks venv support - using conda base python)" for cand in ${VENV_PY:-} python3.12 python3.11 python3.10 python3; do
"$(conda info --base)/bin/python3" -m venv .venv || { echo "venv creation failed"; exit 1; } command -v "$cand" >/dev/null 2>&1 || [ -x "$cand" ] || continue
else "$cand" -c 'import sys; raise SystemExit(0 if (3,10) <= sys.version_info < (3,13) else 1)' 2>/dev/null || continue
echo "venv creation failed - install python3-venv (apt) or run:" rm -rf .venv
echo " conda create -n omniparse python=3.12 && .venv fallback: OMNI_PYTHON=... (see README)" "$cand" -m venv .venv 2>/dev/null && [ -x .venv/bin/pip ] && break
exit 1 done
fi if [ ! -x .venv/bin/pip ]; then
rm -rf .venv
echo "could not create a Python 3.10-3.12 venv. Fix either way:"
echo " apt install python3-venv (Debian/Ubuntu)"
echo " ./setup.sh --python /path/to/python3.12 (e.g. a conda interpreter)"
exit 1
fi fi
.venv/bin/pip install -q --upgrade pip .venv/bin/pip install -q --upgrade pip