-
Notifications
You must be signed in to change notification settings - Fork 16
130 lines (110 loc) · 4.86 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
name: Build Python Binding
on:
push:
branches:
- main
tags:
- '**'
# pull_request: {}
jobs: # Workflow credit to https://github.com/samuelcolvin/rtoml/blob/main/.github/workflows/ci.yml
# Yue: I use cibuildwheel to start multiple dockers with different targets, and use maturin to actually generate the wheel
build_wheels:
name: Build wheels py3.${{ matrix.python-version }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu
- macos
- windows
python-version: # Yue 2022.10.9: I enabled abi3-py37 in pyo3, so everything built will be py37-abi3 which is compatible with py37+
# - '7'
- '8' # use python 3.8 to build because macos universal2 requires at least python 3.8; however the result will be py37-abi3
# - '9'
# - '10'
# - '11'
include:
- os: ubuntu
platform: linux
- os: windows
ls: dir
runs-on: ${{ format('{0}-latest', matrix.os) }}
steps:
- uses: actions/checkout@v3
if: matrix.os != 'macos' || matrix['python-version'] != '7' # no python37 for macos
- uses: actions/setup-python@v3
if: matrix.os != 'macos' || matrix['python-version'] != '7' # no python37 for macos
- name: Install Rust
# unnecessary for ubuntu because it's installed inside cibuildwheel
# no python37 for macos
if: matrix.os != 'ubuntu' && (matrix.os != 'macos' || matrix['python-version'] != '7')
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-11-16
override: true
- name: Install Python dependencies
if: matrix.os != 'macos' || matrix['python-version'] != '7' # no python37 for macos
run: python -m pip install -U setuptools wheel twine cibuildwheel
# - name: Set up QEMU for building with emulator
# if: matrix.os == 'ubuntu'
# uses: docker/setup-qemu-action@v2
# with:
# platforms: all
- name: Build Wheels
if: matrix.os != 'macos' || matrix['python-version'] != '7' # no python37 for macos
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: 'cp3${{ matrix.python-version }}-*'
CIBW_SKIP: "*-win32 *_i686" # do not build for 32bit machines, rustc seems to complain about it
CIBW_PLATFORM: ${{ matrix.platform || matrix.os }} # only build for specific platform
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"'
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
CIBW_MANYLINUX_X86_64_IMAGE: 'manylinux2014'
# Yue 2022.10.17: build on aarch64 failed due to strange `cargo metadata` exited with an error: Updating crates.io index
CIBW_ARCHS_LINUX: x86_64 # aarch64 requires QEMU, ~ 40min for each manylinux and musllinux...
CIBW_ARCHS_MACOS: universal2
CIBW_BEFORE_BUILD: >
rustup default nightly-2023-11-16 &&
rustup show
CIBW_BEFORE_BUILD_MACOS: >
rustup target add aarch64-apple-darwin &&
rustup default nightly-2023-11-16 &&
rustup show
CIBW_BEFORE_BUILD_LINUX: >
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly-2023-11-16 --profile=minimal -y &&
rustup show
- name: Build windows 32bit wheels
if: matrix.os == 'windows'
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32'
CIBW_PLATFORM: windows
CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"'
CIBW_BEFORE_BUILD: >
rustup toolchain install nightly-2023-11-16-i686-pc-windows-msvc &&
rustup default nightly-2023-11-16-i686-pc-windows-msvc &&
rustup override set nightly-2023-11-16-i686-pc-windows-msvc &&
rustup show
- name: list wheel files
if: matrix.os != 'macos' || matrix['python-version'] != '7' # no python37 for macos
run: ${{ matrix.ls || 'ls -lh' }} wheelhouse/
- name: twine check
if: matrix.os != 'macos' || matrix['python-version'] != '7' # no python37 for macos
run: twine check wheelhouse/*
- uses: actions/upload-artifact@v3
if: matrix.os != 'macos' || matrix['python-version'] != '7' # no python37 for macos
with:
path: wheelhouse/*.whl
# build_sdist:
# name: Build source distribution
# runs-on: ubuntu-latest
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v3
# - name: Install Python dependencies
# run: python -m pip install -U maturin cffi
# - uses: actions/upload-artifact@v3
# with:
# path: ./wheelhouse/*.tar.gz
# upload_pypi:
# needs: [build_wheels, build_sdist]