-
Notifications
You must be signed in to change notification settings - Fork 517
222 lines (211 loc) · 7.07 KB
/
build_wheel.yml
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Build and upload to PyPI
on:
push:
branches-ignore:
- "gh-readonly-queue/**"
tags:
- "v*"
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
determine-arm64-runner:
runs-on: ubuntu-latest
permissions: read-all
outputs:
runner: ${{ steps.set-runner.outputs.runner }}
steps:
- name: Determine which runner to use for ARM64 build
id: set-runner
run: |
if [ "${{ github.repository_owner }}" == "deepmodeling" ]; then
echo "runner=[\"Linux\",\"ARM64\"]" >> $GITHUB_OUTPUT
else
echo "runner=\"ubuntu-latest\"" >> $GITHUB_OUTPUT
fi
build_wheels:
name: Build wheels for cp${{ matrix.python }}-${{ matrix.platform_id }}
needs: determine-arm64-runner
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# linux-64
- os: ubuntu-latest
python: 311
platform_id: manylinux_x86_64
dp_variant: cuda
cuda_version: 12.2
- os: ubuntu-latest
python: 311
platform_id: manylinux_x86_64
dp_variant: cuda
cuda_version: 11.8
dp_pkg_name: deepmd-kit-cu11
# macos-x86-64
- os: macos-13
python: 311
platform_id: macosx_x86_64
dp_variant: cpu
# macos-arm64
- os: macos-14
python: 311
platform_id: macosx_arm64
dp_variant: cpu
# win-64
- os: windows-2019
python: 311
platform_id: win_amd64
dp_variant: cpu
# linux-aarch64
- os: ${{ fromJson(needs.determine-arm64-runner.outputs.runner) }}
python: 310
platform_id: manylinux_aarch64
dp_variant: cpu
steps:
- uses: actions/checkout@v4
with:
# https://github.com/pypa/setuptools_scm/issues/480
fetch-depth: 0
- name: Install uv
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.2.24/uv-installer.sh | sh
if: runner.os != 'Linux'
- uses: docker/setup-qemu-action@v3
name: Setup QEMU
if: matrix.platform_id == 'manylinux_aarch64' && matrix.os == 'ubuntu-latest'
# detect version in advance. See #3168
- run: |
echo "SETUPTOOLS_SCM_PRETEND_VERSION=$(pipx run uv tool run --from setuptools_scm python -m setuptools_scm)" >> $GITHUB_ENV
rm -rf .git
if: matrix.dp_pkg_name == 'deepmd-kit-cu11'
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_ARCHS: all
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
DP_VARIANT: ${{ matrix.dp_variant }}
CUDA_VERSION: ${{ matrix.cuda_version }}
DP_PKG_NAME: ${{ matrix.dp_pkg_name }}
CIBW_BUILD_FRONTEND: 'build[uv]'
- uses: actions/upload-artifact@v4
with:
name: cibw-cp${{ matrix.python }}-${{ matrix.platform_id }}-cu${{ matrix.cuda_version }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build sdist
run: pipx run uv tool run --with build[uv] --from build python -m build --installer uv --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
build_docker:
# use the already built wheels to build docker
needs: [build_wheels]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- variant: ""
cuda_version: "12"
- variant: "_cu11"
cuda_version: "11"
steps:
- name: Delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: source/install/docker/dist
pattern: cibw-*-manylinux_x86_64-cu${{ matrix.cuda_version }}*
merge-multiple: true
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/deepmodeling/deepmd-kit
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: source/install/docker
push: ${{ github.repository_owner == 'deepmodeling' && github.event_name == 'push' && github.actor != 'dependabot[bot]' }}
tags: ${{ steps.meta.outputs.tags }}${{ matrix.variant }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VARIANT=${{ matrix.variant }}
CUDA_VERSION=${{ matrix.cuda_version }}
build_pypi_index:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist/packages
pattern: cibw-*
merge-multiple: true
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
- run: pip install dumb-pypi
- run: |
ls dist/packages > package_list.txt
dumb-pypi --output-dir dist --packages-url ../../packages --package-list package_list.txt --title "DeePMD-kit Developed Packages"
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
deploy_pypi_index:
needs: build_pypi_index
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/devel' && github.repository_owner == 'deepmodeling'
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
pass:
name: Pass testing build wheels
needs: [build_wheels, build_sdist, build_docker, build_pypi_index]
runs-on: ubuntu-latest
if: always()
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}