From 0025edd833aefef87d6f9f8736f290252e769b47 Mon Sep 17 00:00:00 2001 From: Christian Heitman Date: Fri, 18 Aug 2023 14:00:59 -0300 Subject: [PATCH 1/4] Update actions/checkout to v3 --- .github/workflows/codecov.yml | 2 +- .github/workflows/docker.yml | 2 +- .github/workflows/linux.yml | 2 +- .github/workflows/osx.yml | 2 +- .github/workflows/python.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index ae2a8b6e2..9f0eb244f 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -10,7 +10,7 @@ jobs: python-version: [3.9] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 06a308339..c703e6401 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,6 +6,6 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build the Docker image run: docker build . --file Dockerfile --tag triton-docker:$(date +%s) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index be66b9dbe..f61b429cf 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -12,7 +12,7 @@ jobs: capstone-version: ['5.0-rc2', '4.0.2'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 744b96dfe..1e830deb6 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -10,7 +10,7 @@ jobs: python-version: ['3.7', '3.8', '3.9', '3.10'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 663f3e98f..b75cced2f 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -142,7 +142,7 @@ jobs: # - python-version: 3.10 # steps: # - name: Checkout - # uses: actions/checkout@v2 + # uses: actions/checkout@v3 # - name: Set up Python ${{ matrix.python-version }} # uses: actions/setup-python@v4 From 9aac0cad371b5a469a948c52037d33ff08a203e8 Mon Sep 17 00:00:00 2001 From: Christian Heitman Date: Thu, 17 Aug 2023 15:22:51 -0300 Subject: [PATCH 2/4] Improve wheel building process --- .github/workflows/python.yml | 18 ++--- src/scripts/docker/Dockerfile | 47 +++++++++++++ src/scripts/docker/build-wheel-linux.sh | 90 +++++++++---------------- 3 files changed, 89 insertions(+), 66 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index b75cced2f..8ac18c1ab 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -19,35 +19,35 @@ jobs: run: | docker run \ --rm \ - -v $GITHUB_WORKSPACE:/src \ + --volume $GITHUB_WORKSPACE:/src \ build-triton-linux-x86_64 bash /src/src/scripts/docker/build-wheel-linux.sh - name: Upload Wheel packages (Python 3.8) uses: actions/upload-artifact@v3 with: - name: triton_library-${{ env.package-version }}-cp38-cp38-manylinux_2_24_x86_64.whl - path: wheel-final/triton_library-${{ env.package-version }}-cp38-cp38-manylinux_2_24_x86_64.whl + name: triton_library-${{ env.package-version }}-cp38-cp38-manylinux_2_28_x86_64.whl + path: wheelhouse/manylinux_2_28_x86_64/triton_library-${{ env.package-version }}-cp38-cp38-manylinux_2_28_x86_64.whl if-no-files-found: warn - name: Upload Wheel packages (Python 3.9) uses: actions/upload-artifact@v3 with: - name: triton_library-${{ env.package-version }}-cp39-cp39-manylinux_2_24_x86_64.whl - path: wheel-final/triton_library-${{ env.package-version }}-cp39-cp39-manylinux_2_24_x86_64.whl + name: triton_library-${{ env.package-version }}-cp39-cp39-manylinux_2_28_x86_64.whl + path: wheelhouse/manylinux_2_28_x86_64/triton_library-${{ env.package-version }}-cp39-cp39-manylinux_2_28_x86_64.whl if-no-files-found: warn - name: Upload Wheel packages (Python 3.10) uses: actions/upload-artifact@v3 with: - name: triton_library-${{ env.package-version }}-cp310-cp310-manylinux_2_24_x86_64.whl - path: wheel-final/triton_library-${{ env.package-version }}-cp310-cp310-manylinux_2_24_x86_64.whl + name: triton_library-${{ env.package-version }}-cp310-cp310-manylinux_2_28_x86_64.whl + path: wheelhouse/manylinux_2_28_x86_64/triton_library-${{ env.package-version }}-cp310-cp310-manylinux_2_28_x86_64.whl if-no-files-found: warn - name: Upload Wheel packages (Python 3.11) uses: actions/upload-artifact@v3 with: - name: triton_library-${{ env.package-version }}-cp311-cp311-manylinux_2_24_x86_64.whl - path: wheel-final/triton_library-${{ env.package-version }}-cp311-cp311-manylinux_2_24_x86_64.whl + name: triton_library-${{ env.package-version }}-cp311-cp311-manylinux_2_28_x86_64.whl + path: wheelhouse/manylinux_2_28_x86_64/triton_library-${{ env.package-version }}-cp311-cp311-manylinux_2_28_x86_64.whl if-no-files-found: warn diff --git a/src/scripts/docker/Dockerfile b/src/scripts/docker/Dockerfile index 4cfc441b2..b55936f8c 100644 --- a/src/scripts/docker/Dockerfile +++ b/src/scripts/docker/Dockerfile @@ -12,3 +12,50 @@ RUN yum install -y \ wget RUN python3.10 -m pip install meson + +ENV DEPENDENCIES_DIR=/tmp/triton-dependencies +ENV SOURCE_DIR=/src + +# Create directory for dependencies. +RUN mkdir -p $DEPENDENCIES_DIR + +# Download, build and install GMP. +RUN echo "[+] Download, build and install GMP" && \ + cd $DEPENDENCIES_DIR && \ + wget -q https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz && \ + tar -xf gmp-6.2.1.tar.xz && \ + cd gmp-6.2.1 && \ + ./configure --enable-cxx && \ + make && \ + make install + +# Download, build and install Bitwuzla. +RUN echo "[+] Download, build and install Bitwuzla" && \ + cd $DEPENDENCIES_DIR && \ + git clone https://github.com/bitwuzla/bitwuzla.git && \ + cd bitwuzla && \ + git checkout -b 0.1.0 0.1.0 && \ + CC=clang CXX=clang++ PATH=$PATH:/opt/_internal/cpython-3.10.12/bin python3.10 ./configure.py --shared --prefix $(pwd)/install && \ + cd build && \ + PATH=$PATH:/opt/_internal/cpython-3.10.12/bin ninja install + +# Download Z3. +RUN echo "[+] Download Z3" && \ +cd $DEPENDENCIES_DIR && \ +wget -q https://github.com/Z3Prover/z3/releases/download/z3-4.8.17/z3-4.8.17-x64-glibc-2.31.zip && \ +unzip z3-4.8.17-x64-glibc-2.31.zip + +# Download, build and install Capstone. +RUN echo "[+] Download, build and install Capstone" && \ + cd $DEPENDENCIES_DIR && \ + wget -q https://github.com/aquynh/capstone/archive/4.0.2.tar.gz -O capstone-4.0.2.tar.gz && \ + tar -xf capstone-4.0.2.tar.gz && \ + cd capstone-4.0.2 && \ + bash ./make.sh && \ + sudo make install + +# Download LLVM. +RUN echo "[+] Download LLVM" && \ + cd $DEPENDENCIES_DIR && \ + wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.1/clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz && \ + tar -xf clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz diff --git a/src/scripts/docker/build-wheel-linux.sh b/src/scripts/docker/build-wheel-linux.sh index 06e2ba23b..065849111 100755 --- a/src/scripts/docker/build-wheel-linux.sh +++ b/src/scripts/docker/build-wheel-linux.sh @@ -11,95 +11,71 @@ # # You'll find the .whl packages in the wheel-final folder. -set -ex +set -e +# set -x # Debugging -# Create deps folder. -cd /src -mkdir -p deps -cd deps - -# Download and build GMP. -wget https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz -tar xvf gmp-6.2.1.tar.xz -cd gmp-6.2.1/ -./configure --enable-cxx -make -make install -cd .. - -# Download and build Bitwuzla. -git clone https://github.com/bitwuzla/bitwuzla.git -cd bitwuzla -git checkout -b 0.1.0 0.1.0 -CC=clang CXX=clang++ PATH=$PATH:/opt/_internal/cpython-3.10.12/bin python3.10 ./configure.py --shared --prefix $(pwd)/install -cd build -PATH=$PATH:/opt/_internal/cpython-3.10.12/bin ninja install -cd ../.. - -# Download Z3. -wget https://github.com/Z3Prover/z3/releases/download/z3-4.8.17/z3-4.8.17-x64-glibc-2.31.zip -unzip z3-4.8.17-x64-glibc-2.31.zip - -# Install Capstone. -wget https://github.com/aquynh/capstone/archive/4.0.2.tar.gz -tar -xf ./4.0.2.tar.gz -cd ./capstone-4.0.2 -bash ./make.sh -sudo make install -cd .. - -# Download LLVM. -wget https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.1/clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz -tar -xf clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz +DEPENDENCIES_DIR=/tmp/triton-dependencies +SOURCE_DIR=/src +WHEEL_DIR=$SOURCE_DIR/wheelhouse # Set environment variables for building Triton. -export Z3_INCLUDE_DIRS=$(pwd)/z3-4.8.17-x64-glibc-2.31/include -export Z3_LIBRARIES=$(pwd)/z3-4.8.17-x64-glibc-2.31/bin/libz3.a +echo "[+] Setup environment variables" +export Z3_INCLUDE_DIRS=$DEPENDENCIES_DIR/z3-4.8.17-x64-glibc-2.31/include +export Z3_LIBRARIES=$DEPENDENCIES_DIR/z3-4.8.17-x64-glibc-2.31/bin/libz3.a export CAPSTONE_INCLUDE_DIRS=/usr/include export CAPSTONE_LIBRARIES=/usr/lib/libcapstone.a export BITWUZLA_INTERFACE=On -export BITWUZLA_INCLUDE_DIRS=$(pwd)/bitwuzla/install/include -export BITWUZLA_LIBRARIES=$(pwd)/bitwuzla/install/lib64/libbitwuzla.so +export BITWUZLA_INCLUDE_DIRS=$DEPENDENCIES_DIR/bitwuzla/install/include +export BITWUZLA_LIBRARIES=$DEPENDENCIES_DIR/bitwuzla/install/lib64/libbitwuzla.so export LLVM_INTERFACE=ON -export CMAKE_PREFIX_PATH=$($(pwd)/clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-/bin/llvm-config --prefix) - -cd .. +export CMAKE_PREFIX_PATH=$($DEPENDENCIES_DIR/clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-/bin/llvm-config --prefix) # Build Triton Python wheel package for Python 3.8. +echo "[+] Build Triton wheel package for Python 3.8" +cd $SOURCE_DIR export PYTHON_BINARY=/opt/_internal/cpython-3.8.17/bin/python export PYTHON_INCLUDE_DIRS=$($PYTHON_BINARY -c "from sysconfig import get_paths; print(get_paths()['include'])") export PYTHON_LIBRARY=$($PYTHON_BINARY -c "from sysconfig import get_paths; print(get_paths()['include'])") -$PYTHON_BINARY setup.py bdist_wheel --dist-dir wheel-temp +$PYTHON_BINARY -m build --wheel --outdir $WHEEL_DIR/linux_x86_64 # Build Triton Python wheel package for Python 3.9. +echo "[+] Build Triton wheel package for Python 3.9" +cd $SOURCE_DIR export PYTHON_BINARY=/opt/_internal/cpython-3.9.17/bin/python export PYTHON_INCLUDE_DIRS=$($PYTHON_BINARY -c "from sysconfig import get_paths; print(get_paths()['include'])") export PYTHON_LIBRARY=$($PYTHON_BINARY -c "from sysconfig import get_paths; print(get_paths()['include'])") -$PYTHON_BINARY setup.py bdist_wheel --dist-dir wheel-temp +$PYTHON_BINARY -m build --wheel --outdir $WHEEL_DIR/linux_x86_64 # Build Triton Python wheel package for Python 3.10. +echo "[+] Build Triton wheel package for Python 3.10" +cd $SOURCE_DIR export PYTHON_BINARY=/opt/_internal/cpython-3.10.12/bin/python export PYTHON_INCLUDE_DIRS=$($PYTHON_BINARY -c "from sysconfig import get_paths; print(get_paths()['include'])") export PYTHON_LIBRARY=$($PYTHON_BINARY -c "from sysconfig import get_paths; print(get_paths()['include'])") -$PYTHON_BINARY setup.py bdist_wheel --dist-dir wheel-temp +$PYTHON_BINARY -m build --wheel --outdir $WHEEL_DIR/linux_x86_64 # Build Triton Python wheel package for Python 3.11. +echo "[+] Build Triton wheel package for Python 3.11" +cd $SOURCE_DIR export PYTHON_BINARY=/opt/_internal/cpython-3.11.4/bin/python export PYTHON_INCLUDE_DIRS=$($PYTHON_BINARY -c "from sysconfig import get_paths; print(get_paths()['include'])") export PYTHON_LIBRARY=$($PYTHON_BINARY -c "from sysconfig import get_paths; print(get_paths()['include'])") -$PYTHON_BINARY setup.py bdist_wheel --dist-dir wheel-temp +$PYTHON_BINARY -m build --wheel --outdir $WHEEL_DIR/linux_x86_64 # Repair wheels. -for whl in wheel-temp/*.whl; do - auditwheel repair "$whl" -w wheel-final +echo "[+] Repair wheel packages" +cd $SOURCE_DIR +for whl in $WHEEL_DIR/linux_x86_64/*.whl; do + auditwheel repair "$whl" --wheel-dir $WHEEL_DIR/manylinux_2_28_x86_64 done -chown -R 1000:1000 build -chown -R 1000:1000 deps -chown -R 1000:1000 triton_library.egg-info -chown -R 1000:1000 wheel-final -chown -R 1000:1000 wheel-temp +echo "[+] Remove build directory" +rm -rf $SOURCE_DIR/build +rm -rf $SOURCE_DIR/triton_library.egg-info + +echo "[+] Change permissions for directories" +chown -R 1000:1000 $WHEEL_DIR From 0ffc28a04296e6bf3190c72a19bdc8998c5412a9 Mon Sep 17 00:00:00 2001 From: Christian Heitman Date: Fri, 18 Aug 2023 13:48:59 -0300 Subject: [PATCH 3/4] Update .gitignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6ba618dc4..605453c58 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ private/* .vscode dist/ *.egg-info/ +wheelhouse/ From 04fd303ed04b54b597ae0a8468b486a8c4513760 Mon Sep 17 00:00:00 2001 From: Christian Heitman Date: Mon, 2 Jan 2023 11:46:11 -0300 Subject: [PATCH 4/4] Fix python workflow for macOS --- .github/workflows/python.yml | 251 ++++++++++----------- src/scripts/macos/delocate-wheel-custom.py | 40 ++++ 2 files changed, 164 insertions(+), 127 deletions(-) create mode 100644 src/scripts/macos/delocate-wheel-custom.py diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 8ac18c1ab..f703b7185 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -130,130 +130,127 @@ jobs: # if-no-files-found: warn - # FIXME - #build-macos: - # runs-on: macos-latest - # strategy: - # matrix: - # python-version: ['3.8', '3.9', '3.10'] - # include: - # - python-version: 3.8 - # - python-version: 3.9 - # - python-version: 3.10 - # steps: - # - name: Checkout - # uses: actions/checkout@v3 - - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@v4 - # with: - # python-version: ${{ matrix.python-version }} - - # - name: Install LLVM and Clang - # uses: KyleMayes/install-llvm-action@v1 - # 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: Download and build GMP - # run: | - # wget https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz - # tar xvf gmp-6.2.1.tar.xz - # cd gmp-6.2.1/ - # ./configure --enable-cxx - # make - # make check - # make install - - # - name: Download and build Bitwuzla - # run: | - # git clone https://github.com/bitwuzla/bitwuzla.git - # cd bitwuzla - # ./contrib/setup-cadical.sh - # ./contrib/setup-btor2tools.sh - # ./contrib/setup-symfpu.sh - # ./configure.sh --shared --prefix $(pwd)/install - # cd build - # make - # make install - - # - name: Download Z3 - # run: | - # wget https://github.com/Z3Prover/z3/releases/download/z3-4.8.17/z3-4.8.17-x64-osx-10.16.zip - # unzip z3-4.8.17-x64-osx-10.16.zip - - # - name: Install Capstone - # run: | - # wget https://github.com/aquynh/capstone/archive/4.0.2.tar.gz - # tar -xf ./4.0.2.tar.gz - # cd ./capstone-4.0.2 - # bash ./make.sh - # sudo make install - # cd ../ - - # - name: Build Triton Python package - # run: python -m build --wheel - # env: - # PYTHON_VERSION: ${{ matrix.python-version }} - # PYTHON_LIBRARIES: ${{ env.pythonLocation }}/lib/libpython${{ matrix.python-version }}.dylib - # PYTHON_LIBRARY: ${{ env.pythonLocation }}/lib/libpython${{ matrix.python-version }}.dylib - # PYTHON_INCLUDE_DIRS: ${{ env.pythonLocation }}/include/python${{ matrix.python-version }} - # Z3_INCLUDE_DIRS: ${{ github.workspace }}/z3-4.8.17-x64-osx-10.16/include - # Z3_LIBRARIES: ${{ github.workspace }}/z3-4.8.17-x64-osx-10.16/bin/libz3.a - # CAPSTONE_INCLUDE_DIRS: /usr/local/include - # CAPSTONE_LIBRARIES: /usr/local/lib/libcapstone.a - # BITWUZLA_INTERFACE: On - # BITWUZLA_INCLUDE_DIRS: ${{ github.workspace }}/bitwuzla/install/include - # BITWUZLA_LIBRARIES: ${{ github.workspace }}/bitwuzla/install/lib/libbitwuzla.dylib - # LLVM_INTERFACE: On - # CMAKE_PREFIX_PATH: ${{env.LLVM_PATH}} - - # - name: Repair wheel package (Python 3.8) - # if: ${{ matrix.python-version == '3.8' }} - # run: | - # pip install delocate - # delocate-wheel -w wheel-final -v ${{ github.workspace }}/dist/triton_library-${{ env.package-version }}-cp38-cp38-macosx_11_0_x86_64.whl - - # - name: Upload Wheel packages (Python 3.8) - # uses: actions/upload-artifact@v3 - # if: ${{ matrix.python-version == '3.8' }} - # with: - # name: triton_library-${{ env.package-version }}-cp38-cp38-macosx_11_0_x86_64.whl - # path: ${{ github.workspace }}/wheel-final/triton_library-${{ env.package-version }}-cp38-cp38-macosx_11_0_x86_64.whl - # if-no-files-found: warn - - # - name: Repair wheel package (Python 3.9) - # if: ${{ matrix.python-version == '3.9' }} - # run: | - # pip install delocate - # delocate-wheel -w wheel-final -v ${{ github.workspace }}/dist/triton_library-${{ env.package-version }}-cp39-cp39-macosx_11_0_x86_64.whl - - # - name: Upload Wheel packages (Python 3.9) - # uses: actions/upload-artifact@v3 - # if: ${{ matrix.python-version == '3.9' }} - # with: - # name: triton_library-${{ env.package-version }}-cp39-cp39-macosx_11_0_x86_64.whl - # path: ${{ github.workspace }}/wheel-final/triton_library-${{ env.package-version }}-cp39-cp39-macosx_11_0_x86_64.whl - # if-no-files-found: warn - - # - name: Repair wheel package (Python 3.10) - # if: ${{ matrix.python-version == '3.10' }} - # run: | - # pip install delocate - # delocate-wheel -w wheel-final -v ${{ github.workspace }}/dist/triton_library-${{ env.package-version }}-cp310-cp310-macosx_11_0_x86_64.whl - - # - name: Upload Wheel packages (Python 3.10) - # uses: actions/upload-artifact@v3 - # if: ${{ matrix.python-version == '3.10' }} - # with: - # name: triton_library-${{ env.package-version }}-cp310-cp310-macosx_11_0_x86_64.whl - # path: ${{ github.workspace }}/wheel-final/triton_library-${{ env.package-version }}-cp310-cp310-macosx_11_0_x86_64.whl - # if-no-files-found: warn + build-macos: + runs-on: macos-latest + 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 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v1.6.1 + 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: Download and build GMP + run: | + wget -q https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz + tar -xf gmp-6.2.1.tar.xz + cd gmp-6.2.1 + ./configure --enable-cxx + make + make install + + - name: Install Ninja + run: | + brew install ninja + + - 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.1.0 0.1.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.8.17/z3-4.8.17-x64-osx-10.16.zip + unzip z3-4.8.17-x64-osx-10.16.zip + + - name: Install Capstone + run: | + wget -q https://github.com/aquynh/capstone/archive/4.0.2.tar.gz + tar -xf ./4.0.2.tar.gz + cd capstone-4.0.2 + bash ./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.8.17-x64-osx-10.16/include + Z3_LIBRARIES: ${{ github.workspace }}/z3-4.8.17-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 + + 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 + + cd ${{ github.workspace }}/src/testers + python -m unittest discover -b -v unittests + deactivate + + - name: Upload wheel package + uses: actions/upload-artifact@v3 + 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 diff --git a/src/scripts/macos/delocate-wheel-custom.py b/src/scripts/macos/delocate-wheel-custom.py new file mode 100644 index 000000000..7eab1b5f9 --- /dev/null +++ b/src/scripts/macos/delocate-wheel-custom.py @@ -0,0 +1,40 @@ +import sys + +from delocate.cmd.delocate_wheel import main +import delocate.delocating + + +def filter_system_libs(libname): + copy_lib = not (libname.startswith('/usr/lib') or + libname.startswith('/System') or + libname.find('libpython') >= 0) + + print(f'[filter_system_libs] libname: {libname}, copy_lib: {copy_lib}') + + return copy_lib + + +def delocate_wheel(in_wheel, + out_wheel=None, + lib_sdir='.dylibs', + lib_filt_func=None, + copy_filt_func=filter_system_libs, + require_archs=None, + check_verbose=None, + executable_path=None, + ignore_missing=False): + return delocate.delocating.delocate_wheel(in_wheel, + out_wheel, + lib_sdir, + lib_filt_func, + copy_filt_func, + require_archs, + check_verbose, + executable_path, + ignore_missing) + +delocate.cmd.delocate_wheel.delocate_wheel = delocate_wheel + + +if __name__ == '__main__': + sys.exit(main())