Skip to content

Commit 62909d3

Browse files
authored
Merge pull request #204 from light-curve/abi3
ABI3 wheels
2 parents 2724e35 + 542fd92 commit 62909d3

File tree

5 files changed

+109
-75
lines changed

5 files changed

+109
-75
lines changed

.github/workflows/publish.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
diff /tmp/.crate_version /tmp/.tag
2323
2424
cibuildwheel:
25-
name: Build ${{ matrix.platform }} ${{ matrix.arch }} ${{ matrix.interpreter }}
25+
name: Build ${{ matrix.platform }} ${{ matrix.arch }} ${{ matrix.abi3 && 'ABI3 ' || '' }}${{ matrix.interpreter }}
2626
runs-on: ${{ matrix.os }}
2727

2828
needs: check-version
@@ -38,6 +38,7 @@ jobs:
3838
arch: [aarch64, ppc64le, x86_64, amd64] # amd64 is Windows-only
3939
interpreter: [cp37, cp38, cp39, cp310, cp311, pp37, pp38, pp39]
4040
platform: [manylinux, musllinux, macosx, win]
41+
abi3: [false, true]
4142
exclude:
4243
# Build Linux on Linux
4344
- os: macos-11
@@ -92,6 +93,21 @@ jobs:
9293
arch: ppc64le
9394
- os: windows-2019
9495
arch: x86_64
96+
# We need a single interpreter for ABI, so we use py310 only
97+
- abi3: true
98+
interpreter: cp37
99+
- abi3: true
100+
interpreter: cp38
101+
- abi3: true
102+
interpreter: cp39
103+
- abi3: true
104+
interpreter: cp311
105+
- abi3: true
106+
interpreter: pp37
107+
- abi3: true
108+
interpreter: pp38
109+
- abi3: true
110+
interpreter: pp39
95111

96112
steps:
97113
- uses: actions/checkout@v3
@@ -122,6 +138,14 @@ jobs:
122138
echo "CIBW_BUILD=${{ matrix.interpreter }}-${{ matrix.platform }}_${{ matrix.arch }}" >> $GITHUB_ENV
123139
echo "CIBW_ARCHS=${{ matrix.arch }}" >> $GITHUB_ENV
124140
141+
- name: Set up ABI3 build on Windows
142+
if: ${{ matrix.abi3 && matrix.os == 'windows-2019' }}
143+
run: echo "ADDITIONAL_CARGO_FEATURES=abi3" >> $env:GITHUB_ENV
144+
145+
- name: Set up ABI3 build on Linux or macOS
146+
if: ${{ matrix.abi3 && matrix.os != 'windows-2019' }}
147+
run: echo "ADDITIONAL_CARGO_FEATURES=abi3" >> $GITHUB_ENV
148+
125149
- name: Build wheels
126150
uses: pypa/cibuildwheel@v2.12.1
127151
with:

.github/workflows/test.yml

Lines changed: 75 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -48,57 +48,42 @@ jobs:
4848
strategy:
4949
fail-fast: false
5050
matrix:
51+
os: ['macos-latest', 'ubuntu-latest']
52+
abi3: [true, false]
53+
ceres: [false, 'source', 'system']
54+
fftw: ['source', 'system', 'mkl']
55+
gsl: [true, false]
56+
exclude:
57+
# We don't support MKL on macOS
58+
- os: 'macos-latest'
59+
fftw: 'mkl'
60+
# Matrix is huge, let's make it more sparse
61+
- ceres: 'system'
62+
fftw: 'source'
63+
- ceres: 'source'
64+
fftw: 'system'
65+
- ceres: 'source'
66+
fftw: 'source'
67+
gsl: false
68+
- abi3: true
69+
ceres: 'system'
70+
- abi3: false
71+
fftw: 'system'
72+
- os: 'macos-latest'
73+
ceres: 'system'
74+
gsl: true
75+
# We have very limited support for Windows, fftw-source is the only supported feature
5176
include:
52-
- name: 'Linux, default features'
53-
os: 'ubuntu-latest'
54-
maturin_build_args: '--locked'
55-
install_ceres: false
56-
install_fftw: false
57-
- name: 'macOS, default features'
58-
os: 'macos-11'
59-
maturin_build_args: '--locked'
60-
install_ceres: false
61-
install_fftw: false
62-
- name: 'Linux, system FFTW, source Ceres'
63-
os: 'ubuntu-latest'
64-
maturin_build_args: '--locked --no-default-features --features ceres-source,fftw-system'
65-
install_ceres: false
66-
install_fftw: true
67-
- name: 'macOS, system FFTW, source Ceres'
68-
os: 'macos-11'
69-
maturin_build_args: '--locked --no-default-features --features ceres-source,fftw-system'
70-
install_ceres: false
71-
install_fftw: true
72-
- name: 'Linux, system FFTW, system Ceres'
73-
os: 'ubuntu-latest'
74-
maturin_build_args: '--locked --no-default-features --features ceres-system,fftw-system'
75-
install_ceres: true
76-
install_fftw: true
77-
- name: 'macOS, system FFTW, system Ceres'
78-
os: 'macos-11'
79-
maturin_build_args: '--locked --no-default-features --features ceres-system,fftw-system'
80-
install_ceres: true
81-
install_fftw: true
82-
- name: 'Linux, system FFTW + GSL'
83-
os: 'ubuntu-latest'
84-
maturin_build_args: '--locked --no-default-features --features fftw-system,gsl'
85-
install_ceres: false
86-
install_fftw: true
87-
- name: 'macOS, system FFTW + GSL'
88-
os: 'macos-11'
89-
maturin_build_args: '--locked --no-default-features --features fftw-system,gsl'
90-
install_ceres: false
91-
install_fftw: true
92-
- name: 'Linux, MKL + GSL'
93-
os: 'ubuntu-latest'
94-
maturin_build_args: '--locked --no-default-features --features fftw-mkl,gsl'
95-
install_ceres: false
96-
install_fftw: false
97-
- name: 'Windows, statically linked FFTW for fftw-src'
98-
os: 'windows-latest'
99-
maturin_build_args: '--locked --no-default-features --features fftw-source'
100-
install_ceres: false
101-
install_fftw: false
77+
- os: 'windows-latest'
78+
abi3: false
79+
ceres: false
80+
fftw: 'source'
81+
gsl: false
82+
- os: 'windows-latest'
83+
abi3: true
84+
ceres: false
85+
fftw: 'source'
86+
gsl: false
10287

10388
defaults:
10489
run:
@@ -110,52 +95,72 @@ jobs:
11095

11196
steps:
11297
- uses: actions/checkout@v3
113-
- name: GSL, macOS
114-
if: ${{ startsWith( matrix.os, 'macos' ) }}
115-
run: brew install gsl
116-
- name: Install CERES, Linux
117-
if: ${{ matrix.install_ceres && startsWith( matrix.os, 'ubuntu' ) }}
118-
run: |
119-
sudo apt-get update
120-
sudo apt-get install -y libunwind-dev
121-
sudo apt-get install -y libceres-dev
122-
- name: Install FFTW, macOS
123-
if: ${{ matrix.install_ceres && startsWith( matrix.os, 'macos' ) }}
98+
- name: Install ceres on macOS
99+
if: ${{ matrix.ceres == 'system' && startsWith( matrix.os, 'macos' ) }}
124100
run: brew install ceres-solver
125-
- name: Install FFTW, Linux
126-
if: ${{ matrix.install_fftw && startsWith( matrix.os, 'ubuntu' ) }}
101+
- name: Install ceres on Linux
102+
if: ${{ matrix.ceres == 'system' && startsWith( matrix.os, 'ubuntu' ) }}
127103
run: |
128-
sudo apt-get update
129-
sudo apt-get install -y libfftw3-dev
130-
- name: Install FFTW, macOS
131-
if: ${{ matrix.install_fftw && startsWith( matrix.os, 'macos' ) }}
104+
sudo apt-get update
105+
sudo apt-get install -y libunwind-dev
106+
sudo apt-get install -y libceres-dev
107+
- name: Install FFTW on macOS
108+
if: ${{ matrix.fftw == 'system' && startsWith( matrix.os, 'macos' ) }}
132109
run: brew install fftw
110+
- name: Install FFTW on Linux
111+
if: ${{ matrix.fftw == 'system' && startsWith( matrix.os, 'ubuntu' ) }}
112+
run: |
113+
sudo apt-get update
114+
sudo apt-get install -y libfftw3-dev
115+
- name: Install GSL on macOS
116+
if: ${{ matrix.gsl && startsWith( matrix.os, 'macos' ) }}
117+
run: brew install gsl
118+
- name: Install GSL on Linux
119+
if: ${{ matrix.gsl && startsWith( matrix.os, 'ubuntu' ) }}
120+
run: |
121+
sudo apt-get update
122+
sudo apt-get install -y libgsl-dev
133123
- name: Set up Python 3.7
124+
if: ${{ ! matrix.abi3 }}
134125
uses: actions/setup-python@v4
135126
with:
136127
python-version: '3.7'
137128
- name: Set up Python 3.8
129+
if: ${{ ! matrix.abi3 }}
138130
uses: actions/setup-python@v4
139131
with:
140132
python-version: '3.8'
141133
- name: Set up Python 3.9
134+
if: ${{ ! matrix.abi3 }}
142135
uses: actions/setup-python@v4
143136
with:
144137
python-version: '3.9'
145138
- name: Set up Python 3.10
139+
# No if here, we want to build abi3 wheels on 3.10
146140
uses: actions/setup-python@v4
147141
with:
148142
python-version: '3.10'
149143
- name: Set up Python 3.11
144+
if: ${{ ! matrix.abi3 }}
150145
uses: actions/setup-python@v4
151146
with:
152147
python-version: '3.11'
153148
- name: Set up Rust toolchain
154149
uses: dtolnay/rust-toolchain@stable
155150
- name: Install maturin
156-
run: pip install 'maturin>=0.14,<0.15'
157-
- name: Build for ${{ matrix.name }}
158-
run: maturin build --find-interpreter --manylinux=off ${{ matrix.maturin_build_args }}
151+
run: python3 -mpip install 'maturin>=0.14,<0.15'
152+
- name: Build wheels for abi3=${{ matrix.abi3 }} fftw=${{ matrix.fftw }} ceres=${{ matrix.ceres }} gsl=${{ matrix.gsl }}
153+
run: |
154+
maturin build --find-interpreter --manylinux=off --locked --no-default-features --features=fftw-${{ matrix.fftw }}${{ matrix.ceres == 'source' && ',ceres-source' || '' }}${{ matrix.ceres == 'system' && ',ceres-system' || '' }}${{ matrix.gsl && ',gsl' || '' }}${{ matrix.abi3 && ',abi3' || '' }}
155+
- name: Install abi3audit
156+
if: ${{ matrix.abi3 }}
157+
run: python3 -mpip install abi3audit
158+
- name: Check wheels for ABI compatibility on Linux
159+
if: ${{ matrix.abi3 && startsWith( matrix.os, 'ubuntu' ) }}
160+
run: abi3audit --strict target/wheels/*.whl
161+
- name: Check wheels for ABI compatibility on Windows
162+
if: ${{ matrix.abi3 && startsWith( matrix.os, 'windows' ) }}
163+
run: Get-ChildItem -Path .\target\wheels -Filter *.whl | ForEach-Object { abi3audit --strict $_.FullName }
159164

160165
coverage:
161166
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
--
12+
- Build: "abi3" and "abi3-py310" Cargo features (the least one is enabled by the first one) to build a wheel for CPython 3.10+. This stable ABI wheel is less performant than the regular one, but it is compatible with all future Python versions. See [PEP 384](https://www.python.org/dev/peps/pep-0384/) for details. https://github.com/light-curve/light-curve-python/issues/79
1313

1414
### Changed
1515

light-curve/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ codegen-units = 1
1919

2020
[features]
2121
default = ["ceres-source", "fftw-source", "gsl"]
22+
abi3 = ["abi3-py310"]
23+
abi3-py310 = ["pyo3/abi3-py310"]
2224
ceres-source = ["light-curve-feature/ceres-source"]
2325
ceres-system = ["light-curve-feature/ceres-system"]
2426
fftw-source = ["light-curve-feature/fftw-source"]

light-curve/pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ musllinux-x86_64-image = "ghcr.io/light-curve/base-docker-images/musllinux_1_1_x
152152

153153
# We'd like to link system FFTW, because is is usually better optimised
154154
# We use system Ceres because it is available as a static library in our build environment
155-
environment = { "PATH" = "$PATH:$HOME/.cargo/bin", "MATURIN_PEP517_ARGS" = "--locked --no-default-features --features ceres-system,fftw-system,gsl" }
155+
# ADDITIONAL_CARGO_FEATURES is used to pass additional features to cargo, such as "abi3"
156+
environment = { "PATH" = "$PATH:$HOME/.cargo/bin", "MATURIN_PEP517_ARGS" = "--locked --no-default-features --features ceres-system,fftw-system,gsl,$ADDITIONAL_CARGO_FEATURES" }
156157

157158
[tool.cibuildwheel.macos]
158159
before-all = [
@@ -172,13 +173,15 @@ before-all = [
172173
before-build = ["pip install delvewheel"]
173174
repair-wheel-command = "delvewheel repair --add-path=%USERPROFILE%\\Downloads\\fftw-dll64 -w {dest_dir} {wheel}"
174175
# We do not support Ceres and GSL on Windows
175-
environment = { "MATURIN_PEP517_ARGS" = "--locked --no-default-features --features fftw-source" }
176+
# ADDITIONAL_CARGO_FEATURES is used to pass additional features to cargo, such as "abi3"
177+
environment = { "MATURIN_PEP517_ARGS" = "--locked --no-default-features --features fftw-source,$ADDITIONAL_CARGO_FEATURES" }
176178

177179
# Build with Intel MKL on Linux x86_64
178180
[[tool.cibuildwheel.overrides]]
179181
select = "*linux_x86_64"
180182
# We use system Ceres because it is available as a static library in our build environment
181-
environment = { "PATH" = "$PATH:$HOME/.cargo/bin", "MATURIN_PEP517_ARGS" = "--locked --no-default-features --features ceres-system,fftw-mkl,gsl" }
183+
# ADDITIONAL_CARGO_FEATURES is used to pass additional features to cargo, such as "abi3"
184+
environment = { "PATH" = "$PATH:$HOME/.cargo/bin", "MATURIN_PEP517_ARGS" = "--locked --no-default-features --features ceres-system,fftw-mkl,gsl,$ADDITIONAL_CARGO_FEATURES" }
182185

183186
# Test
184187
# We skip benchmark tests, because it requires feets and its transitive

0 commit comments

Comments
 (0)