双周会和安同校园行里面已经做了一些说明,下面是个人的一些补充。
[manylinux](https://github.com/pypa/manylinux)
主要供 [cibuildwheel](https://github.com/pypa/cibuildwheel)
使用。
由于历史的原因,之前 manylinux
一直构建在 RedHat
系操作系统之上(随着 armv7
和 riscv64
的架构引入而新增了 Debian
系),因此上游的 Python
项目基本上都没有对其他操作系统的可能性进行适配,比如:
很多类似的项目使用了 yum
命令进行依赖管理,因此想要在改动比较小或者不改动源代码的情况下进行构建最好使用 RedHat
系的操作系统,如果使用非 RedHat
系的话需要进行一些侵入操作,维护和管理上会带来一些麻烦。
镜像的选型其实之前已经测试过,参考:
目前的问题是使用这些镜像上游是否愿意接受?如果由我们自己维护的话应该不成问题。
下面是一些额外的参考:
AlmaLinux
的基础镜像是使用 https://github.com/AlmaLinux/container-images
该项目生成。
参考该项目为龙架构也构建了所需的基础镜像 https://github.com/loong64/container-images,然后生成 https://github.com/loong64/manylinux/tree/patch_loong64 manylinux 镜像。
(由于新世界目前并没有基于 glibc2.36
的 RedHat
系操作系统,经过多次测试最终选择改动最小的 Anolis OS
作为基础镜像 glibc2.38
)
目前 https://github.com/loong64/pypi/tree/master/.github/workflows 项目已经做了一些测试的构建工作,感兴趣的也可以自己测试验证一下。
在 linux/loong64
上可以使用下面的步骤进行 wheel
包构建:
pip install cibuildwheel --break-system-packages --index-url https://gitlab.com/api/v4/projects/65746188/packages/pypi/simple
cd ~
wget https://files.pythonhosted.org/packages/fc/97/c783634659c2920c3fc70419e3af40972dbaf758daa229a7d6ea6135c90d/cffi-1.17.1.tar.gz
tar -xf cffi-1.17.1.tar.gz
cd cffi-1.17.1
CIBW_ARCHS=loongarch64 cibuildwheel . --output-dir ../wheelhouse
ls -al ../wheelhouse
如果希望在 Github Actions
进行构建,可以参考 https://github.com/loong64/pypi/actions