python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

停止支持 Python 2

Open weakish opened this issue 5 years ago • 3 comments

  1. Python 2 已于 2020 年 1 月 1 号 EOL;未来 Python 3.10 还会移除一些兼容 Python 2 的特性
  2. SDK 用的依赖也逐渐开始停止支持 Python 2,比如 gevent 1.5 官方说不支持 python 3.8 的(不过目前在 3.8 下跑单元测试能跑过,但不确定会不会有边角问题),而支持 3.8 的 gevent 20 又不支持 python 2.7;Arrow 说下一个版本将停止支持 Python 2.7 和 Python 3.5

所以未来如果要继续支持 Python 2 的话,会越来越麻烦,可能很多地方都要写两份代码(其实现在 SDK 有些地方就已经是这么做了,未来随着依赖库逐渐抛弃 Python 2,这样的分支会越来越多,增加维护的难度),云引擎那边也要修改,根据 Python 版本选择不同的依赖文件(比如 requirements-py2.txt 之类)。

weakish avatar Nov 19 '20 05:11 weakish

gevent 21 又回过头把 python 2.7 的支持加回来了,然后同一份 requirments.txt 里也是可以根据 python 的版本不同指定不同的依赖。所以看起来 Python 2 还能继续支持一阵。

Arrow 说下一个版本将停止支持 Python 2.7 和 Python 3.5

Arrow 的下一个版本(1.0)已经在 2021 年 2 月发布,不支持 Python 2.7 Pendulum (功能类似 Arrow 的替代品)目前还支持 Python 2.7,未来可以考虑把 arrow 换成 Pendulum 如果还要继续支持 Python 2 的话。

weakish avatar Mar 03 '21 04:03 weakish

另外贴一下统计数据,近 30 日云引擎 Python 运行时请求数:

  • 国际版:全是 Python 3
  • 华北节点:Python 2 占比约千分之一

weakish avatar Mar 05 '21 09:03 weakish

未来可以考虑把 arrow 换成 Pendulum 如果还要继续支持 Python 2 的话。

换 Pendulum 也许还能解决 arrow 在 Windows 平台上不支持负的 unix 时间的问题 (工单 37855)

@pytest.mark.skipif(
    os.name == "nt", reason="negative timestamps are not supported on Windows"
)

weakish avatar May 24 '21 07:05 weakish