fix: support Python 3.13 by installing web.py from GitHub

This commit is contained in:
zhayujie
2026-06-08 20:15:32 +08:00
parent 9fc39f648f
commit c887fc71ad
5 changed files with 23 additions and 22 deletions

View File

@@ -5,7 +5,7 @@ description: One-click install and manage CowAgent with scripts
The project provides scripts for one-click install, configuration, startup, and management. Script-based deployment is recommended for quick setup.
Supports Linux, macOS, and Windows. Requires Python 3.7-3.12 (3.9 recommended).
Supports Linux, macOS, and Windows. Requires Python 3.7-3.13 (3.9 recommended).
## Install Command

View File

@@ -5,7 +5,7 @@ description: スクリプトによるCowAgentのワンクリックインスト
本プロジェクトでは、ワンクリックでのインストール、設定、起動、管理を行うスクリプトを提供しています。素早くセットアップするには、スクリプトによるデプロイを推奨します。
Linux、macOS、Windowsに対応しています。Python 3.7〜3.12が必要です3.9を推奨)。
Linux、macOS、Windowsに対応しています。Python 3.7〜3.13が必要です3.9を推奨)。
## インストールコマンド

View File

@@ -5,7 +5,7 @@ description: 使用脚本一键安装和管理 CowAgent
项目提供了一键安装、配置、启动、管理程序的脚本,推荐使用脚本快速运行。
支持 Linux、macOS、Windows 操作系统,需安装 Python 3.7 ~ 3.12(推荐 3.9)。
支持 Linux、macOS、Windows 操作系统,需安装 Python 3.7 ~ 3.13(推荐 3.9)。
## 安装命令

View File

@@ -3,8 +3,6 @@ aiohttp>=3.8.6,<3.10
requests>=2.28.2
chardet>=5.1.0
Pillow
web.py
legacy-cgi; python_version >= "3.13"
python-dotenv>=1.0.0
PyYAML>=6.0
croniter>=2.0.0
@@ -33,3 +31,8 @@ python-telegram-bot
slack_bolt
# discord bot
discord.py
# web.py: PyPI 0.62 fails to build on Python 3.13+ (cgi module removed), use GitHub fix instead
web.py; python_version < "3.13"
web.py @ git+https://github.com/webpy/webpy.git ; python_version >= "3.13"
legacy-cgi; python_version >= "3.13"

30
run.sh
View File

@@ -359,40 +359,38 @@ detect_python_command() {
FOUND_NEWER_VERSION=""
# Try to find Python command in order of preference
for cmd in python3 python python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do
for cmd in python3 python python3.13 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; 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)
minor_version=$($cmd -c 'import sys; print(sys.version_info[1])' 2>/dev/null)
if [[ "$major_version" == "3" ]]; then
# Check if version is in supported range (3.7 - 3.12)
if (( minor_version >= 7 && minor_version <= 12 )); then
# Supported range is 3.7+. On 3.13+ web.py is installed from a
# pinned GitHub commit (see requirements.txt), which needs git.
if (( minor_version >= 7 )); then
PYTHON_CMD=$cmd
PYTHON_VERSION="${major_version}.${minor_version}"
break
elif (( minor_version >= 13 )); then
# Found Python 3.13+, but not compatible
if [ -z "$FOUND_NEWER_VERSION" ]; then
FOUND_NEWER_VERSION="${major_version}.${minor_version}"
fi
fi
fi
fi
done
if [ -z "$PYTHON_CMD" ]; then
echo -e "${YELLOW}Tried: python3, python, python3.12, python3.11, python3.10, python3.9, python3.8, python3.7${NC}"
if [ -n "$FOUND_NEWER_VERSION" ]; then
echo -e "${RED}❌ Found Python $FOUND_NEWER_VERSION, but this project requires Python 3.7-3.12${NC}"
echo -e "${YELLOW}Python 3.13+ has compatibility issues with some dependencies (web.py, cgi module removed)${NC}"
echo -e "${YELLOW}Please install Python 3.7-3.12 (recommend Python 3.12)${NC}"
else
echo -e "${RED}❌ No suitable Python found. Please install Python 3.7-3.12${NC}"
fi
echo -e "${YELLOW}Tried: python3, python, python3.13, python3.12, python3.11, python3.10, python3.9, python3.8, python3.7${NC}"
echo -e "${RED}❌ No suitable Python found. Please install Python 3.7 or newer${NC}"
exit 1
fi
# On 3.13+, web.py is pulled from GitHub via pip, which requires git.
if [[ "$major_version" == "3" ]] && (( minor_version >= 13 )); then
if ! command -v git &> /dev/null; then
echo -e "${YELLOW}⚠️ Python $PYTHON_VERSION detected. Installing web.py from GitHub requires git, which was not found.${NC}"
echo -e "${YELLOW} Please install git, or use Python 3.12 where web.py installs directly from PyPI.${NC}"
fi
fi
# Export for global use
export PYTHON_CMD
export PYTHON_VERSION