Skip to content

Commit fb53ed9

Browse files
committed
fix: use manylinux2014 for Colab compatibility
- Switch from manylinux_2_28 to manylinux2014 (provides manylinux_2_17) - This should produce wheels compatible with manylinux_2_35_x86_64 requirement - Update package manager from dnf to yum for CentOS 7 - Use cmake3 with symlink for compatibility
1 parent 015f437 commit fb53ed9

File tree

3 files changed

+66
-90
lines changed

3 files changed

+66
-90
lines changed

.github/workflows/build-cibuildwheel.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ jobs:
4646
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-*
4747
CIBW_SKIP: "*-win32 *-manylinux_i686 pp* *musllinux*"
4848

49-
# Use manylinux_2_28 for better compatibility
50-
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
51-
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
49+
# 使用manylinux2014生成兼容性更好的wheels
50+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
51+
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
5252

53-
# Install dependencies before building
53+
# Linux dependencies - 使用yum因为manylinux2014基于CentOS 7
5454
CIBW_BEFORE_ALL_LINUX: |
55-
dnf install -y epel-release
56-
dnf install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake
55+
yum install -y epel-release
56+
yum install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake3
57+
ln -sf /usr/bin/cmake3 /usr/bin/cmake
5758
5859
CIBW_BEFORE_ALL_MACOS: |
5960
brew install boost zeromq openblas cmake
@@ -77,12 +78,13 @@ jobs:
7778
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-*
7879
CIBW_SKIP: "*-win32 *-manylinux_i686 pp* *musllinux*"
7980

80-
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
81-
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
81+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
82+
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
8283

8384
CIBW_BEFORE_ALL_LINUX: |
84-
dnf install -y epel-release
85-
dnf install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake
85+
yum install -y epel-release
86+
yum install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake3
87+
ln -sf /usr/bin/cmake3 /usr/bin/cmake
8688
8789
CIBW_BEFORE_ALL_MACOS: |
8890
brew install boost zeromq openblas cmake

MANYLINUX_BUILD_STRATEGY.md

Lines changed: 48 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,50 @@
11
# Manylinux Build Strategy
22

3-
## 问题概述
4-
5-
Colab和许多Linux环境需要`manylinux`兼容的wheels,而不是特定于某个Linux发行版的wheels。我们之前的尝试过于复杂,试图手动处理所有的依赖关系。
6-
7-
## 新策略
8-
9-
基于社区最佳实践和其他成功项目的经验,我们采用了以下简化方案:
10-
11-
### 1. 使用 cibuildwheel
12-
13-
`cibuildwheel`是PyPA推荐的构建多平台wheels的工具,它:
14-
- 自动处理manylinux环境设置
15-
- 管理不同Python版本的构建
16-
- 提供标准化的测试框架
17-
18-
### 2. 使用 manylinux_2_28
19-
20-
-`manylinux2014`升级到`manylinux_2_28`
21-
- 提供更现代的基础库
22-
- 使用`dnf`而不是`yum`
23-
- 更好地支持现代Python版本
24-
25-
### 3. CMake配置
26-
27-
`pyproject.toml`中添加:
28-
```toml
29-
[tool.scikit-build.cmake.define]
30-
Python_FIND_VIRTUALENV = "ONLY"
31-
Python3_FIND_VIRTUALENV = "ONLY"
32-
```
33-
34-
这帮助CMake在cibuildwheel的虚拟环境中正确找到Python。
35-
36-
### 4. 简化的依赖安装
37-
38-
只安装必要的系统依赖:
39-
- `gcc-c++`
40-
- `boost-devel`
41-
- `zeromq-devel`
42-
- `openblas-devel`
43-
- `cmake`
44-
45-
## 测试策略
46-
47-
1. **手动触发**: 使用`workflow_dispatch`在GitHub Actions上测试
48-
2. **自动测试**: 在`fix/manylinux-*`分支上推送时自动运行
49-
3. **PR测试**: 当PR修改相关文件时自动测试
50-
51-
## 如何使用
52-
53-
### 在本地测试
54-
```bash
55-
# 安装cibuildwheel
56-
pip install cibuildwheel
57-
58-
# 构建wheels
59-
cibuildwheel --platform linux packages/leann-backend-hnsw
60-
```
61-
62-
### 在GitHub Actions测试
63-
1. 推送到`fix/manylinux-compatibility`分支
64-
2. 或手动触发"Test Manylinux Build"工作流
65-
66-
## 下一步
67-
68-
1. **监控CI运行结果**
69-
2. **根据错误调整依赖**
70-
3. **测试生成的wheels在Colab的兼容性**
71-
4. **如果成功,将更改合并到main**
72-
73-
## 参考
74-
75-
- [cibuildwheel文档](https://cibuildwheel.readthedocs.io/)
76-
- [manylinux规范](https://github.com/pypa/manylinux)
77-
- [scikit-build-core文档](https://scikit-build-core.readthedocs.io/)
3+
## Problem
4+
Google Colab requires wheels compatible with `manylinux_2_35_x86_64` or earlier. Our previous builds were producing `manylinux_2_39_x86_64` wheels, which are incompatible.
5+
6+
## Solution
7+
We're using `cibuildwheel` with `manylinux2014` images to build wheels that are compatible with a wide range of Linux distributions, including Google Colab.
8+
9+
### Key Changes
10+
11+
1. **cibuildwheel Configuration**
12+
- Using `manylinux2014` images (provides `manylinux_2_17` compatibility)
13+
- Using `yum` package manager (CentOS 7 based)
14+
- Installing `cmake3` and creating symlink for compatibility
15+
16+
2. **Build Matrix**
17+
- Python versions: 3.9, 3.10, 3.11, 3.12, 3.13
18+
- Platforms: Linux (x86_64), macOS
19+
- No Windows support (not required)
20+
21+
3. **Dependencies**
22+
- Linux: gcc-c++, boost-devel, zeromq-devel, openblas-devel, cmake3
23+
- macOS: boost, zeromq, openblas, cmake (via Homebrew)
24+
25+
4. **Environment Variables**
26+
- `CMAKE_BUILD_PARALLEL_LEVEL=8`: Speed up builds
27+
- `Python_FIND_VIRTUALENV=ONLY`: Help CMake find Python in cibuildwheel env
28+
- `Python3_FIND_VIRTUALENV=ONLY`: Alternative variable for compatibility
29+
30+
## Testing Strategy
31+
32+
1. **CI Pipeline**: `test-manylinux.yml`
33+
- Triggers on PR to main, manual dispatch, or push to `fix/manylinux-*` branches
34+
- Builds wheels using cibuildwheel
35+
- Tests installation on Ubuntu 22.04 (simulating Colab)
36+
37+
2. **Local Testing**
38+
```bash
39+
# Download built wheels
40+
# Test in fresh environment
41+
python -m venv test_env
42+
source test_env/bin/activate
43+
pip install leann_core-*.whl leann_backend_hnsw-*manylinux*.whl leann-*.whl
44+
python -c "from leann import LeannBuilder; print('Success!')"
45+
```
46+
47+
## References
48+
- [cibuildwheel documentation](https://cibuildwheel.readthedocs.io/)
49+
- [manylinux standards](https://github.com/pypa/manylinux)
50+
- [PEP 599 - manylinux2014](https://peps.python.org/pep-0599/)

pyproject.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ leann-backend-hnsw = { path = "packages/leann-backend-hnsw", editable = true }
6565
# 跳过32位和PyPy构建
6666
skip = "*-win32 *-manylinux_i686 pp* *musllinux*"
6767

68-
# 使用更新的manylinux镜像以获得更好的兼容性
69-
manylinux-x86_64-image = "manylinux_2_28"
70-
manylinux-aarch64-image = "manylinux_2_28"
68+
# 使用manylinux2014以获得最大兼容性(支持GLIBC 2.17)
69+
manylinux-x86_64-image = "manylinux2014"
70+
manylinux-aarch64-image = "manylinux2014"
7171

7272
# Linux系统依赖
7373
[tool.cibuildwheel.linux]
7474
before-all = """
75-
dnf install -y epel-release
76-
dnf install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake
75+
yum install -y epel-release
76+
yum install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake3
77+
ln -sf /usr/bin/cmake3 /usr/bin/cmake
7778
"""
7879

7980
# macOS系统依赖

0 commit comments

Comments
 (0)