-
Notifications
You must be signed in to change notification settings - Fork 42
174 lines (154 loc) · 6.27 KB
/
publish.yml
File metadata and controls
174 lines (154 loc) · 6.27 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
163
164
165
166
167
168
169
170
171
172
173
174
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml
name: Build and upload to PyPI
on:
workflow_dispatch:
pull_request:
push:
branches: [main]
release:
types: [published]
jobs:
build_wheels:
name: Build wheels for ${{ matrix.os }}-cu${{ matrix.cuda_major }}
runs-on: ${{ matrix.runs-on }}
strategy:
matrix:
include:
# CUDA 12 wheels (compiled with 12.2 for runtime 12.2+ compatibility)
- os: linux-intel
cuda_major: "12"
runs-on: ubuntu-latest
cibw_image: "ghcr.io/scverse/rapids_singlecell:manylinux_2_28_x86_64_cuda12.2"
dockerfile: "docker/manylinux_2_28_x86_64_cuda12.2.Dockerfile"
cuda_archs: "75-real;80-real;86-real;89-real;90"
- os: linux-arm
cuda_major: "12"
runs-on: ubuntu-24.04-arm
cibw_image: "ghcr.io/scverse/rapids_singlecell:manylinux_2_28_aarch64_cuda12.2"
dockerfile: "docker/manylinux_2_28_aarch64_cuda12.2.Dockerfile"
cuda_archs: "75-real;80-real;86-real;89-real;90"
# CUDA 13 wheels (native Blackwell support)
- os: linux-intel
cuda_major: "13"
runs-on: ubuntu-latest
cibw_image: "ghcr.io/scverse/rapids_singlecell:manylinux_2_28_x86_64_cuda13.0"
dockerfile: "docker/manylinux_2_28_x86_64_cuda13.0.Dockerfile"
cuda_archs: "75-real;80-real;86-real;89-real;90-real;100-real;120"
- os: linux-arm
cuda_major: "13"
runs-on: ubuntu-24.04-arm
cibw_image: "ghcr.io/scverse/rapids_singlecell:manylinux_2_28_aarch64_cuda13.0"
dockerfile: "docker/manylinux_2_28_aarch64_cuda13.0.Dockerfile"
cuda_archs: "75-real;80-real;86-real;89-real;90-real;100-real;120"
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Get version from setuptools-scm
id: version
run: |
pip install setuptools-scm
VERSION=$(python -m setuptools_scm)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Detected version: $VERSION"
- name: Set package name, extras, and CUDA archs for CUDA ${{ matrix.cuda_major }}
run: |
python3 - ${{ matrix.cuda_major }} "${{ matrix.cuda_archs }}" <<'SCRIPT'
import sys, pathlib
cuda = sys.argv[1]
cuda_archs = sys.argv[2]
other = "13" if cuda == "12" else "12"
path = pathlib.Path("pyproject.toml")
text = path.read_text()
# Rename package
text = text.replace(
'name = "rapids-singlecell"',
f'name = "rapids-singlecell-cu{cuda}"',
)
# Rename matching extra to "rapids", remove the other
text = text.replace(f'rapids-cu{cuda} =', 'rapids =')
# Remove the other CUDA extra line entirely
lines = text.splitlines(keepends=True)
text = "".join(l for l in lines if f'rapids-cu{other}' not in l)
# Set CUDA architectures (replace "native" with CI target archs)
text = text.replace(
'CMAKE_CUDA_ARCHITECTURES = "native"',
f'CMAKE_CUDA_ARCHITECTURES = "{cuda_archs}"',
)
path.write_text(text)
# Verify
for line in path.read_text().splitlines():
if "name" in line or "rapids" in line.lower() or "CUDA_ARCH" in line:
print(line)
SCRIPT
- name: Sanity check pyproject.toml
run: |
grep -E "name|rapids|CUDA_ARCH" pyproject.toml
- name: Build CUDA manylinux image
run: |
docker build -t "${{ matrix.cibw_image }}" -f "${{ matrix.dockerfile }}" docker
- name: Build wheels
uses: pypa/cibuildwheel@v3.1.4
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.version.outputs.version }}
CIBW_SKIP: '*-musllinux*'
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.os == 'linux-intel' && matrix.cibw_image || '' }}
CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.os == 'linux-arm' && matrix.cibw_image || '' }}
CIBW_ENVIRONMENT_PASS_LINUX: SETUPTOOLS_SCM_PRETEND_VERSION
CIBW_ENVIRONMENT: >
CUDA_PATH=/usr/local/cuda
LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
PATH=/usr/local/cuda/bin:$PATH
CIBW_BEFORE_BUILD: >
python -m pip install -U pip
scikit-build-core cmake ninja nanobind
CIBW_TEST_SKIP: "*"
CIBW_TEST_COMMAND: ""
CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair --exclude libcublas.so.${{ matrix.cuda_major }} --exclude libcublasLt.so.${{ matrix.cuda_major }} --exclude libcudart.so.${{ matrix.cuda_major }} -w {dest_dir} {wheel}"
CIBW_BUILD_VERBOSITY: "1"
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-cu${{ matrix.cuda_major }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
upload_wheels:
needs: [build_wheels]
runs-on: ubuntu-latest
environment: publish-cu${{ matrix.cuda_major }}
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
strategy:
matrix:
cuda_major: ["12", "13"]
steps:
- uses: actions/download-artifact@v5
with:
pattern: cibw-wheels-*-cu${{ matrix.cuda_major }}-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
upload_sdist:
needs: [build_sdist]
runs-on: ubuntu-latest
environment: publish
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v5
with:
name: cibw-sdist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1