Refactor Python workflow

This commit is contained in:
Christian Heitman 2026-04-12 17:55:52 -03:00
parent 0f8b2a3bf4
commit 0a99dfa3a7
No known key found for this signature in database
GPG key ID: 0417A8664956113B

View file

@ -1,279 +1,167 @@
# name: Build Python Package
name: Build Python Package
# on: [push, pull_request, workflow_dispatch]
on: [push, pull_request, workflow_dispatch]
# env:
# package-version: '1.0.0rc4'
env:
package-version: '1.0.0rc4'
# jobs:
# build-linux:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout Triton repository
uses: actions/checkout@v6
# - name: Create Docker image
# run: bash ./src/scripts/docker/build-docker-image.sh
- name: Create Docker image
run: bash ./src/scripts/docker/build-docker-image.sh
# - name: Install LLVM and Clang
# uses: KyleMayes/install-llvm-action@v2
# with:
# version: "14.0"
# directory: ${{ runner.temp }}/llvm
- name: Install LLVM
uses: KyleMayes/install-llvm-action@v2
with:
version: "14"
directory: ${{ runner.temp }}/llvm
# - name: Build Wheel packages
# run: |
# docker run \
# --rm \
# --volume $GITHUB_WORKSPACE:/src \
# --volume ${{env.LLVM_PATH}}:/llvm \
# build-triton-linux-x86_64 bash /src/src/scripts/docker/build-wheel-linux.sh
- name: Build Wheel packages
run: |
docker run \
--rm \
--volume $GITHUB_WORKSPACE:/src \
--volume ${{ env.LLVM_PATH }}:/llvm \
build-triton-linux-x86_64 bash /src/src/scripts/docker/build-wheel-linux.sh
# - name: Upload Wheel packages (Python 3.9)
# uses: actions/upload-artifact@v4
# with:
# name: triton_library-${{ env.package-version }}-cp39-cp39-manylinux_2_34_x86_64.whl
# path: wheelhouse/manylinux_2_34_x86_64/triton_library-${{ env.package-version }}-cp39-cp39-manylinux_2_34_x86_64.whl
# if-no-files-found: warn
- name: Upload Wheel packages
uses: actions/upload-artifact@v7
with:
name: triton_library-${{ env.package-version }}-manylinux_2_34_x86_64
path: wheelhouse/manylinux_2_34_x86_64/*.whl
if-no-files-found: warn
# - name: Upload Wheel packages (Python 3.10)
# uses: actions/upload-artifact@v4
# with:
# name: triton_library-${{ env.package-version }}-cp310-cp310-manylinux_2_34_x86_64.whl
# path: wheelhouse/manylinux_2_34_x86_64/triton_library-${{ env.package-version }}-cp310-cp310-manylinux_2_34_x86_64.whl
# if-no-files-found: warn
build-windows:
runs-on: windows-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
include:
- python-version: 3.9
pycp: cp39-cp39
pylib: python39.lib
- python-version: 3.10
pycp: cp310-cp310
pylib: python310.lib
- python-version: 3.11
pycp: cp311-cp311
pylib: python311.lib
- python-version: 3.12
pycp: cp312-cp312
pylib: python312.lib
- python-version: 3.13
pycp: cp313-cp313
pylib: python313.lib
- python-version: 3.14
pycp: cp314-cp314
pylib: python314.lib
steps:
- name: Checkout Triton repository
uses: actions/checkout@v6
# - name: Upload Wheel packages (Python 3.11)
# uses: actions/upload-artifact@v4
# with:
# name: triton_library-${{ env.package-version }}-cp311-cp311-manylinux_2_34_x86_64.whl
# path: wheelhouse/manylinux_2_34_x86_64/triton_library-${{ env.package-version }}-cp311-cp311-manylinux_2_34_x86_64.whl
# if-no-files-found: warn
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
# - name: Upload Wheel packages (Python 3.12)
# uses: actions/upload-artifact@v4
# with:
# name: triton_library-${{ env.package-version }}-cp312-cp312-manylinux_2_34_x86_64.whl
# path: wheelhouse/manylinux_2_34_x86_64/triton_library-${{ env.package-version }}-cp312-cp312-manylinux_2_34_x86_64.whl
# if-no-files-found: warn
- name: Install Triton dependencies
uses: ./.github/actions/install-triton-deps/windows
with:
python-version: ${{ matrix.python-version }}
# - name: Upload Wheel packages (Python 3.13)
# uses: actions/upload-artifact@v4
# with:
# name: triton_library-${{ env.package-version }}-cp313-cp313-manylinux_2_34_x86_64.whl
# path: wheelhouse/manylinux_2_34_x86_64/triton_library-${{ env.package-version }}-cp313-cp313-manylinux_2_34_x86_64.whl
# if-no-files-found: warn
- name: Build Triton Python package
run: |
python -m build --wheel --outdir ${{ github.workspace }}\wheelhouse\windows_x86_64_tmp
env:
PYTHON_VERSION: ${{ matrix.python-version }}
PYTHON_INCLUDE_DIRS: ${{ env.pythonLocation }}\include
PYTHON_LIBRARY: ${{ env.pythonLocation }}\libs\${{ matrix.pylib }}
Z3_INCLUDE_DIRS: ${{ env.Z3_INCLUDE_DIRS }}
Z3_LIBRARIES: ${{ env.Z3_LIBRARIES }}
CAPSTONE_INCLUDE_DIRS: ${{ env.CAPSTONE_INCLUDE_DIRS }}
CAPSTONE_LIBRARIES: ${{ env.CAPSTONE_LIBRARIES }}
# - name: Upload Wheel packages (Python 3.14)
# uses: actions/upload-artifact@v4
# with:
# name: triton_library-${{ env.package-version }}-cp314-cp314-manylinux_2_34_x86_64.whl
# path: wheelhouse/manylinux_2_34_x86_64/triton_library-${{ env.package-version }}-cp314-cp314-manylinux_2_34_x86_64.whl
# if-no-files-found: warn
- name: Repair Wheel packages
run: |
python -m pip install delvewheel
delvewheel repair `
--add-path ${{ env.Z3_BIN_DIR }} `
--add-path ${{ env.CAPSTONE_BIN_DIR }} `
--wheel-dir ${{ github.workspace }}\wheelhouse\windows_x86_64 -v `
${{ github.workspace }}\wheelhouse\windows_x86_64_tmp\triton_library-${{ env.package-version }}-${{ matrix.pycp }}-win_amd64.whl
# build-windows:
# runs-on: windows-latest
# strategy:
# matrix:
# python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
# include:
# - python-version: 3.9
# pycp: cp39-cp39
# pylib: python39.lib
# - python-version: 3.10
# pycp: cp310-cp310
# pylib: python310.lib
# - python-version: 3.11
# pycp: cp311-cp311
# pylib: python311.lib
# - python-version: 3.12
# pycp: cp312-cp312
# pylib: python312.lib
# - python-version: 3.13
# pycp: cp313-cp313
# pylib: python313.lib
# - python-version: 3.14
# pycp: cp314-cp314
# pylib: python314.lib
# steps:
# - name: Checkout
# uses: actions/checkout@v4
- name: Upload Wheel packages
uses: actions/upload-artifact@v7
with:
name: triton_library-${{ env.package-version }}-${{ matrix.pycp }}-win_amd64.whl
path: ${{ github.workspace }}\wheelhouse\windows_x86_64\triton_library-${{ env.package-version }}-${{ matrix.pycp }}-win_amd64.whl
if-no-files-found: warn
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}
build-macos:
runs-on: macos-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
include:
- python-version: 3.9
pycp: cp39-cp39
- python-version: 3.10
pycp: cp310-cp310
- python-version: 3.11
pycp: cp311-cp311
- python-version: 3.12
pycp: cp312-cp312
- python-version: 3.13
pycp: cp313-cp313
- python-version: 3.14
pycp: cp314-cp314
steps:
- name: Checkout Triton repository
uses: actions/checkout@v6
# - name: Get CMake
# uses: lukka/get-cmake@latest
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
# - name: Setup Windows dev environment
# uses: ilammy/msvc-dev-cmd@v1
# with:
# arch: 'x64'
- name: Install Triton dependencies
uses: ./.github/actions/install-triton-deps/macos
with:
python-version: ${{ matrix.python-version }}
# - name: Upgrade pip version
# run: |
# python -m pip install -U pip
- name: Build wheel package
run: |
python -m build --wheel --outdir wheelhouse/default_arm64
env:
Z3_INTERFACE: ON
Z3_INCLUDE_DIRS: ${{ env.Z3_INCLUDE_DIRS }}
Z3_LIBRARIES: ${{ env.Z3_LIBRARIES }}
BITWUZLA_INTERFACE: ON
BITWUZLA_INCLUDE_DIRS: ${{ env.BITWUZLA_INCLUDE_DIRS }}
BITWUZLA_LIBRARIES: ${{ env.BITWUZLA_LIBRARIES }}
LLVM_INTERFACE: ON
CMAKE_PREFIX_PATH: ${{ env.LLVM_PATH }}
BOOST_INTERFACE: OFF
MACOSX_DEPLOYMENT_TARGET: "15.0"
# - name: Install build package
# run: |
# python -m pip install build
- name: Test wheel package
run: |
pip install wheelhouse/default_arm64/triton_library-${{ env.package-version }}-${{ matrix.pycp }}-macosx_15_0_universal2.whl
pip install capstone lief unicorn z3-solver
python -c "import triton; print('triton imported successfully')"
cd ${{ github.workspace }}/src/testers
python -m unittest discover -b -v unittests
env:
DYLD_LIBRARY_PATH: ${{ env.DYLD_LIBRARY_PATH }}:/opt/homebrew/lib:/usr/local/lib
# - name: Download and build Z3
# run: |
# wget -UseBasicParsing https://github.com/Z3Prover/z3/releases/download/z3-4.12.2/z3-4.12.2-x64-win.zip -O z3-4.12.2-x64-win.zip
# tar -xf z3-4.12.2-x64-win.zip
# shell: powershell
# - name: Download and build Capstone
# run: |
# wget -UseBasicParsing https://github.com/capstone-engine/capstone/archive/refs/tags/5.0.3.zip -O capstone-5.0.3.zip
# tar -xf capstone-5.0.3.zip
# mkdir -p capstone-5.0.3/build
# cd capstone-5.0.3/build
# ../nmake.bat
# shell: powershell
# - name: Build Triton Python package
# run: python -m build --wheel --outdir ${{ github.workspace }}\wheelhouse\windows_x86_64_tmp
# env:
# PYTHON_VERSION: ${{ matrix.python-version }}
# PYTHON_INCLUDE_DIRS: ${{ env.pythonLocation }}\include
# PYTHON_LIBRARY: ${{ env.pythonLocation }}\libs\${{ matrix.pylib }}
# Z3_INCLUDE_DIRS: ${{ github.workspace }}\z3-4.12.2-x64-win\include
# Z3_LIBRARIES: ${{ github.workspace }}\z3-4.12.2-x64-win\bin\libz3.lib
# CAPSTONE_INCLUDE_DIRS: ${{ github.workspace }}\capstone-5.0.3\include
# CAPSTONE_LIBRARIES: ${{ github.workspace }}\capstone-5.0.3\build\capstone.lib
# - name: Repair wheel package
# run: |
# python -m pip install delvewheel
# delvewheel repair --add-path ${{ github.workspace }}\z3-4.12.2-x64-win\bin --wheel-dir ${{ github.workspace }}\wheelhouse\windows_x86_64 -v ${{ github.workspace }}\wheelhouse\windows_x86_64_tmp\triton_library-${{ env.package-version }}-${{ matrix.pycp }}-win_amd64.whl
# - name: Upload
# uses: actions/upload-artifact@v4
# with:
# name: triton_library-${{ env.package-version }}-${{ matrix.pycp }}-win_amd64.whl
# path: ${{ github.workspace }}\wheelhouse\windows_x86_64\triton_library-${{ env.package-version }}-${{ matrix.pycp }}-win_amd64.whl
# if-no-files-found: warn
# # NOTE Temporarily disabled until issues with macos-14 get resolved.
# # build-macos:
# # # macos-13 = x86
# # # macos-14 = arm (M1)
# # runs-on: macos-12
# # strategy:
# # matrix:
# # python-version: ['3.8', '3.9', '3.10']
# # include:
# # - python-version: 3.8
# # pycp: cp38-cp38
# # - python-version: 3.9
# # pycp: cp39-cp39
# # - python-version: 3.10
# # pycp: cp310-cp310
# # # - python-version: 3.11
# # # pycp: cp311-cp311
# # # - python-version: 3.12
# # # pycp: cp312-cp312
# # steps:
# # - name: Checkout
# # uses: actions/checkout@v4
# # - name: Set up Python ${{ matrix.python-version }}
# # uses: actions/setup-python@v5
# # with:
# # python-version: ${{ matrix.python-version }}
# # - name: Install LLVM and Clang
# # uses: KyleMayes/install-llvm-action@v2
# # with:
# # version: "14.0"
# # directory: ${{ runner.temp }}/llvm
# # - name: Upgrade pip version
# # run: |
# # sudo python -m pip install -U pip
# # - name: Install build package
# # run: |
# # sudo python -m pip install build
# # - name: Install Meson
# # run: |
# # python -m pip install meson
# # - name: Install Bitwuzla
# # run: |
# # git clone https://github.com/bitwuzla/bitwuzla.git
# # cd bitwuzla
# # git checkout -b 0.4.0 0.4.0
# # python ./configure.py --shared --prefix $(pwd)/install
# # cd build
# # sudo ninja install
# # - name: Download Z3
# # run: |
# # wget -q https://github.com/Z3Prover/z3/releases/download/z3-4.12.2/z3-4.12.2-x64-osx-10.16.zip -O z3-4.12.2-x64-osx-10.16.zip
# # unzip z3-4.12.2-x64-osx-10.16.zip
# # - name: Install Capstone
# # run: |
# # wget -q https://github.com/capstone-engine/capstone/archive/refs/tags/5.0.1.tar.gz -O capstone-5.0.1.tar.gz
# # tar xf capstone-5.0.1.tar.gz
# # cd ./capstone-5.0.1
# # ./make.sh
# # sudo make install
# # - name: Build Triton Python package
# # run: python -m build --wheel --outdir wheelhouse/default_x86_64
# # env:
# # Z3_INTERFACE: On
# # Z3_INCLUDE_DIRS: ${{ github.workspace }}/z3-4.12.2-x64-osx-10.16/include
# # Z3_LIBRARIES: ${{ github.workspace }}/z3-4.12.2-x64-osx-10.16/bin/libz3.a
# # BITWUZLA_INTERFACE: On
# # BITWUZLA_INCLUDE_DIRS: ${{ github.workspace }}/bitwuzla/install/include
# # BITWUZLA_LIBRARIES: ${{ github.workspace }}/bitwuzla/install/lib/libbitwuzla.dylib
# # CAPSTONE_INCLUDE_DIRS: /usr/local/include
# # CAPSTONE_LIBRARIES: /usr/local/lib/libcapstone.a
# # LLVM_INTERFACE: On
# # CMAKE_PREFIX_PATH: ${{env.LLVM_PATH}}
# # BOOST_INTERFACE: Off
# # - name: Repair wheel package
# # run: |
# # pip install delocate==0.10.4
# # python ${{ github.workspace }}/src/scripts/macos/delocate-wheel-custom.py \
# # --verbose \
# # --wheel-dir wheelhouse/repaired_x86_64 \
# # ${{ github.workspace }}/wheelhouse/default_x86_64/triton_library-${{ env.package-version }}-${{ matrix.pycp }}-macosx_12_0_x86_64.whl
# # - name: Test wheel package
# # run: |
# # pip install virtualenv
# # virtualenv test-venv
# # source test-venv/bin/activate
# # pip install ${{ github.workspace }}/wheelhouse/repaired_x86_64/triton_library-${{ env.package-version }}-${{ matrix.pycp }}-macosx_12_0_x86_64.whl
# # python -c "import triton"
# # pip install capstone
# # pip install lief
# # pip install unicorn==2.0.0
# # pip install z3-solver==4.12.2
# # cd ${{ github.workspace }}/src/testers
# # python -m unittest discover -b -v unittests
# # deactivate
# # - name: Upload wheel package
# # uses: actions/upload-artifact@v4
# # with:
# # name: triton_library-${{ env.package-version }}-${{ matrix.pycp }}-macosx_12_0_x86_64.whl
# # path: ${{ github.workspace }}/wheelhouse/repaired_x86_64/triton_library-${{ env.package-version }}-${{ matrix.pycp }}-macosx_12_0_x86_64.whl
# # if-no-files-found: warn
- name: Upload wheel package
uses: actions/upload-artifact@v7
with:
name: triton_library-${{ env.package-version }}-${{ matrix.pycp }}-macosx_15_0_universal2.whl
path: wheelhouse/default_arm64/triton_library-${{ env.package-version }}-${{ matrix.pycp }}-macosx_15_0_universal2.whl
if-no-files-found: warn