-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Python package building rework #2538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e0342f3
- Refactored setup.py to remove hacks regarding packaging of wheels f…
Antelox 62bf812
Added SPDX headers to the setup.py
Antelox ac94040
- cstest_py: Fixed positional argument since it doesn't accept a `req…
Antelox 7f9054d
GitHub Actions: Run python 3.8 (lowest) and 3.13 (current highest) fo…
Antelox 1a40846
GitHub Action:
Antelox 94d9a50
GitHub Action: Added run_tests.py script to run all tests during CI w…
Antelox 80e12b5
- Added SPDX headers to the run_tests.py script and to the build-whee…
Antelox 1c9dc46
GitHub Action:
Antelox 4f60f09
Python bindings: Refreshed the list of files needed to be copied for …
Antelox 6b501d2
GitHub Action: Commented out arch:x86 matrix elements
Antelox 164aafb
GitHub Action: Run qemu step only if non-native Linux runner
Antelox 7de6c9a
GitHub Action: Minor fixes
Antelox 82fe006
Python bindings: Added missing .in pattern when collecting src files …
Antelox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,279 @@ | ||
| # SPDX-FileCopyrightText: 2024 Antelox <anteloxrce@gmail.com> | ||
| # SPDX-License-Identifier: BSD-3 | ||
|
|
||
| name: Build and publish wheels with cibuildwheel | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| debugMode: | ||
| description: 'Debug Mode' | ||
| required: false | ||
| default: '' | ||
| type: choice | ||
| options: | ||
| - '0' | ||
| - '1' | ||
|
|
||
| push: | ||
| paths-ignore: | ||
| - ".gitignore" | ||
| - "CREDITS.TXT" | ||
| - "ChangeLog" | ||
| - "README.md" | ||
| - "docs/**" | ||
| pull_request: | ||
|
|
||
| env: | ||
| # Enable DEBUG flag either according to the tag release or manual override | ||
| CAPSTONE_DEBUG: ${{ inputs.debugMode != '' && inputs.debugMode || startsWith(github.ref, 'refs/tags') && '0' || '1' }} | ||
|
|
||
| jobs: | ||
| # job to be executed for every push - testing purpose | ||
| build_wheels_always: | ||
| name: Building on ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.cibw_build }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| # NOTE: Making this to parallelize and speed up workflow | ||
| # i686 - manylinux | ||
| # - { os: ubuntu-latest, arch: i686, cibw_build: 'cp38-manylinux* cp313-manylinux*', cibw_skip: '' } | ||
| # i686 - musllinux | ||
| # - { os: ubuntu-latest, arch: i686, cibw_build: 'cp38-musllinux* cp313-musllinux*', cibw_skip: '' } | ||
| # x86_64 - manylinux | ||
| - { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp38-manylinux* cp313-manylinux*', cibw_skip: '' } | ||
| # x86_64 - musllinux | ||
| # - { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp38-musllinux* cp313-musllinux*', cibw_skip: '' } | ||
| # aarch64 - manylinux | ||
| # - { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp38-manylinux* cp313-manylinux*', cibw_skip: '' } | ||
| # aarch64 - musllinux | ||
| # - { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp38-musllinux* cp313-musllinux*', cibw_skip: '' } | ||
| # macos - x86_64 | ||
| - { os: macos-13, arch: x86_64, cibw_build: 'cp38* cp313*', cibw_skip: '' } | ||
| # macos - arm64 | ||
| # - { os: macos-latest, arch: arm64, cibw_build: 'cp38* cp313*', cibw_skip: '' } | ||
| # - { os: macos-latest, arch: universal2, cibw_build: 'cp38* cp313*', cibw_skip: '' } | ||
| # windows - x86_64 | ||
| - { os: windows-latest, arch: AMD64, cibw_build: 'cp38* cp313*', cibw_skip: '' } | ||
| # windows - amd64 | ||
| # - { os: windows-latest, arch: x86, cibw_build: 'cp38* cp313*', cibw_skip: '' } | ||
| # windows - arm64 | ||
| # - { os: windows-latest, arch: ARM64, cibw_build: 'cp39* cp313*', cibw_skip: '' } | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| # https://github.com/actions/upload-artifact/issues/22 | ||
| - name: Prepare a unique name for Artifacts | ||
| shell: bash | ||
| run: | | ||
| # replace not-allowed chars with dash | ||
| name="cibw-wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.cibw_build }}" | ||
| name=$(echo -n "$name" | sed -e 's/[ \t:\/\\"<>|*?]/-/g' -e 's/--*/-/g' | sed -e 's/\-$//') | ||
| echo "ARTIFACT_NAME=$name" >> $GITHUB_ENV | ||
|
|
||
| # https://cibuildwheel.pypa.io/en/stable/faq/#macos-building-cpython-38-wheels-on-arm64 | ||
| - uses: actions/setup-python@v5 | ||
| if: runner.os == 'macOS' && runner.arch == 'ARM64' | ||
| with: | ||
| python-version: 3.8 | ||
|
|
||
| - name: '🛠️ Win MSVC 32 dev cmd setup' | ||
| if: runner.os == 'Windows' && matrix.arch == 'x86' | ||
| uses: ilammy/msvc-dev-cmd@v1 | ||
| with: | ||
| arch: x86 | ||
|
|
||
| - name: '🛠️ Win MSVC 64 dev cmd setup' | ||
| if: runner.os == 'Windows' && matrix.arch == 'AMD64' | ||
| uses: ilammy/msvc-dev-cmd@v1 | ||
| with: | ||
| arch: x64 | ||
|
|
||
| - name: '🛠️ Win MSVC ARM64 dev cmd setup' | ||
| if: runner.os == 'Windows' && matrix.arch == 'ARM64' | ||
| uses: ilammy/msvc-dev-cmd@v1 | ||
| with: | ||
| arch: amd64_arm64 | ||
|
|
||
| - name: '🛠️ Set up QEMU' | ||
| if: runner.os == 'Linux' && matrix.arch != 'x86_64' | ||
| uses: docker/setup-qemu-action@v3 | ||
|
|
||
| - name: '🚧 cibuildwheel run' | ||
| uses: pypa/cibuildwheel@v2.21.3 | ||
| env: | ||
| CIBW_BUILD_FRONTEND: build | ||
| CIBW_BUILD: ${{ matrix.cibw_build }} | ||
| CIBW_SKIP: ${{ matrix.cibw_skip }} | ||
| CIBW_ARCHS: ${{ matrix.arch }} | ||
| CIBW_ENVIRONMENT: DEBUG=${{ env.CAPSTONE_DEBUG }} | ||
| CIBW_ENVIRONMENT_PASS_LINUX: DEBUG | ||
| # https://cibuildwheel.pypa.io/en/stable/faq/#windows-arm64 | ||
| # https://github.com/pypa/cibuildwheel/pull/1169 | ||
| CIBW_TEST_SKIP: "*-win_arm64 cp38-macosx_*:arm64" | ||
| CIBW_TEST_COMMAND: > | ||
| python -m pip install {package}/cstest_py && | ||
| python {project}/suite/run_tests.py | ||
| with: | ||
| package-dir: bindings/python | ||
| output-dir: wheelhouse | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ env.ARTIFACT_NAME }} | ||
| path: ./wheelhouse/*.whl | ||
|
|
||
| # To be executed only in case of a tag release | ||
| build_wheels_all: | ||
| name: Building on ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.cibw_build }} | ||
| runs-on: ${{ matrix.os }} | ||
| if: startsWith(github.ref, 'refs/tags') | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| # NOTE: Making this to parallelize and speed up workflow | ||
| # i686 - manylinux | ||
| # - { os: ubuntu-latest, arch: i686, cibw_build: 'cp39-manylinux*', cibw_skip: '' } | ||
| # - { os: ubuntu-latest, arch: i686, cibw_build: 'cp310-manylinux*', cibw_skip: '' } | ||
| # - { os: ubuntu-latest, arch: i686, cibw_build: 'cp311-manylinux*', cibw_skip: '' } | ||
| # - { os: ubuntu-latest, arch: i686, cibw_build: 'cp312-manylinux*', cibw_skip: '' } | ||
| # i686 - musllinux | ||
| # - { os: ubuntu-latest, arch: i686, cibw_build: 'cp39-musllinux*', cibw_skip: '' } | ||
| # - { os: ubuntu-latest, arch: i686, cibw_build: 'cp310-musllinux*', cibw_skip: '' } | ||
| # - { os: ubuntu-latest, arch: i686, cibw_build: 'cp311-musllinux*', cibw_skip: '' } | ||
| # - { os: ubuntu-latest, arch: i686, cibw_build: 'cp312-musllinux*', cibw_skip: '' } | ||
| # x86_64 - manylinux | ||
| - { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp39-manylinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp310-manylinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp311-manylinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp312-manylinux*', cibw_skip: '' } | ||
| # x86_64 - musllinux | ||
| - { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp39-musllinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp310-musllinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp311-musllinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp312-musllinux*', cibw_skip: '' } | ||
| # aarch64 - manylinux | ||
| - { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp39-manylinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp310-manylinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp311-manylinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp312-manylinux*', cibw_skip: '' } | ||
| # aarch64 - musllinux | ||
| - { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp39-musllinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp310-musllinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp311-musllinux*', cibw_skip: '' } | ||
| - { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp312-musllinux*', cibw_skip: '' } | ||
| # macos - x86_64 | ||
| - { os: macos-13, arch: x86_64, cibw_build: 'cp*', cibw_skip: '*36* *37* *38* *313*' } | ||
| # macos - arm64 | ||
| - { os: macos-latest, arch: arm64, cibw_build: 'cp*', cibw_skip: '*36* *37* *38* *313*' } | ||
|
Antelox marked this conversation as resolved.
|
||
| - { os: macos-latest, arch: universal2, cibw_build: 'cp*', cibw_skip: '*36* *37* *38* *39* *313*' } | ||
| # windows - amd64 | ||
| - { os: windows-latest, arch: AMD64, cibw_build: 'cp*', cibw_skip: '*36* *37* *38* *313*' } | ||
| # windows - x86 | ||
| # - { os: windows-latest, arch: x86, cibw_build: 'cp*', cibw_skip: '*36* *37* *38* *313*' } | ||
| # windows - arm64 | ||
| - { os: windows-latest, arch: ARM64, cibw_build: 'cp*', cibw_skip: '*36* *37* *38* *39* *313*' } | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| # https://github.com/actions/upload-artifact/issues/22 | ||
| - name: Prepare a unique name for Artifacts | ||
| shell: bash | ||
| run: | | ||
| # replace not-allowed chars with dash | ||
| name="cibw-wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.cibw_build }}" | ||
| name=$(echo -n "$name" | sed -e 's/[ \t:\/\\"<>|*?]/-/g' -e 's/--*/-/g' | sed -e 's/\-$//') | ||
| echo "ARTIFACT_NAME=$name" >> $GITHUB_ENV | ||
|
|
||
| - name: '🛠️ Win MSVC 32 dev cmd setup' | ||
| if: runner.os == 'Windows' && matrix.arch == 'x86' | ||
| uses: ilammy/msvc-dev-cmd@v1 | ||
| with: | ||
| arch: x86 | ||
|
|
||
| - name: '🛠️ Win MSVC 64 dev cmd setup' | ||
| if: runner.os == 'Windows' && matrix.arch == 'AMD64' | ||
| uses: ilammy/msvc-dev-cmd@v1 | ||
| with: | ||
| arch: x64 | ||
|
|
||
| - name: '🛠️ Win MSVC ARM64 dev cmd setup' | ||
| if: runner.os == 'Windows' && matrix.arch == 'ARM64' | ||
| uses: ilammy/msvc-dev-cmd@v1 | ||
| with: | ||
| arch: amd64_arm64 | ||
|
|
||
| - name: '🛠️ Set up QEMU' | ||
| if: runner.os == 'Linux' && matrix.arch != 'x86_64' | ||
| uses: docker/setup-qemu-action@v3 | ||
|
|
||
| - name: '🚧 cibuildwheel run' | ||
| uses: pypa/cibuildwheel@v2.21.3 | ||
| env: | ||
| CIBW_BUILD_FRONTEND: build | ||
| CIBW_BUILD: ${{ matrix.cibw_build }} | ||
| CIBW_SKIP: ${{ matrix.cibw_skip }} | ||
| CIBW_ARCHS: ${{ matrix.arch }} | ||
| CIBW_ENVIRONMENT: DEBUG=${{ env.CAPSTONE_DEBUG }} | ||
| CIBW_ENVIRONMENT_PASS_LINUX: DEBUG | ||
| # https://cibuildwheel.pypa.io/en/stable/faq/#windows-arm64 | ||
| CIBW_TEST_SKIP: "*-win_arm64" | ||
| CIBW_TEST_COMMAND: > | ||
| python -m pip install {package}/cstest_py && | ||
| python {project}/suite/run_tests.py | ||
| with: | ||
| package-dir: bindings/python | ||
| output-dir: wheelhouse | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ env.ARTIFACT_NAME }} | ||
| path: ./wheelhouse/*.whl | ||
|
|
||
| make_sdist: | ||
| name: Make SDist | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| submodules: true | ||
|
|
||
| - name: Build SDist | ||
| run: | | ||
| cd bindings/python | ||
| python3 -m pip install -U pip build | ||
| python3 -m build --sdist | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: sdist-archive | ||
| path: bindings/python/dist/*.tar.gz | ||
|
|
||
| publish: | ||
| needs: [ build_wheels_always, build_wheels_all, make_sdist ] | ||
| environment: pypi | ||
| permissions: | ||
| id-token: write | ||
| runs-on: ubuntu-latest | ||
| if: startsWith(github.ref, 'refs/tags') | ||
| 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' | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| if: ${{ success() }} | ||
| with: | ||
| user: __token__ | ||
| password: ${{ secrets.pypi_pass }} | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.