-
Notifications
You must be signed in to change notification settings - Fork 7
368 lines (342 loc) · 14.8 KB
/
wheels.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
on:
workflow_call:
inputs:
publish:
type: boolean
description: "If true, the packages will be published."
default: false
env:
CMAKE_BUILD_TYPE: Release
jobs:
build_sdist:
name: Build sdist artifacts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
- name: Install poetry
run: |
pipx install poetry
- name: Build sdit
run: |
poetry build -f sdist
ls ./dist
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-sdist
path: dist/
build_wheels:
name: Build wheel for py${{ matrix.python-version }} ${{ matrix.os.platform_id }}
runs-on: ${{ matrix.os.name }}
strategy:
# Ensure that a wheel builder finishes even if another fails
# list of github vm: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os:
- name: "ubuntu-latest"
platform: "linux"
platform_id: "manylinux_x86_64"
- name: "macos-13"
platform: "macos"
min_macos_version: "13"
platform_id: "macosx_x86_64"
- name: "macos-14"
platform: "macos"
min_macos_version: "14"
platform_id: "macosx_arm64"
- name: "windows-latest"
platform: "windows"
platform_id: "win_amd64"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
id: py
with:
python-version: ${{ matrix.python-version }}
update-environment: false
- name: Install Poetry
run: |
which python
python --version
which python3
python3 --version
echo "pythonpath: ${{ steps.py.outputs.python-path }}"
${{ steps.py.outputs.python-path }} --version
pipx install poetry==1.8.4
poetry env use ${{ steps.py.outputs.python-path }}
- name: Set up custom PATH and set py version to cpXYZ [windows]
if: ${{matrix.os.platform_id == 'win_amd64'}}
shell: pwsh
run: |
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\Users\runneradmin\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\nasm" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$version = "${{ matrix.python-version }}"
$cp_version = "cp$($version -replace '\.', '')"
Add-Content -Path $env:GITHUB_ENV -Value "python_cp_version=$cp_version"
- name: Convert python version to cpXYZ
if: ${{matrix.os.platform_id != 'win_amd64'}}
run: |
version=${{ matrix.python-version }}
cp_version="cp${version//.}"
echo "python_cp_version=$cp_version" >> $GITHUB_ENV
- name: Build wheels [macos-x86_64]
if: ${{matrix.os.platform_id == 'macosx_x86_64'}}
env:
CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }}
CIBW_ARCHS: x86_64
CIBW_ARCHS_MACOS: x86_64
CIBW_PLATFORM: macos
CIBW_SKIP: "pp* *-musllinux_* *_i686* *_s390* *arm64* *pypy*"
CIBW_PROJECT_REQUIRES_PYTHON: "~=${{ matrix.python-version }}.0"
CIBW_BUILD_VERBOSITY: 3
CMAKE_OSX_ARCHITECTURES: x86_64
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # do not run delocate-wheel before the re-tag
CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.min_macos_version }}.0"
ARCHFLAGS: -arch x86_64
BUILD_THREADS: "4"
PYTORCH_MPS_HIGH_WATERMARK_RATIO: "0.0"
run: |
PY_CACHE_TAG=$(poetry run python -c 'import sys;print(sys.implementation.cache_tag)')
echo "Building wheel ${CIBW_BUILD} ${{ env.CIBW_BUILD }}"
echo "Building cp: ${{ env.python_cp_version }}"
echo "Building cache_tag: ${PY_CACHE_TAG}"
echo "Building platform_id: ${{ matrix.os.platform_id }}"
poetry run python --version
poetry run python --version | grep ${{ matrix.python-version }}
poetry install --no-root --only=build
cat ./pyproject.toml
poetry run python -m cibuildwheel --output-dir wheelhouse
echo "step 1"
ls -l wheelhouse
poetry run wheel tags --remove --platform-tag macosx_${{ matrix.os.min_macos_version }}_0_x86_64 ./wheelhouse/*.whl
rm -f ./wheelhouse/*arm64.whl
echo "step 2"
ls -l wheelhouse
poetry run delocate-wheel --require-archs x86_64 -v ./wheelhouse/*.whl
echo "step 3"
ls -l wheelhouse
for file in ./wheelhouse/*.whl; do
echo "Inspecting $file"
poetry run python -m zipfile --list "$file"
echo "Checking if .so is contained in the wheel"
poetry run python -m zipfile --list "$file" | grep \\.so
echo "Checking if the correct python version is contained in the wheel"
poetry run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG}
done
mkdir -p ./dist
cp wheelhouse/*.whl ./dist/
# there is an error with the tagging of wheels for macosx-arm64
# see note: https://cibuildwheel.readthedocs.io/en/stable/faq/
# see here: https://gist.github.com/anderssonjohan/49f07e33fc5cb2420515a8ac76dc0c95#file-build-pendulum-wheels-yml-L39-L53
- name: Build wheels [macos-arm64]
if: ${{matrix.os.platform_id == 'macosx_arm64'}}
env:
CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }}
CIBW_ARCHS: arm64
CIBW_ARCHS_MACOS: arm64
CIBW_PLATFORM: macos
CIBW_SKIP: "pp* *-musllinux_* *_i686* *x86_64* *_s390* *pypy*"
CIBW_PROJECT_REQUIRES_PYTHON: "~=${{ matrix.python-version }}.0"
CIBW_BUILD_VERBOSITY: 3
CMAKE_OSX_ARCHITECTURES: arm64
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # do not run delocate-wheel before the re-tag
CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.min_macos_version }}.0"
ARCHFLAGS: -arch arm64
BUILD_THREADS: "4"
PYTORCH_MPS_HIGH_WATERMARK_RATIO: "0.0"
CUDA_VISIBLE_DEVICES: "cpu"
run: |
PY_CACHE_TAG=$(poetry run python -c 'import sys;print(sys.implementation.cache_tag)')
echo "Building wheel ${CIBW_BUILD} ${{ env.CIBW_BUILD }}"
echo "Building cp: ${{ env.python_cp_version }}"
echo "Building cache_tag: ${PY_CACHE_TAG}"
echo "Building platform_id: ${{ matrix.os.platform_id }}"
poetry run python --version
poetry run python --version | grep ${{ matrix.python-version }}
poetry install --no-root --only=build
cat ./pyproject.toml
poetry run python -m cibuildwheel --output-dir wheelhouse
echo "step 1"
ls -l wheelhouse
poetry run wheel tags --remove --platform-tag macosx_${{ matrix.os.min_macos_version }}_0_arm64 ./wheelhouse/*.whl
rm -f ./wheelhouse/*x86_64.whl
echo "step 2"
ls -l wheelhouse
poetry run delocate-wheel --require-archs arm64 -v ./wheelhouse/*.whl
echo "step 3"
ls -l wheelhouse
for file in ./wheelhouse/*.whl; do
echo "Inspecting $file"
poetry run python -m zipfile --list "$file"
echo "Checking if .so is contained in the wheel"
poetry run python -m zipfile --list "$file" | grep \\.so
echo "Checking if the correct python version is contained in the wheel"
poetry run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG}
done
mkdir -p ./dist
cp wheelhouse/*.whl ./dist/
- name: Set up QEMU [linux]
if: matrix.os.name == 'ubuntu-latest'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Build wheels [linux]
if: matrix.os.name == 'ubuntu-latest'
env:
# CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }}
CIBW_ARCHS: auto x86_64 aarch64
CIBW_PLATFORM: linux
CIBW_SKIP: "pp* *musllinux_* *_i686* *_s390* *pypy*"
CIBW_PROJECT_REQUIRES_PYTHON: "~=${{ matrix.python-version }}.0"
CIBW_BUILD_VERBOSITY: 3
BUILD_THREADS: "8"
run: |
PY_CACHE_TAG=$(poetry run python -c 'import sys;print(sys.implementation.cache_tag)')
echo "Building cp: ${{ env.python_cp_version }}"
echo "Building cache_tag: ${PY_CACHE_TAG}"
echo "Building platform_id: ${{ matrix.os.platform_id }}"
poetry run python --version
poetry run python --version | grep ${{ matrix.python-version }}
poetry install --no-root --only=build
cat ./pyproject.toml
poetry run python -m cibuildwheel --output-dir ./wheelhouse
ls -l ./wheelhouse
for file in ./wheelhouse/*.whl; do
echo "Inspecting $file"
poetry run python -m zipfile --list "$file"
echo "Checking if .so is contained in the wheel"
poetry run python -m zipfile --list "$file" | grep \\.so
echo "Checking if the correct python version is contained in the wheel"
poetry run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG}
done
mkdir -p ./dist
cp wheelhouse/*.whl ./dist/
- name: Test install wheel [macos-arm64]
if: matrix.os.platform_id == 'macosx_arm64' && matrix.os.name == 'macos-14'
shell: bash
run: |
wheel_file=$(ls dist/*.whl | head -n 1)
poetry run pip install "$wheel_file"
- name: Set up MSYS2 [windows]
if: ${{matrix.os.platform_id == 'win_amd64'}}
uses: msys2/setup-msys2@v2
with:
update: true
install: >
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-gcc-libs
- name: Set up external-libs [windows]
if: ${{matrix.os.platform_id == 'win_amd64'}}
shell: pwsh
run: |
Copy-Item -Path "C:/mingw64/bin/libgcc_s_seh-1.dll" -Destination ".\deepsearch_glm"
Copy-Item -Path "C:/mingw64/bin/libstdc++-6.dll" -Destination ".\deepsearch_glm"
Copy-Item -Path "C:/mingw64/bin/libwinpthread-1.dll" -Destination ".\deepsearch_glm"
- name: Build wheels [windows]
if: ${{matrix.os.platform_id == 'win_amd64'}}
env:
CIBW_PLATFORM: windows
CIBW_BUILD_VERBOSITY: 3
CIBW_ARCHS: AMD64
CIBW_PROJECT_REQUIRES_PYTHON: "~=${{ matrix.python-version }}.0"
PKG_CONFIG_PATH: "C:/msys64/usr/lib/pkgconfig"
PKG_CONFIG_EXECUTABLE: "C:/mingw64/bin/pkg-config.exe"
CMAKE_PREFIX_PATH: "C:/msys64/mingw64;C:/mingw64"
CMAKE_LIBRARY_PATH: "C:/msys64/mingw64/lib;C:/mingw64/lib"
CMAKE_INCLUDE_PATH: "C:/msys64/mingw64/include;C:/mingw64/include"
CMAKE_GENERATOR: "MSYS Makefiles"
BUILD_THREADS: 1
shell: pwsh
run: |
Remove-Item -Recurse -Force "C:\Strawberry\"
poetry install --no-interaction --no-root --only=build
poetry run python -m cibuildwheel --output-dir .\wheelhouse
Get-ChildItem -Path .\wheelhouse -Filter *.whl | Format-List
Get-ChildItem -Path .\wheelhouse -Filter *.whl | ForEach-Object {
$file = $_.FullName
Write-Output "Inspecting $file"
poetry run python -m zipfile --list "$file"
}
if (-not (Test-Path -Path .\dist)) {
New-Item -Path .\dist -ItemType Directory
}
Copy-Item -Path .\wheelhouse\*.whl -Destination .\dist\
- name: Test install wheel [windows]
if: ${{matrix.os.platform_id == 'win_amd64'}}
shell: pwsh
run: |
$wheel_file = Get-ChildItem dist\*.whl | Select-Object -First 1
Write-Host "Installing wheel: $wheel_file"
poetry run pip install "$wheel_file"
- name: Quick test wheel
if: ${{ matrix.os.platform_id == 'win_amd64' || (matrix.os.platform_id == 'macosx_arm64' && matrix.os.name == 'macos-14') }}
run: |
poetry install --no-interaction --no-root --all-extras
poetry run python -c 'from deepsearch_glm import andromeda_glm'
poetry run pytest ./tests/test_glm.py -v
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-py${{ matrix.python-version }}-${{ matrix.os.platform_id }}
path: dist/
publish-packages:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: inputs.publish && startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build_sdist
- build_wheels
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/deepsearch-glm
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
contents: write # IMPORTANT: mandatory for adding artifacts to GitHub Releases
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist/
- name: List dist/
run: |
ls ./dist
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
release-signing-artifacts: false
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: List dist/
run: |
ls ./dist
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
# PyPI does not accept .sigstore artifacts and
# gh-action-pypi-publish has no option to ignore them.
- name: Remove sigstore signatures before uploading to PyPI
run: rm ./dist/*.sigstore.json
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# currently not working with reusable workflows
attestations: false