Skip to content

Commit de53cf0

Browse files
Anteloxwtdcode
authored andcommitted
Python bindings: Use ABI3 wheels #2223
1 parent fd2e0e6 commit de53cf0

File tree

4 files changed

+20
-146
lines changed

4 files changed

+20
-146
lines changed

.github/workflows/build-wheels-publish.yml

Lines changed: 16 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ on:
1111
options:
1212
- '0'
1313
- '1'
14-
fullMode:
15-
description: 'Full Mode'
16-
required: false
17-
default: ''
18-
type: choice
19-
options:
20-
- '0'
21-
- '1'
2214
push:
2315
paths-ignore:
2416
- ".gitignore"
@@ -38,7 +30,7 @@ env:
3830

3931
jobs:
4032
# job to be executed for every push - testing purpose
41-
build_wheels_python38_only:
33+
build_and_test_wheels:
4234
name: Building on ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.cibw_build }}
4335
runs-on: ${{ matrix.os }}
4436
strategy:
@@ -47,21 +39,21 @@ jobs:
4739
include:
4840
# NOTE: Doing this to parallelize and speed up workflow
4941
# i686 - manylinux
50-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp38-manylinux*', cibw_skip: '' }
42+
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp*-manylinux*', cibw_skip: 'cp36*' }
5143
# i686 - musllinux
52-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp38-musllinux*', cibw_skip: '' }
44+
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp*-musllinux*', cibw_skip: 'cp36*' }
5345
# x86_64 - manylinux
54-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp38-manylinux*', cibw_skip: '' }
46+
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp*-manylinux*', cibw_skip: 'cp36*' }
5547
# x86_64 - musllinux
56-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp38-musllinux*', cibw_skip: '' }
48+
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp*-musllinux*', cibw_skip: 'cp36*' }
5749
# aarch64 - manylinux
58-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp38-manylinux*', cibw_skip: '' }
50+
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp*-manylinux*', cibw_skip: 'cp36*' }
5951
# aarch64 - musllinux
60-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp38-musllinux*', cibw_skip: '' }
61-
- { os: macos-13, arch: x86_64, cibw_build: 'cp38*', cibw_skip: '' }
62-
- { os: macos-latest, arch: arm64, cibw_build: 'cp38*', cibw_skip: '' }
63-
- { os: windows-2022, arch: AMD64, cibw_build: 'cp38*', cibw_skip: '' }
64-
- { os: windows-2022, arch: x86, cibw_build: 'cp38*', cibw_skip: '' }
52+
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp*-musllinux*', cibw_skip: 'cp36*' }
53+
- { os: macos-13, arch: x86_64, cibw_build: 'cp*', cibw_skip: 'cp36*' }
54+
- { os: macos-latest, arch: arm64, cibw_build: 'cp*', cibw_skip: 'cp36* cp37*' }
55+
- { os: windows-2022, arch: AMD64, cibw_build: 'cp*', cibw_skip: 'cp36*' }
56+
- { os: windows-2022, arch: x86, cibw_build: 'cp*', cibw_skip: 'cp36*' }
6557

6658
steps:
6759
- uses: actions/checkout@v4
@@ -113,7 +105,7 @@ jobs:
113105
uses: docker/setup-qemu-action@v3
114106

115107
- name: '🚧 cibuildwheel run'
116-
uses: pypa/cibuildwheel@v2.22.0
108+
uses: pypa/cibuildwheel@v2.23.3
117109
env:
118110
CIBW_BUILD_FRONTEND: build
119111
CIBW_BUILD: ${{ matrix.cibw_build }}
@@ -136,10 +128,10 @@ jobs:
136128
shell: bash
137129
run: |
138130
python3 -m pip install -U pip wheel
139-
python3 -m wheel tags --python-tag='py2' --abi-tag=none wheelhouse/*cp38*.whl
131+
python3 -m wheel tags --python-tag='py2' --abi-tag=none wheelhouse/*cp37*.whl
140132
141133
- uses: LizardByte/[email protected]
142-
if: (runner.os == 'Linux' && (matrix.arch == 'x86_64' || matrix.arch == 'aarch64') && matrix.cibw_build == 'cp38-manylinux*') || (runner.os == 'macOS' && matrix.arch == 'arm64') || (runner.os == 'Windows' && matrix.arch == 'AMD64')
134+
if: (runner.os == 'Linux' && (matrix.arch == 'x86_64' || matrix.arch == 'aarch64') && matrix.cibw_build == 'cp*-manylinux*') || (runner.os == 'macOS' && matrix.arch == 'arm64') || (runner.os == 'Windows' && matrix.arch == 'AMD64')
143135
with:
144136
python-version: 2.7
145137

@@ -153,7 +145,7 @@ jobs:
153145
154146
# NOTE: no python2.7 support for macos-13: https://github.com/LizardByte/setup-python-action/issues/2
155147
- name: 'Python 2.7 tests - Non-Windows'
156-
if: (runner.os == 'Linux' && (matrix.arch == 'x86_64' || matrix.arch == 'aarch64') && matrix.cibw_build == 'cp38-manylinux*') || (runner.os == 'macOS' && matrix.arch == 'arm64')
148+
if: (runner.os == 'Linux' && (matrix.arch == 'x86_64' || matrix.arch == 'aarch64') && matrix.cibw_build == 'cp*-manylinux*') || (runner.os == 'macOS' && matrix.arch == 'arm64')
157149
run: |
158150
python2 -m pip install capstone==4.0.2 wheelhouse/*py2*.whl
159151
python2 -m unittest discover tests/regress "*.py"
@@ -163,125 +155,6 @@ jobs:
163155
name: ${{ env.ARTIFACT_NAME }}
164156
path: ./wheelhouse/*.whl
165157

166-
# Job to be executed to build all wheels for all platforms/architectures/python versions only for tag release
167-
build_wheels_all_versions:
168-
name: Building on ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.cibw_build }}
169-
runs-on: ${{ matrix.os }}
170-
strategy:
171-
fail-fast: false
172-
matrix:
173-
include:
174-
# NOTE: Doing this to parallelize and speed up workflow
175-
# i686 - manylinux
176-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp37-manylinux*', cibw_skip: '' }
177-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp39-manylinux*', cibw_skip: '' }
178-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp310-manylinux*', cibw_skip: '' }
179-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp311-manylinux*', cibw_skip: '' }
180-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp312-manylinux*', cibw_skip: '' }
181-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp313-manylinux*', cibw_skip: '' }
182-
# i686 - musllinux
183-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp37-musllinux*', cibw_skip: '' }
184-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp39-musllinux*', cibw_skip: '' }
185-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp310-musllinux*', cibw_skip: '' }
186-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp311-musllinux*', cibw_skip: '' }
187-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp312-musllinux*', cibw_skip: '' }
188-
- { os: ubuntu-latest, arch: i686, cibw_build: 'cp313-musllinux*', cibw_skip: '' }
189-
# x86_64 - manylinux
190-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp37-manylinux*', cibw_skip: '' }
191-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp39-manylinux*', cibw_skip: '' }
192-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp310-manylinux*', cibw_skip: '' }
193-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp311-manylinux*', cibw_skip: '' }
194-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp312-manylinux*', cibw_skip: '' }
195-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp313-manylinux*', cibw_skip: '' }
196-
# x86_64 - musllinux
197-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp37-musllinux*', cibw_skip: '' }
198-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp39-musllinux*', cibw_skip: '' }
199-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp310-musllinux*', cibw_skip: '' }
200-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp311-musllinux*', cibw_skip: '' }
201-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp312-musllinux*', cibw_skip: '' }
202-
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp313-musllinux*', cibw_skip: '' }
203-
# aarch64 - manylinux
204-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp37-manylinux*', cibw_skip: '' }
205-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp39-manylinux*', cibw_skip: '' }
206-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp310-manylinux*', cibw_skip: '' }
207-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp311-manylinux*', cibw_skip: '' }
208-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp312-manylinux*', cibw_skip: '' }
209-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp313-manylinux*', cibw_skip: '' }
210-
# aarch64 - musllinux
211-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp37-musllinux*', cibw_skip: '' }
212-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp39-musllinux*', cibw_skip: '' }
213-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp310-musllinux*', cibw_skip: '' }
214-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp311-musllinux*', cibw_skip: '' }
215-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp312-musllinux*', cibw_skip: '' }
216-
- { os: ubuntu-24.04-arm, arch: aarch64, cibw_build: 'cp313-musllinux*', cibw_skip: '' }
217-
- { os: macos-13, arch: x86_64, cibw_build: 'cp*', cibw_skip: '*36* *38*' }
218-
- { os: macos-latest, arch: arm64, cibw_build: 'cp*', cibw_skip: '*36* *37* *38*' }
219-
- { os: windows-2022, arch: AMD64, cibw_build: 'cp*', cibw_skip: '*36* *38*' }
220-
- { os: windows-2022, arch: x86, cibw_build: 'cp*', cibw_skip: '*36* *38*' }
221-
if: ${{ inputs.fullMode == 1 || (startsWith(github.ref, 'refs/tags') && !startsWith(github.ref, 'refs/tags/v')) || contains(github.event.head_commit.message, 'CI(full)') }}
222-
steps:
223-
- uses: actions/checkout@v4
224-
with:
225-
fetch-depth: 0
226-
227-
# https://github.com/actions/upload-artifact/issues/22
228-
- name: Prepare a unique name for Artifacts
229-
shell: bash
230-
run: |
231-
# replace not-allowed chars with dash
232-
name="cibw-wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.cibw_build }}"
233-
name=$(echo -n "$name" | sed -e 's/[ \t:\/\\"<>|*?]/-/g' -e 's/--*/-/g' | sed -e 's/\-$//')
234-
echo "ARTIFACT_NAME=$name" >> $GITHUB_ENV
235-
236-
- name: "Increase pagefile to avoid OOM"
237-
if: runner.os == 'Windows'
238-
uses: al-cheb/[email protected]
239-
with:
240-
minimum-size: 8GB
241-
disk-root: "C:"
242-
243-
- name: '🛠️ Add msbuild to PATH'
244-
if: runner.os == 'Windows'
245-
uses: microsoft/setup-msbuild@v2
246-
with:
247-
vs-version: '17'
248-
249-
- name: '🛠️ Win MSVC 32 dev cmd setup'
250-
if: runner.os == 'Windows' && matrix.arch == 'x86'
251-
uses: ilammy/msvc-dev-cmd@v1
252-
with:
253-
arch: x86
254-
255-
- name: '🛠️ Win MSVC 64 dev cmd setup'
256-
if: runner.os == 'Windows' && matrix.arch == 'AMD64'
257-
uses: ilammy/msvc-dev-cmd@v1
258-
with:
259-
arch: x64
260-
261-
- name: '🛠️ Set up QEMU'
262-
if: runner.os == 'Linux' && matrix.arch == 'i686'
263-
uses: docker/setup-qemu-action@v3
264-
265-
- name: '🚧 cibuildwheel run'
266-
uses: pypa/[email protected]
267-
env:
268-
CIBW_BUILD_FRONTEND: build
269-
CIBW_BUILD: ${{ matrix.cibw_build }}
270-
CIBW_SKIP: ${{ matrix.cibw_skip }}
271-
CIBW_ARCHS: ${{ matrix.arch }}
272-
CIBW_ENVIRONMENT: DEBUG=${{ env.UNICORN_DEBUG }} GENERATORS='Visual Studio 17 2022'
273-
CIBW_ENVIRONMENT_PASS_LINUX: DEBUG
274-
CIBW_TEST_EXTRAS: test
275-
CIBW_TEST_COMMAND: 'python -m unittest discover -v {project}/tests/regress "*.py"'
276-
with:
277-
package-dir: bindings/python
278-
output-dir: wheelhouse
279-
280-
- uses: actions/upload-artifact@v4
281-
with:
282-
name: ${{ env.ARTIFACT_NAME }}
283-
path: ./wheelhouse/*.whl
284-
285158
make_sdist:
286159
name: Make SDist
287160
runs-on: ubuntu-latest
@@ -303,7 +176,7 @@ jobs:
303176
path: bindings/python/dist/*.tar.gz
304177

305178
publish:
306-
needs: [ build_wheels_python38_only, build_wheels_all_versions, make_sdist ]
179+
needs: [ build_and_test_wheels, make_sdist ]
307180
environment: pypi
308181
permissions:
309182
id-token: write

bindings/python/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ sdist3_win:
6666
python3 setup.py sdist register upload
6767

6868
clean:
69-
rm -rf src/ dist/ build/ MANIFEST
69+
rm -rf src/ dist/ build/
7070
rm -rf prebuilt/win64/unicorn.dll
7171
rm -rf prebuilt/win32/unicorn.dll
7272
rm -rf unicorn/lib unicorn/include

bindings/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools>=64", "build", "wheel", "setuptools-scm"]
2+
requires = ["setuptools>=64", "build", "setuptools-scm"]
33
build-backend = "setuptools.build_meta"
44

55
[project]

bindings/python/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,6 @@ def run(self):
148148

149149
setup(
150150
cmdclass={'build_py': CustomBuild, 'sdist': CustomSDist},
151-
has_ext_modules=lambda: True, # It's not a Pure Python wheel
151+
has_ext_modules=lambda: True, # It's not a Pure Python wheel,
152+
options={"bdist_wheel": {"py_limited_api": "cp37"}}, # to have ABI3 tagged wheel
152153
)

0 commit comments

Comments
 (0)