最近在学习 Python 包管理机制,了解到以下信息:
- PEP-425: Wheel 打包格式支持声明目标部署平台( platform tag ),且
pip install会根据当前平台信息( i.e. windows/macos/linux )自动选择匹配对应的 wheel。 - PEP-513 与 PEP-571 定义了一个兼容性较强的 Linux 依赖集合,希望可以接近“一次编译,到处运行”的目标:It would be ideal if wheel packages could be compiled that would work on any linux system. ... we define a standard subset of the kernel+core userspace ABI that, in practice, is compatible enough that packages conforming to this standard will work on many linux systems
基于此,可以对任意语言实现的源码进行交叉编译,将编译结果打包成 wheel 格式,发布至 PyPI。用户可直接通过 pip 自动下载安装其平台所需的二进制包。
基于这个思路,我用 GitHub workflow 在 Linux/MacOS 上编译了 Redis 并发布到 PyPI,详见: