|
94 | 94 | exit 1 |
95 | 95 | fi |
96 | 96 |
|
97 | | -# ─── Step 2: Find or install Python 3.9 ───────────────────────────────────── |
98 | | -# PyCoral pip wheels are only available for Python 3.6–3.9 on Linux. |
99 | | -# We lock to 3.9 regardless of the system Python version via pyenv. |
100 | | -emit '{"event": "progress", "stage": "python", "message": "Resolving Python 3.9..."}' |
101 | | - |
102 | | -PYTHON_CMD="" |
103 | | - |
104 | | -# Check for python3.9 natively first (fastest path) |
105 | | -if command -v python3.9 &>/dev/null; then |
106 | | - PYTHON_CMD="python3.9" |
107 | | - log "Found native python3.9: $(python3.9 --version)" |
108 | | -else |
109 | | - log "python3.9 not found — attempting pyenv install..." |
110 | | - emit '{"event": "progress", "stage": "python", "message": "python3.9 not found — installing via pyenv..."}' |
111 | | - |
112 | | - # Install pyenv if missing |
113 | | - if ! command -v pyenv &>/dev/null; then |
114 | | - log "Installing pyenv..." |
115 | | - curl -sSL https://pyenv.run | bash |
116 | | - # Add pyenv to PATH for this session |
117 | | - export PYENV_ROOT="$HOME/.pyenv" |
118 | | - export PATH="$PYENV_ROOT/bin:$PATH" |
119 | | - eval "$(pyenv init -)" |
120 | | - else |
121 | | - export PYENV_ROOT="${PYENV_ROOT:-$HOME/.pyenv}" |
122 | | - export PATH="$PYENV_ROOT/bin:$PATH" |
123 | | - eval "$(pyenv init -)" |
124 | | - fi |
125 | | - |
126 | | - # Install Python 3.9.x via pyenv |
127 | | - if ! pyenv versions --bare | grep -q "^3\.9"; then |
128 | | - emit '{"event": "progress", "stage": "python", "message": "pyenv: compiling Python 3.9 (this may take a few minutes)..."}' |
129 | | - pyenv install 3.9.18 |
130 | | - fi |
131 | | - |
132 | | - PYTHON_CMD="$(pyenv root)/versions/$(pyenv versions --bare | grep "^3\.9" | tail -1)/bin/python3" |
| 97 | +# ─── Step 2: Find Python 3 ────────────────────────────────────────────── |
| 98 | +# ai-edge-litert supports Python 3.9–3.13. No version pinning needed. |
| 99 | +if ! command -v python3 &>/dev/null; then |
| 100 | + emit '{"event": "error", "stage": "python", "message": "Python 3 not found. Install via your package manager."}' |
| 101 | + exit 1 |
133 | 102 | fi |
134 | | - |
| 103 | +PYTHON_CMD="python3" |
135 | 104 | log "Using Python: $($PYTHON_CMD --version)" |
136 | 105 |
|
137 | 106 | # ─── Step 3: Create isolated venv ──────────────────────────────────────────── |
|
146 | 115 |
|
147 | 116 | "$VENV_DIR/bin/python" -m pip install --upgrade pip >/dev/null 2>&1 || true |
148 | 117 |
|
149 | | -# ─── Step 4: Install PyCoral via pip (works with Python 3.9 wheels) ────────── |
150 | | -emit '{"event": "progress", "stage": "build", "message": "Installing PyCoral 2.0 wheels from Google..."}' |
151 | | -if ! "$VENV_DIR/bin/python" -m pip install --extra-index-url https://google-coral.github.io/py-repo/ pycoral~=2.0; then |
152 | | - emit '{"event": "error", "stage": "build", "message": "pip install pycoral failed"}' |
153 | | - exit 1 |
154 | | -fi |
155 | | - |
| 118 | +# ─── Step 4: Install dependencies ────────────────────────────────────────────── |
| 119 | +emit '{"event": "progress", "stage": "build", "message": "Installing ai-edge-litert and dependencies..."}' |
156 | 120 | if ! "$VENV_DIR/bin/python" -m pip install -r "$SKILL_DIR/requirements.txt"; then |
157 | 121 | emit '{"event": "error", "stage": "build", "message": "pip install requirements failed"}' |
158 | 122 | exit 1 |
|
0 commit comments