Skip to content

chore: modernize dependencies (Flask 2.x, redis 4/5) and Docker base to Python 3.11 - #230

Merged
Germey merged 1 commit into
masterfrom
chore/modernize-deps-runtime
Jul 4, 2026
Merged

chore: modernize dependencies (Flask 2.x, redis 4/5) and Docker base to Python 3.11#230
Germey merged 1 commit into
masterfrom
chore/modernize-deps-runtime

Conversation

@Germey

@Germey Germey commented Jul 4, 2026

Copy link
Copy Markdown
Member

背景

Issue 收敛计划 Phase 2(依赖与运行环境现代化)。目标:让项目在现代 Python 上能正常安装运行,同时保持行为不变(稳妥升级:Flask 2.x + redis 4/5 + Python 3.11)。

问题

  • requirements.txtitsdangerous==0.24(2014 年)、MarkupSafe<2.1Flask<2.0 三者绑死,在 Python 3.10+ 上直接装不上,是大量「安装报错」类 issue 的根因。
  • Dockerfile 基于 python:3.7-alpine(3.7 已 EOL)。alpine + musl 需要现场编译 gevent/lxml/aiohttp,慢且易失败,ARM(树莓派)尤甚。

改动

requirements.txt

  • Flask 升到 >=2.0,<3.0,并显式约束 Werkzeug>=2.0,<3.0;移除 itsdangerous==0.24MarkupSafe<2.1(由 Flask 2.x 自动解析正确版本)。
  • redis >=4.3,<6(代码已有 IS_REDIS_VERSION_2 兼容分支,redis-py 4/5 的 zadd(mapping)/zincrby(amount, value) 签名完全兼容)。
  • aiohttp>=3.9lxml<6gevent<25environs<12attrs<24,均放宽到支持 3.11/3.12 的版本。

Dockerfile

  • 基础镜像 python:3.7-alpinepython:3.11-slim。Debian 有 gevent/lxml/aiohttp 的 manylinux wheel,安装从「现场编译」变为「直接装 wheel」,更快更稳,并原生支持 arm64。
  • 构建阶段保留最小编译依赖,运行阶段无需额外系统库(wheel 自带)。

验证

pip install --dry-run -r requirements.txt 解析成功、无冲突:

Would install Flask-2.3.3 Werkzeug-2.3.8 itsdangerous-2.2.0 Jinja2-3.1.6
  redis-5.3.1 aiohttp-3.14.1 gevent-24.11.1 greenlet-3.5.3 lxml-5.4.0
  environs-11.2.1 attrs-23.2.0 supervisor-4.3.0 tornado-6.5.7 ...

代码走查确认未使用 Flask 2.x 已移除的 API。

关联 issue

注:/countkey 参数时直接返回 int 的历史小问题(Flask 视图不允许返回 int)留待 server 相关 PR 一并修。

- requirements: move to Flask 2.x and drop the ancient itsdangerous==0.24 / MarkupSafe<2.1 pins that blocked installs on Python 3.10+; bump redis to 4/5, aiohttp>=3.9, lxml<6, gevent<25; add explicit Werkzeug<3 bound

- Dockerfile: base image python:3.7-alpine (EOL) -> python:3.11-slim so gevent/lxml/aiohttp install from wheels instead of compiling under musl, fixing common build failures and enabling arm64 (e.g. Raspberry Pi)

Refs #167, #183, #192, #178, #149, #158
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not able to start with the docker 安装依赖报错!

1 participant