[next] Wheel build fixes: manylinux1, trigger upload on release, Linux AArch64... (#2444)

* Add AArch64 linux build again.

* Enable package build also for PRs and pushes.

* Fix: don't append python version to injected platform name.

* Add musllinux build to wheel checking script

* Trigger wheel upload only on published full-releases.

* Remove duplicate workflow file

* Ensure all artifacts are moved to the same directory 'dist'

* Enable verbose twine upload.

* Add step to show downloaded artifacts for debugging.
This commit is contained in:
Rot127 2024-08-19 08:33:08 +00:00 committed by GitHub
parent 7149ec8dca
commit 42d3acf5ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 92 deletions

View File

@ -1,6 +1,6 @@
name: RELEASE BUILD - PyPI 📦 Distribution
on: [release, workflow_dispatch]
on: [push, pull_request, release, workflow_dispatch]
jobs:
build_wheels:
@ -26,7 +26,7 @@ jobs:
uses: pypa/cibuildwheel@v2.20.0
env:
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CIBW_ARCHS_LINUX: "x86_64 i686" # ppc64le s390x really slow
CIBW_ARCHS_LINUX: "x86_64 i686 aarch64" # ppc64le s390x really slow
CIBW_ARCHS_WINDOWS: "AMD64" # ARM64 Seems ARM64 will rebuild amd64 wheel for unknow reason.
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*"
CIBW_SKIP: ""
@ -69,17 +69,22 @@ jobs:
publish:
needs: [build_wheels]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
if: github.event_name == 'release' && github.event.prerelease == false && github.event.action == 'published'
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist
- name: Show downloaded artifacts
run: ls -laR dist
- name: Publish distribution 📦 to PyPI
if: ${{ success() }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
user: __token__
password: ${{ secrets.pypi_pass }}

View File

@ -1,85 +0,0 @@
name: PyPI 📦 Distribution
on: [push, pull_request]
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
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.16.5
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: "cp38-macosx* cp310-macosx* cp312-macosx* \
cp38-win* cp310-win_amd64 cp312-win_amd64 \
cp38-manylinux* cp310-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
with:
fetch-depth: 0 # Optional, use if you use setuptools_scm
submodules: true # Optional, use if you have submodules
- name: Build SDist
run: |
cd bindings/python
pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
path: bindings/python/dist/*.tar.gz
publish:
needs: [build_wheels]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
# - name: Publish distribution 📦 to test PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.test_pypi_pass }}
# repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: ${{ success() }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_pass }}

View File

@ -203,12 +203,19 @@ except ImportError:
print("Proper 'develop' support unavailable.")
if 'bdist_wheel' in sys.argv and '--plat-name' not in sys.argv:
# Inject the platform identifier into argv.
# Platform tags are described here:
# https://packaging.python.org/en/latest/specifications/platform-compatibility-tags
#
# I couldn't really find out in time why we need to inject the platform here?
# The cibuildwheel doesn't need it for the Windows job. But for Mac and Linux.
# This here is very dirty and will maybe break in the future.
# Sorry if this is the case and you read this.
# See: https://github.com/capstone-engine/capstone/issues/2445
idx = sys.argv.index('bdist_wheel') + 1
sys.argv.insert(idx, '--plat-name')
name = get_platform()
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))
sys.argv.insert(idx + 1, name.replace('.', '_').replace('-', '_'))
setup(
provides=['capstone'],

View File

@ -33,6 +33,7 @@ archs = {
filename = {
"macosx": "libcapstone.dylib",
"manylinux": "libcapstone.so",
"musllinux": "libcapstone.so",
"win": "capstone.dll",
}
@ -45,7 +46,7 @@ for root, dir, files in os.walk(sys.argv[1]):
continue
wheel_seen = True
target = re.search(r"py3-none-(.+).whl", f"{f}").group(1)
platform = re.search("^(win|manylinux|macosx)", target).group(1)
platform = re.search("^(win|manylinux|musllinux|macosx)", target).group(1)
arch = re.search(
"(universal2|x86_64|arm64|aarch64|i686|win32|amd64)$", target