-
Notifications
You must be signed in to change notification settings - Fork 12
162 lines (138 loc) · 5.19 KB
/
Copy pathpython-app.yml
File metadata and controls
162 lines (138 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# GitHub Actions workflow for Sequenzo package
name: Build Wheels for Sequenzo
on:
push:
tags:
- "v*"
workflow_dispatch:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: Build ${{ matrix.os }} Py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11']
steps:
- name: Checkout source with submodules
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Add OpenMP support
- name: Install OpenMP (macOS)
if: runner.os == 'macOS'
run: |
brew install libomp
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
echo "LDFLAGS=-L$(brew --prefix libomp)/lib" >> $GITHUB_ENV
echo "CPPFLAGS=-I$(brew --prefix libomp)/include" >> $GITHUB_ENV
echo "SEQUENZO_ENABLE_OPENMP=1" >> $GITHUB_ENV
- name: Install OpenMP (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libomp-dev
echo "SEQUENZO_ENABLE_OPENMP=1" >> $GITHUB_ENV
- name: Setup MSVC with OpenMP (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Enable OpenMP (Windows)
if: runner.os == 'Windows'
run: |
echo "SEQUENZO_ENABLE_OPENMP=1" >> $env:GITHUB_ENV
# 强制使用预编译包,避免源码编译问题
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --only-binary=all --prefer-binary numpy scipy
pip install --prefer-binary Cython pybind11 build cibuildwheel twine
# 针对 fastcluster,尝试安装预编译版本
pip install --only-binary=fastcluster fastcluster || pip install fastcluster
- name: Build Cython wheels on macOS
if: runner.os == 'macOS'
run: |
python setup.py build_ext --inplace
python -m build
- name: Clean previous build outputs
if: runner.os != 'macOS'
run: |
rm -rf build/ dist/ *.egg-info
find . -name "*.so" -delete
shell: bash
- name: Build wheels with cibuildwheel
if: runner.os != 'macOS'
run: python -m cibuildwheel --output-dir dist
env:
CIBW_SKIP: "pp* *-musllinux*" # 跳过 PyPy 和 musllinux
CIBW_ARCHS_WINDOWS: "AMD64"
CIBW_ARCHS_LINUX: "x86_64"
# 环境变量配置
CIBW_ENVIRONMENT_LINUX: >
SEQUENZO_ENABLE_OPENMP=1
PIP_PREFER_BINARY=1
CIBW_ENVIRONMENT_WINDOWS: >
SEQUENZO_ENABLE_OPENMP=1
# Linux: 安装更完整的依赖
CIBW_BEFORE_BUILD_LINUX: >
yum install -y libgomp-devel openblas-devel lapack-devel ||
apt-get update && apt-get install -y libomp-dev libopenblas-dev liblapack-dev ||
echo "Dependency installation attempted"
# 使用预编译包安装依赖
CIBW_BEFORE_BUILD: >
pip install --upgrade pip &&
pip install --only-binary=all numpy scipy &&
pip install --prefer-binary fastcluster || echo "fastcluster installation attempted"
# 测试命令
CIBW_TEST_COMMAND: >
python -c "
import sequenzo;
print('Sequenzo import successful');
try:
import sequenzo.clustering.clustering_c_code;
print('C++ extensions loaded');
except Exception as e:
print(f'WARNING C++ extensions issue: {e}')
"
- name: Show dist content
run: ls -lah dist/
shell: bash
- name: Check wheels
run: twine check dist/*
- name: Verify OpenMP Support
run: |
echo "=== 验证构建的wheel中的OpenMP支持 ==="
python -c "
import subprocess
import sys
import os
wheel_files = [f for f in os.listdir('dist') if f.endswith('.whl') and 'cp${{ matrix.python-version }}' in f.replace('.', '')]
if wheel_files:
wheel_file = wheel_files[0]
print(f'Installing wheel: {wheel_file}')
subprocess.run([sys.executable, '-m', 'pip', 'install', '--force-reinstall', f'dist/{wheel_file}'], check=True)
import sequenzo
print('Sequenzo导入成功')
try:
import sequenzo.clustering.clustering_c_code as cc
print('C++扩展加载成功')
except ImportError as e:
print(f'ERROR C++扩展加载失败: {e}')
else:
print('ERROR 未找到对应的wheel文件')
"
shell: bash
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.python-version }}
path: dist/