From 392fa6326f8122d0c5efa16af8d27b68ad89e6ba Mon Sep 17 00:00:00 2001 From: plean Date: Wed, 18 Nov 2026 02:37:57 +0000 Subject: [PATCH] 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. --- README.md | 4 ++++ setup.sh | 39 +++++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 66e4843..256213d 100644 --- a/README.md +++ b/README.md @@ -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 ``` +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 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** diff --git a/setup.sh b/setup.sh index 6d78e93..30908b6 100755 --- a/setup.sh +++ b/setup.sh @@ -7,29 +7,36 @@ # ./setup.sh --skip-weights keep existing weights/ set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" -PASCAL=0; SKIP_WEIGHTS=0 -for a in "$@"; do - case "$a" in +PASCAL=0; SKIP_WEIGHTS=0; PYCAND="" +while [[ $# -gt 0 ]]; do + case "$1" in --pascal) PASCAL=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 + shift done -command -v python3 >/dev/null || { echo "python3 required (3.10+)"; exit 1; } -python3 -c 'import sys; assert sys.version_info >= (3, 10)' || { echo "python >= 3.10 required"; exit 1; } +command -v python3 >/dev/null || { echo "python3 required (3.10-3.12)"; exit 1; } echo "== venv" -if ! python3 -m venv .venv 2>/dev/null; then - # Debian/Ubuntu ship python3 without ensurepip (python3-venv package): - if command -v conda >/dev/null 2>&1; then - echo "(system python3 lacks venv support - using conda base python)" - "$(conda info --base)/bin/python3" -m venv .venv || { echo "venv creation failed"; exit 1; } - else - echo "venv creation failed - install python3-venv (apt) or run:" - echo " conda create -n omniparse python=3.12 && .venv fallback: OMNI_PYTHON=... (see README)" - exit 1 - fi +# numpy 1.26.4 / torch 2.6 ship cp310-cp312 wheels only: pick an interpreter +# in range whose venv works (some distros ship python3 without ensurepip). +[[ -z "$PYCAND" ]] || VENV_PY="$(command -v "$PYCAND" || echo "$PYCAND")" +for cand in ${VENV_PY:-} python3.12 python3.11 python3.10 python3; do + command -v "$cand" >/dev/null 2>&1 || [ -x "$cand" ] || continue + "$cand" -c 'import sys; raise SystemExit(0 if (3,10) <= sys.version_info < (3,13) else 1)' 2>/dev/null || continue + rm -rf .venv + "$cand" -m venv .venv 2>/dev/null && [ -x .venv/bin/pip ] && break +done +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 .venv/bin/pip install -q --upgrade pip