From 2b1d0ad8fcd6bfb7d865cada5e0d9c8c4963627d Mon Sep 17 00:00:00 2001 From: cctv130 Date: Mon, 1 Dec 2025 07:53:18 +0000 Subject: [PATCH] update setup.py --- CMakeLists.txt | 4 ++-- README.md | 12 ++++++++++++ setup.py | 30 ++++++++++++++++-------------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66ff2552..c4625c5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,7 +154,7 @@ list(APPEND CMAKE_MODULE_PATH "${TRITON_ROOT}/CMakeModules/") # Find Z3 if(Z3_INTERFACE) message(STATUS "Compiling with Z3 SMT solver") - find_package(Z3 CONFIG REQUIRED) + find_package(Z3 REQUIRED) message(STATUS "Z3 version: ${Z3_VERSION}") if(TARGET z3::libz3) link_libraries(z3::libz3) @@ -199,7 +199,7 @@ endif() # Find Capstone message(STATUS "Compiling with Capstone") -find_package(CAPSTONE 5 CONFIG REQUIRED) +find_package(CAPSTONE 5 REQUIRED) message(STATUS "CAPSTONE version: ${CAPSTONE_VERSION}") if(TARGET capstone::capstone) link_libraries(capstone::capstone) diff --git a/README.md b/README.md index 719df6f0..35e5cc28 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,18 @@ You can use cmake to generate the .sln file of libTriton. -DCAPSTONE_LIBRARIES="C:/Users/jonathan/Works/Tools/capstone-5.0.1-win64/capstone.lib" .. ``` +You can use setup.py to generate the debug version of triton.pyd on Windows. + +```console +> git clone https://github.com/JonathanSalwan/Triton.git +> cd Triton +> $env:COMPILER_DIR="C:/deps/llvm/llvm2116r/bin" +> $env:CMAKE_PREFIX_PATH="C:/deps/llvm/llvm-project-21.1.6.src/install/lib/cmake/llvm;C:/code/cxx-common-cmake/build/install" +> python_d -m build --wheel +> python_d -m pip install (Get-ChildItem .\dist\triton_library*) + +``` + However, if you prefer to directly download the precompiled library, check out our AppVeyor's [artefacts](https://ci.appveyor.com/project/JonathanSalwan/triton/history). Note that if you use AppVeyor's artefacts, you probably have to install the [Visual C++ Redistributable](https://www.microsoft.com/en-US/download/details.aspx?id=30679) packages for Visual Studio 2012. diff --git a/setup.py b/setup.py index d69baa06..87f34d44 100644 --- a/setup.py +++ b/setup.py @@ -20,11 +20,23 @@ from setuptools.command.build_ext import build_ext VERSION_MAJOR = 1 VERSION_MINOR = 0 VERSION_PATCH = 0 +ON = "ON" +OFF = "OFF" + +clang = "clang" +clang_cl = "clang_cl" +vs2022 = "vs2022" +Release = "Release" +Debug = "Debug" RELEASE_CANDIDATE = 4 +Z3_INTERFACE = ON +LLVM_INTERFACE = OFF +BITWUZLA_INTERFACE = OFF +BOOST_INTERFACE = OFF -BUILDTOOLS = "vs2022" # clang or clang_cl or vs2022 -CMAKE_BUILD_TYPE = "Release" # Release or Debug +BUILDTOOLS = vs2022 # clang or clang_cl or vs2022 +CMAKE_BUILD_TYPE = Release # Release or Debug VERSION = f'{VERSION_MAJOR}.{VERSION_MINOR}.{VERSION_PATCH}' + \ f'rc{RELEASE_CANDIDATE}' if RELEASE_CANDIDATE else '' @@ -73,7 +85,7 @@ class CMakeBuild(build_ext): # BITWUZLA_INTERFACE=Off # BOOST_INTERFACE=Off # - for arg, value in [('Z3_INTERFACE', 'On'), ('LLVM_INTERFACE', 'Off'), ('BITWUZLA_INTERFACE', 'Off'), ('BOOST_INTERFACE', 'Off')]: + for arg, value in [('Z3_INTERFACE', Z3_INTERFACE), ('LLVM_INTERFACE', LLVM_INTERFACE), ('BITWUZLA_INTERFACE', BITWUZLA_INTERFACE), ('BOOST_INTERFACE', BOOST_INTERFACE)]: if os.getenv(arg): cmake_args += [f'-D{arg}=' + os.getenv(arg)] else: @@ -130,9 +142,6 @@ class CMakeBuild(build_ext): cmake_args += ['-DPYTHON_VERSION=' + os.getenv('PYTHON_VERSION')] # Custom Z3 paths. - if os.getenv('Z3_DIR'): - cmake_args += ['-DZ3_DIR=' + os.getenv('Z3_DIR')] - if os.getenv('Z3_LIBRARIES'): cmake_args += ['-DZ3_LIBRARIES=' + os.getenv('Z3_LIBRARIES')] @@ -145,11 +154,7 @@ class CMakeBuild(build_ext): if os.getenv('BITWUZLA_INCLUDE_DIRS'): cmake_args += ['-DBITWUZLA_INCLUDE_DIRS=' + os.getenv('BITWUZLA_INCLUDE_DIRS')] - # Custom Capstone paths. - if os.getenv('CAPSTONE_DIR'): - cmake_args += ['-DCAPSTONE_DIR=' + os.getenv('CAPSTONE_DIR')] - if os.getenv('CAPSTONE_LIBRARIES'): cmake_args += ['-DCAPSTONE_LIBRARIES=' + os.getenv('CAPSTONE_LIBRARIES')] @@ -157,9 +162,6 @@ class CMakeBuild(build_ext): cmake_args += ['-DCAPSTONE_INCLUDE_DIRS=' + os.getenv('CAPSTONE_INCLUDE_DIRS')] # Custom LLVM paths. - if os.getenv('LLVM_DIR'): - cmake_args += ['-DLLVM_DIR='+ os.getenv('LLVM_DIR')] - if os.getenv('LLVM_LIBRARIES'): cmake_args += ['-DLLVM_LIBRARIES=' + os.getenv('LLVM_LIBRARIES')] @@ -200,7 +202,7 @@ class CMakeBuild(build_ext): src_filename = os.path.join(self.build_temp + '/src/libtriton', 'libtriton.dylib') dst_filename = os.path.join(self.build_lib, os.path.basename(filename)) elif platform.system() == "Windows": - src_filename = os.path.join(self.build_temp + '\\src\\libtriton\\', 'triton.pyd') + src_filename = os.path.join(self.build_temp + '/src/libtriton', 'triton.pyd') dst_filename = os.path.join(self.build_lib, os.path.basename(filename)) else: raise Exception(f'Platform not supported: {platform.system()}')