Skip to content

Commit 0638967

Browse files
committed
feat(coral-tpu): dynamic pycoral wheel resolution for Windows Python 3.10+
Google's official Edge TPU wheels only support Windows Python up to 3.9. We now use an inline Python script to probe sys.version_info during deploy.bat execution. It automatically falls back to community-compiled PyCoral wheels (feranick/pycoral) if Python 3.10 or 3.11 are detected natively. Also added user alerts advising that UAC will spawn a detached Google setup console window that they must wait for.
1 parent 670bf6f commit 0638967

2 files changed

Lines changed: 55 additions & 3 deletions

File tree

skills/detection/yolo-detection-2026-coral-tpu/deploy.bat

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ powershell -Command "Expand-Archive -Path 'edgetpu_runtime_20221024.zip' -Destin
3838
cd edgetpu_runtime
3939

4040
echo %LOG_PREFIX% Prompting for Administrator rights to install drivers... 1>&2
41-
echo {"event": "progress", "stage": "platform", "message": "UAC required: Install Google Coral Edge TPU Windows Runtime"}
41+
echo {"event": "progress", "stage": "platform", "message": "A separate UAC prompt and blue terminal will appear. Please approve it."}
42+
echo {"event": "progress", "stage": "platform", "message": "Waiting for Google install.bat to finish..."}
4243

4344
REM Start the official install script elevated. Wait for it to finish.
4445
powershell -Command "Start-Process -FilePath 'cmd.exe' -ArgumentList '/c', 'install.bat < nul' -Verb RunAs -Wait"
@@ -101,9 +102,9 @@ echo {"event": "progress", "stage": "build", "message": "Fetching pycoral specif
101102

102103
"%VENV_DIR%\Scripts\python.exe" -m pip install --upgrade pip >nul 2>&1
103104

104-
"%VENV_DIR%\Scripts\python.exe" -m pip install --extra-index-url https://google-coral.github.io/py-repo/ pycoral~=2.0
105+
"%VENV_DIR%\Scripts\python.exe" "%SKILL_DIR%scripts\install_pycoral.py"
105106
if %errorlevel% neq 0 (
106-
echo %LOG_PREFIX% WARNING: pip install pycoral failed. Will attempt to install standard requirements anyway. 1>&2
107+
echo %LOG_PREFIX% WARNING: pycoral install script failed. 1>&2
107108
)
108109

109110
"%VENV_DIR%\Scripts\python.exe" -m pip install -r "%SKILL_DIR%requirements.txt"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import sys
2+
import subprocess
3+
import json
4+
5+
def emit(event_dict):
6+
print(json.dumps(event_dict), flush=True)
7+
8+
def main():
9+
py_major = sys.version_info.major
10+
py_minor = sys.version_info.minor
11+
12+
emit({"event": "progress", "stage": "build", "message": f"Detected Python {py_major}.{py_minor} — selecting appropriate PyCoral wheel..."})
13+
14+
if py_major == 3 and py_minor <= 9:
15+
emit({"event": "progress", "stage": "build", "message": "Installing official Google pycoral 2.0 (Python <=3.9)..."})
16+
url = "https://google-coral.github.io/py-repo/"
17+
try:
18+
subprocess.check_call([sys.executable, "-m", "pip", "install", "--extra-index-url", url, "pycoral~=2.0"])
19+
except subprocess.CalledProcessError:
20+
print("WARNING: Official pycoral install failed.")
21+
sys.exit(1)
22+
23+
elif py_major == 3 and py_minor == 10:
24+
emit({"event": "progress", "stage": "build", "message": "Installing community pycoral for Python 3.10 (feranick/pycoral)..."})
25+
url = "https://github.com/feranick/pycoral/releases/download/2.0.0TF2.11.1-1/pycoral-2.0.0-cp310-cp310-win_amd64.whl"
26+
try:
27+
subprocess.check_call([sys.executable, "-m", "pip", "install", url])
28+
except subprocess.CalledProcessError:
29+
print("ERROR: Failed to install community wheel for Python 3.10")
30+
sys.exit(1)
31+
32+
elif py_major == 3 and py_minor == 11:
33+
emit({"event": "progress", "stage": "build", "message": "Installing community pycoral for Python 3.11 (feranick/pycoral)..."})
34+
url = "https://github.com/feranick/pycoral/releases/download/2.0.0TF2.11.1-1/pycoral-2.0.0-cp311-cp311-win_amd64.whl"
35+
try:
36+
subprocess.check_call([sys.executable, "-m", "pip", "install", url])
37+
except subprocess.CalledProcessError:
38+
print("ERROR: Failed to install community wheel for Python 3.11")
39+
sys.exit(1)
40+
41+
else:
42+
emit({
43+
"event": "error",
44+
"stage": "build",
45+
"message": f"No pre-compiled PyCoral Windows wheels for Python {py_major}.{py_minor}. Please downgrade to Python 3.9, 3.10, or 3.11."
46+
})
47+
print(f"ERROR: Unsupported Python version {py_major}.{py_minor} for Edge TPU on Windows.")
48+
sys.exit(1)
49+
50+
if __name__ == "__main__":
51+
main()

0 commit comments

Comments
 (0)