From ef46199346b593feba64cee6b5a83bac011bcdfd Mon Sep 17 00:00:00 2001 From: zhayujie Date: Tue, 9 Jun 2026 15:24:32 +0800 Subject: [PATCH] feat: update run.sh for python3.13 --- run.sh | 4 ++-- scripts/run.ps1 | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/run.sh b/run.sh index 1895ea67..015f5d92 100755 --- a/run.sh +++ b/run.sh @@ -359,7 +359,7 @@ detect_python_command() { FOUND_NEWER_VERSION="" # Try to find Python command in order of preference - for cmd in python3 python python3.13 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + for cmd in python3 python python3.12 python3.11 python3.10 python3.9 python3.8 python3.7 python3.13; do if command -v $cmd &> /dev/null; then # Check Python version major_version=$($cmd -c 'import sys; print(sys.version_info[0])' 2>/dev/null) @@ -378,7 +378,7 @@ detect_python_command() { done if [ -z "$PYTHON_CMD" ]; then - echo -e "${YELLOW}Tried: python3, python, python3.13, python3.12, python3.11, python3.10, python3.9, python3.8, python3.7${NC}" + echo -e "${YELLOW}Tried: python3, python, python3.12, python3.11, python3.10, python3.9, python3.8, python3.7, python3.13${NC}" echo -e "${RED}❌ No suitable Python found. Please install Python 3.7 or newer${NC}" exit 1 fi diff --git a/scripts/run.ps1 b/scripts/run.ps1 index 636ade2f..53ad3cb8 100644 --- a/scripts/run.ps1 +++ b/scripts/run.ps1 @@ -194,6 +194,8 @@ function Select-Language { # ── Python detection ───────────────────────────────────────────── function Find-Python { + # 3.13 compatibility is not great, so prefer 3.7-3.12 and only fall back to 3.13. + $fallback = $null foreach ($cmd in @("python3", "python")) { $bin = Get-Command $cmd -ErrorAction SilentlyContinue if (-not $bin) { continue } @@ -201,12 +203,15 @@ function Find-Python { $ver = & $bin.Source -c "import sys; v=sys.version_info; print(f'{v.major}.{v.minor}')" 2>$null $parts = $ver -split '\.' $major = [int]$parts[0]; $minor = [int]$parts[1] - if ($major -eq 3 -and $minor -ge 7 -and $minor -le 13) { + if ($major -eq 3 -and $minor -ge 7 -and $minor -le 12) { return $bin.Source } + if ($major -eq 3 -and $minor -eq 13 -and -not $fallback) { + $fallback = $bin.Source + } } catch {} } - return $null + return $fallback } $PythonCmd = Find-Python