mirror of
https://github.com/capstone-engine/capstone.git
synced 2024-11-23 05:29:53 +00:00
ci: use cibuildwheel for python wheels (#2099)
* ci: use cibuildwheel for python wheels * fix several issues * fix setup.py * fix issue * Compatible with python2 * fix str * trigger ci --------- Co-authored-by: kabeor <kabeor00@gmail.com>
This commit is contained in:
parent
c6c07e9731
commit
d3a0e7ff99
97
.github/workflows/python-publish.yml
vendored
97
.github/workflows/python-publish.yml
vendored
@ -1,70 +1,65 @@
|
||||
name: PyPI 📦 Distribution
|
||||
|
||||
on:
|
||||
push:
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
build_wheels:
|
||||
name: Build wheels on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
platform: [x32, x64]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up MSVC x64
|
||||
if: matrix.os == 'windows-latest'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Set up QEMU
|
||||
if: runner.os == 'Linux'
|
||||
uses: docker/setup-qemu-action@v2
|
||||
with:
|
||||
platforms: all
|
||||
|
||||
- name: Build wheels
|
||||
uses: pypa/cibuildwheel@v2.14.1
|
||||
env:
|
||||
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
|
||||
CIBW_ARCHS_LINUX: "x86_64 i686 aarch64" # ppc64le s390x really slow
|
||||
CIBW_ARCHS_WINDOWS: "AMD64 x86" # ARM64 Seems ARM64 will rebuild amd64 wheel for unknow reason.
|
||||
CIBW_BUILD: "cp36-macosx* cp39-macosx* cp312-macosx* \
|
||||
cp36-win* cp39-win_amd64 cp312-win_amd64 \
|
||||
cp36-manylinux* cp39-manylinux_x86_64 \
|
||||
cp312-manylinux_x86_64 cp312-manylinux_aarch64"
|
||||
CIBW_SKIP: ""
|
||||
with:
|
||||
package-dir: bindings/python
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
path: ./wheelhouse/*.whl
|
||||
|
||||
make_sdist:
|
||||
name: Make SDist
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
# Python is included in manylinux
|
||||
if: matrix.os != 'ubuntu-latest'
|
||||
with:
|
||||
python-version: '3.x'
|
||||
fetch-depth: 0 # Optional, use if you use setuptools_scm
|
||||
submodules: true # Optional, use if you have submodules
|
||||
|
||||
- name: Set up MSVC x86
|
||||
if: matrix.os == 'windows-latest' && matrix.platform == 'x32'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: x86
|
||||
|
||||
- name: Set up MSVC x64
|
||||
if: matrix.os == 'windows-latest' && matrix.platform == 'x64'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Install Python dependencies
|
||||
if: matrix.os != 'ubuntu-latest'
|
||||
run: pip install setuptools wheel
|
||||
|
||||
- name: Build distribution 📦 (Windows)
|
||||
if: matrix.os == 'windows-latest'
|
||||
shell: pwsh
|
||||
- name: Build SDist
|
||||
run: |
|
||||
cd bindings/python && python setup.py build -p win32 bdist_wheel -p win32
|
||||
cd bindings/python
|
||||
pipx run build --sdist
|
||||
|
||||
- name: Build distribution 📦
|
||||
shell: bash
|
||||
run: |
|
||||
if [ ${{ matrix.platform }} == 'x32' ] && [ ${{ matrix.os }} == 'ubuntu-latest' ]; then
|
||||
docker run --rm -v `pwd`/:/work dockcross/manylinux2014-x86 > ./dockcross
|
||||
chmod +x ./dockcross
|
||||
chmod +x bindings/python/build_wheel.sh
|
||||
./dockcross bindings/python/build_wheel.sh
|
||||
elif [ ${{ matrix.platform }} == 'x64' ] && [ ${{ matrix.os }} == 'ubuntu-latest' ]; then
|
||||
docker run --rm -v `pwd`/:/work dockcross/manylinux_2_28-x64 > ./dockcross
|
||||
chmod +x ./dockcross
|
||||
chmod +x bindings/python/build_wheel.sh
|
||||
./dockcross bindings/python/build_wheel.sh
|
||||
elif [ ${{ matrix.platform }} == 'x32' ] && [ ${{ matrix.os }} == 'macos-latest' ]; then
|
||||
cd bindings/python && python setup.py sdist
|
||||
else
|
||||
cd bindings/python && python setup.py bdist_wheel
|
||||
fi
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
path: ${{ github.workspace }}/bindings/python/dist/*
|
||||
path: bindings/python/dist/*.tar.gz
|
||||
|
||||
publish:
|
||||
needs: [build]
|
||||
needs: [build_wheels]
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags')
|
||||
permissions:
|
||||
@ -87,4 +82,4 @@ jobs:
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.pypi_pass }}
|
||||
password: ${{ secrets.pypi_pass }}
|
@ -201,22 +201,9 @@ if 'bdist_wheel' in sys.argv and '--plat-name' not in sys.argv:
|
||||
idx = sys.argv.index('bdist_wheel') + 1
|
||||
sys.argv.insert(idx, '--plat-name')
|
||||
name = get_platform()
|
||||
if 'linux' in name:
|
||||
# linux_* platform tags are disallowed because the python ecosystem is fubar
|
||||
# linux builds should be built in the centos 5 vm for maximum compatibility
|
||||
# see https://github.com/pypa/manylinux
|
||||
# see also https://github.com/angr/angr-dev/blob/master/bdist.sh
|
||||
machine = platform.machine()
|
||||
if machine == "i686":
|
||||
# manylinux2014 is the last which supports x86 in dockercross
|
||||
sys.argv.insert(idx + 1, 'manylinux2014-x86')
|
||||
elif machine == "x86_64":
|
||||
sys.argv.insert(idx + 1, 'manylinux_2_28-x64')
|
||||
else:
|
||||
raise ValueError("Unknown machine: " + machine)
|
||||
else:
|
||||
# https://www.python.org/dev/peps/pep-0425/
|
||||
sys.argv.insert(idx + 1, name.replace('.', '_').replace('-', '_'))
|
||||
pyversion = platform.python_version()
|
||||
major_version, minor_version = map(int, pyversion.split('.')[:2])
|
||||
sys.argv.insert(idx + 1, name.replace('.', '_').replace('-', '_') + "_" + str(major_version) + str(minor_version))
|
||||
|
||||
setup(
|
||||
provides=['capstone'],
|
||||
|
Loading…
Reference in New Issue
Block a user