-
Notifications
You must be signed in to change notification settings - Fork 6
239 lines (194 loc) · 8.93 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
name: Python wheel package build and publish
on:
release:
types: [published]
# Enable Run Workflow button in GitHub UI
workflow_dispatch:
inputs:
# Manual dispatch allows optional upload of wheels to PyPI
upload_dest:
type: choice
description: Upload wheels to
options:
- No Upload
- PyPI
- Test PyPI
push:
# branches: [ main ]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
# For PyPI Trusted Publisher
id-token: write
jobs:
build_sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build SDist
run: pipx run build --sdist
- name: Check metadata
run: pipx run twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
build_wheels:
name: Wheels - ${{ matrix.cibw_archs }} ${{ matrix.arch_note}} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
cibw_archs: "auto64"
# Linux x86 manylinux
- os: ubuntu-latest
cibw_archs: "x86_64"
# Python 3.12 wheel requires libffi-devel to be installed. manylinux container uses yum
cibw_before_build_linux: "yum install -y libffi-devel"
# skip musllinux
cibw_skip: "*musl*"
# Linux x86 musllinux
# Separate runner for a Musl build of graphblas. The glibc build is not guaranteed to be compatible.
- os: ubuntu-latest
cibw_archs: "x86_64"
arch_note: "musl"
# skip manylinux (built elsewhere), PyPy (no musl numpy wheels), CPython 3.8 (no musl numpy wheels)
cibw_skip: "*many* pp* cp38*"
# Linux aarch64
# Separate runner because this requires emulation (only x86 runners are available) and is very slow.
- os: ubuntu-latest
cibw_archs: "aarch64"
# numpy wheels not available for aarch64 PyPy or musllinux
cibw_skip: "pp* *musl*"
# macOS x86
# Note: keep as old as possible as due to libomp this will be the oldest supported macOS version.
- os: macos-12
cibw_archs: "x86_64"
# macOS Apple Silicon
# Note: keep as old as possible as due to libomp this will be the oldest supported macOS version.
- os: macos-14
cibw_archs: "arm64"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# aarch64 Linux builds are cross-compiled on x86 runners using emulation
# see https://cibuildwheel.readthedocs.io/en/stable/faq/#emulation
- name: Setup QEMU (for aarch64)
if: matrix.cibw_archs == 'aarch64'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Setup env (for aarch64)
if: matrix.cibw_archs == 'aarch64'
# Ask suitesparse.sh to compile faster by optimizing fewer types. Otherwise, the build takes too long to finish
# in 6 hour limit.
run: |
echo "SUITESPARSE_FAST_BUILD=1" >> $GITHUB_ENV
- name: Setup for testing
if: github.event_name == 'push' || github.event_name == 'pull_request'
# Ask suitesparse.sh to compile in the fastest way possible and provide a GB version to build
run: |
echo "SUITESPARSE_FASTEST_BUILD=1" >> $GITHUB_ENV
shell: bash
- name: Setup GraphBLAS version from GB_VERSION.txt
# Use GraphBLAS version specified in GB_VERSION.txt unless specified in a git tag (next workflow step).
# Git tag method required for uploads to PyPI.
if: github.event_name != 'release' && github.event.inputs.upload_dest != 'PyPI'
run: echo "GB_VERSION_REF=refs/tags/$(cat GB_VERSION.txt).0" >> $GITHUB_ENV
shell: bash
- name: Setup GraphBLAS version from git tag
if: ${{ startsWith(github.ref, 'refs/tags/') }}
# If this is a tagged ref, like a release, then use the tag for the graphblas version
run: echo "GB_VERSION_REF=${{ github.ref }}" >> $GITHUB_ENV
shell: bash
- name: Install tools (macOS)
if: contains(matrix.os, 'macos')
# Install coreutils which includes `nproc` used by `make -j` in suitesparse.sh
#
# Explicitly install libomp to be clear about the dependency.
#
# libomp determines the minimum macOS version that we can build for
run: |
brew fetch --retry coreutils && brew install coreutils
brew fetch --retry libomp && brew install libomp
echo MACOSX_DEPLOYMENT_TARGET=$(otool -l $(brew --prefix libomp)/lib/libomp.dylib | grep minos | awk '{print $2}') >> $GITHUB_ENV
- uses: pypa/[email protected]
with:
output-dir: wheelhouse
env:
# very verbose
CIBW_BUILD_VERBOSITY: 3
# Build SuiteSparse
CIBW_BEFORE_ALL: bash suitesparse.sh ${{ env.GB_VERSION_REF }}
CIBW_BEFORE_BUILD_LINUX: ${{ matrix.cibw_before_build_linux }}
CIBW_ENVIRONMENT_PASS_LINUX: SUITESPARSE_FAST_BUILD SUITESPARSE_FASTEST_BUILD
# CMAKE_GNUtoMS=ON asks suitesparse.sh to build libraries in MSVC style on Windows.
CIBW_ENVIRONMENT_WINDOWS: GRAPHBLAS_PREFIX="C:/GraphBLAS" CMAKE_GNUtoMS=ON
# macOS libomp requires special configs. BREW_LIBOMP=1 asks suitesparse.sh to include them.
# SUITESPARSE_MACOS_ARCH asks to build a particular architecture. Either x86 or arm64.
CIBW_ENVIRONMENT_MACOS: GRAPHBLAS_PREFIX="{package}/graphblas" BREW_LIBOMP="1" SUITESPARSE_MACOS_ARCH=${{ matrix.cibw_archs }}
CIBW_ENVIRONMENT_LINUX: GRAPHBLAS_PREFIX="{package}/graphblas"
# Uncomment to only build CPython wheels
# CIBW_BUILD: "cp*"
# Architectures to build specified in matrix
CIBW_ARCHS: ${{ matrix.cibw_archs }}
# as of writing numpy does not support pypy 3.10
CIBW_SKIP: "${{ matrix.cibw_skip }} pp310*"
# Use delvewheel on Windows.
# This copies graphblas.dll into the wheel. "repair" in cibuildwheel parlance includes copying any shared
# libraries from the build host into the wheel to make the wheel self-contained.
# Cibuildwheel includes tools for this for Linux and macOS, and they recommend delvewheel for Windows.
# Note: Currently using a workaround: --no-mangle instead of stripping graphblas.dll
# see https://github.com/adang1345/delvewheel/issues/33
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair --add-path \"C:\\GraphBLAS\\bin\" --no-mangle \"libgomp-1.dll;libgcc_s_seh-1.dll\" -w {dest_dir} {wheel}"
# make cibuildwheel install test dependencies from pyproject.toml
CIBW_TEST_EXTRAS: "test"
# run tests
CIBW_TEST_COMMAND: "pytest --pyargs suitesparse_graphblas -s -k test_print_jit_config && pytest -v --pyargs suitesparse_graphblas"
CIBW_TEST_SKIP: ${{ matrix.cibw_test_skip }}
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.cibw_archs }}${{ matrix.arch_note}}
path: wheelhouse/*.whl
if-no-files-found: error
upload_all:
name: Upload to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# only upload releases to PyPI
if: github.repository == 'GraphBLAS/python-suitesparse-graphblas' && ((github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest != 'No Upload'))
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
# Upload to PyPI
- uses: pypa/gh-action-pypi-publish@release/v1
name: Upload to PyPI
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest == 'PyPI')
with:
# PyPI does not allow replacing a file. Without this flag the entire action fails if even a single duplicate exists.
skip-existing: true
verbose: true
password: ${{ secrets.PYPI_TOKEN }}
# Upload to Test PyPI
- uses: pypa/gh-action-pypi-publish@release/v1
name: Upload to Test PyPI
if: github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest == 'Test PyPI'
with:
# PyPI does not allow replacing a file. Without this flag the entire action fails if even a single duplicate exists.
skip-existing: true
verbose: true
repository-url: https://test.pypi.org/legacy/