-
Notifications
You must be signed in to change notification settings - Fork 7
153 lines (127 loc) · 4.97 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
name: wheels
on:
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
release:
types:
- published
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
- name: Build SDist
# Our Python package is in the python/ subdirectory.
# Also, the fast_matrix_market C++ library is symlinked. The build tool ignores the symlinks, so
# replace the symlinks with their targets so that they get included in the sdist.
run: |
cd python/
cd fast_matrix_market/
for LINK in *; do DEST="$(readlink -f $LINK)"; rm -rf $LINK; cp -r $DEST .; done;
cd ..
pipx run build --sdist
cd ..
shell: bash
- name: Check metadata
run: pipx run twine check python/dist/*
- uses: actions/upload-artifact@v4
with:
name: sdist
path: python/dist/*.tar.gz
build_wheels:
name: Wheels on ${{ matrix.os }} - ${{ matrix.cibw_archs }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Originally based on scikit-learn's config, but has diverged since:
# https://github.com/scikit-learn/scikit-learn/blob/main/.github/workflows/wheels.yml
include:
- os: windows-latest
cibw_archs: "AMD64"
- os: ubuntu-latest
cibw_archs: "x86_64"
- os: ubuntu-latest
cibw_archs: "aarch64"
# numpy wheels not available for aarch64 PyPy or musllinux
cibw_skip: "pp* *musl*"
- os: macos-latest
cibw_archs: "x86_64"
- os: macos-latest
cibw_archs: "arm64"
# Skip macOS ARM tests on Intel runner.
cibw_test_skip: "*-macosx_arm64"
steps:
- uses: actions/checkout@v4
- name: Setup QEMU
# for building non-x86 Linux wheels on x86 runner
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- uses: pypa/[email protected]
with:
package-dir: python
output-dir: wheelhouse
env:
CIBW_BUILD_VERBOSITY: 3
CIBW_ARCHS: ${{ matrix.cibw_archs }}
CIBW_SKIP: ${{ matrix.cibw_skip }}
CIBW_TEST_SKIP: ${{ matrix.cibw_test_skip }}
# Allow pre-release to test on newest Python that may only have beta or RC numpy packages available.
# --only-binary and ' || true' to best-effort numpy and scipy installation.
# Some platforms do not have binary wheels for either package, some only for numpy.
# Notably PyPy: no scipy wheels, and numpy wheels for only some versions.
CIBW_BEFORE_TEST: pip install --pre --only-binary ":all:" numpy && pip install --pre --only-binary ":all:" scipy || true
# make cibuildwheel install test dependencies from pyproject.toml
CIBW_TEST_EXTRAS: "testmin"
# run tests in the {package}/tests dir which is python/tests
CIBW_TEST_COMMAND: "pytest {package}/tests"
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.cibw_archs }}
path: wheelhouse/*.whl
upload_all:
name: Upload to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest != 'No Upload')
steps:
- uses: actions/download-artifact@v4
with:
path: dist_artifacts
- name: Flatten artifacts to dist/
run: mkdir dist && find dist_artifacts -type f -exec mv {} dist \;
# 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_API_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/