Skip to content

Commit

Permalink
Merge pull request #152 from c3rb3ru5d3d53c/wheel
Browse files Browse the repository at this point in the history
Multiple Python Wheel Versions for Windows MacOS and Linux
  • Loading branch information
c3rb3ru5d3d53c authored Mar 4, 2023
2 parents 8e2de3f + 673f117 commit 1aa0278
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
38 changes: 26 additions & 12 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
matrix:
target:
- ubuntu-20.04
- ubuntu-22.04
- windows
- macos
include:
Expand All @@ -19,22 +20,24 @@ jobs:
build-type: Release
extra-cmake-flags: >-
"-DBUILD_PYTHON_BINDINGS=ON"
"-DPYBIND11_PYTHON_VERSION=3.8.10"
- target: ubuntu-22.04
os: ubuntu-22.04
build-type: Release
extra-cmake-flags: >-
"-DBUILD_PYTHON_BINDINGS=ON"
- target: windows
os: windows-latest
build-type: Release
extra-cmake-flags: >-
"-DBUILD_PYTHON_BINDINGS=ON"
"-DPYBIND11_PYTHON_VERSION=3.8.10"
- target: macos
os: macOS-latest
build-type: Release
extra-cmake-flags: >-
"-DBUILD_PYTHON_BINDINGS=ON"
"-DPYBIND11_PYTHON_VERSION=3.8.10"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
lfs: true
submodules: true
Expand All @@ -43,9 +46,12 @@ jobs:
uses: seanmiddleditch/gha-setup-ninja@v3

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.8.10'
python-version: |
3.8
3.9
3.10
- name: Enable Developer Command Prompt
if: ${{ runner.os == 'Windows' }}
Expand All @@ -68,10 +74,19 @@ jobs:
cmake --build build --config ${{ matrix.build-type }} --parallel 4
cmake --install build --prefix build/install --config ${{ matrix.build-type }}
# - name: Test
# run: |
# python3 test.py
# python3 -m pip wheel -v -w ${{ github.workspace }}/build/ .
- name: Build Python Unix
if: ${{ runner.os != 'Windows' }}
run: |
python3.8 -m pip wheel -v -w ${{ github.workspace }}/build/ .
python3.9 -m pip wheel -v -w ${{ github.workspace }}/build/ .
python3.10 -m pip wheel -v -w ${{ github.workspace }}/build/ .
- name: Build Python Windows
if: ${{ runner.os == 'Windows' }}
run: |
py -3.8 -m pip wheel -v -w ${{ github.workspace }}/build/ .
py -3.9 -m pip wheel -v -w ${{ github.workspace }}/build/ .
py -3.10 -m pip wheel -v -w ${{ github.workspace }}/build/ .
- name: Package
run: |
Expand All @@ -89,11 +104,10 @@ jobs:
build/*.exe
build/*.dll
build/*.lib
build/*.whl
build/*.tar.gz
build/*.rpm
build/*.a
build/*.whl
build/pybinlex*.whl
build/*.dmg
- name: Compress artifacts
Expand Down
1 change: 1 addition & 0 deletions cmake/FindCAPSTONE.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(CAPSTONE_ROOT "${CMAKE_SOURCE_DIR}/deps/build/capstone")
set(CAPSTONE_INCLUDE_DIRS "${CAPSTONE_ROOT}/include")
file(MAKE_DIRECTORY ${CAPSTONE_INCLUDE_DIRS})

add_library(capstone_static STATIC IMPORTED)
set_target_properties(capstone_static PROPERTIES
Expand Down
1 change: 1 addition & 0 deletions cmake/FindLIEF.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(LIEF_PREFIX "${CMAKE_SOURCE_DIR}/deps/build/LIEF")
set(LIEF_INCLUDE_DIRS "${LIEF_PREFIX}/include")
file(MAKE_DIRECTORY ${LIEF_INCLUDE_DIRS})

add_library(lief_static STATIC IMPORTED)
set_target_properties(lief_static PROPERTIES
Expand Down
1 change: 1 addition & 0 deletions cmake/FindTLSH.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(TLSH_ROOT "${CMAKE_SOURCE_DIR}/deps/build/tlsh")
set(TLSH_INCLUDE_DIRS "${TLSH_ROOT}/src/tlsh/include")
file(MAKE_DIRECTORY ${TLSH_INCLUDE_DIRS})

add_library(tlsh_static STATIC IMPORTED)
set_target_properties(
Expand Down
12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from glob import glob
import subprocess
import platform
from multiprocessing import cpu_count
from setuptools import Extension, setup, find_packages
from setuptools.command.build_ext import build_ext

Expand Down Expand Up @@ -35,14 +36,17 @@ def build_extension(self, ext):
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}",
f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DCMAKE_BUILD_TYPE={cfg}",
'-DBUILD_PYTHON_BINDINGS=ON'
'-DBUILD_PYTHON_BINDINGS=ON',
f'-DPYBIND11_PYTHON_VERSION={platform.python_version()}'
]
build_temp = os.path.join(self.build_temp, ext.name)
if not os.path.exists(build_temp):
os.makedirs(build_temp)
subprocess.check_call(["cmake", "-B", "build", ext.sourcedir] + cmake_args, cwd=build_temp)
subprocess.check_call(["cmake", "--build", "build", "--config", cfg, '--parallel'], cwd=build_temp)
subprocess.check_call(["cmake", "--install", "build", "--prefix", "build/install", "--config", cfg], cwd=build_temp)
subprocess.check_call(["cmake", "-B", "deps/build", "-S", "deps"], cwd=ext.sourcedir)
subprocess.check_call(["cmake", "--build", "deps/build", "--config", cfg, '--parallel', f'{cpu_count()}'], cwd=ext.sourcedir)
subprocess.check_call(["cmake", "-B", "build"] + cmake_args, cwd=ext.sourcedir)
subprocess.check_call(["cmake", "--build", "build", "--config", cfg, '--parallel', f'{cpu_count()}'], cwd=ext.sourcedir)
subprocess.check_call(["cmake", "--install", "build", "--prefix", "build/install", "--config", cfg], cwd=ext.sourcedir)

setup(
name="pybinlex",
Expand Down

0 comments on commit 1aa0278

Please sign in to comment.