22import re
33import shutil
44import subprocess
5- import sysconfig
65import sys
76
87from setuptools import setup
@@ -37,40 +36,53 @@ def run(self):
3736 self .build_extension ()
3837
3938 def build_extension (self ):
39+ # configuration
40+ build_type = "Debug"
41+
4042 ninja_dir = shutil .which ("ninja" )
4143 # create build directories
4244 if not os .path .exists (self .build_temp ):
4345 os .makedirs (self .build_temp )
44- # python directories
45- python_include_dir = sysconfig .get_path ("platinclude" )
4646 cmake_args = [
4747 "-G" ,
4848 "Ninja" , # Ninja is much faster than make
4949 "-DCMAKE_MAKE_PROGRAM=" +
5050 ninja_dir , # Pass explicit path to ninja otherwise cmake may cache a temporary path
5151 f"-DCMAKE_PREFIX_PATH={ torch .utils .cmake_prefix_path } { ipex_cmake_prefix_path } " ,
5252 f"-DUSE_IPEX={ USE_IPEX_OPTION } " ,
53- "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" ,
54- "-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=" + self .extdir ,
55- "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + self .extdir ,
56- "-DPython3_EXECUTABLE:FILEPATH=" + sys .executable ,
57- "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON" ,
58- "-DPYTHON_INCLUDE_DIRS=" + python_include_dir ,
53+ "-DCMAKE_INSTALL_PREFIX=" + self .extdir ,
54+ "-DPython3_ROOT_DIR:FILEPATH=" + sys .exec_prefix ,
55+ "-DCMAKE_VERBOSE_MAKEFILE=TRUE" ,
5956 "-DCMAKE_C_COMPILER=icx" ,
6057 "-DCMAKE_CXX_COMPILER=icpx" ,
58+ "-DCMAKE_BUILD_TYPE=" + build_type ,
59+ "-S" ,
60+ self .current_dir ,
61+ "-B" ,
62+ self .build_temp ,
6163 ]
6264
63- # configuration
64- build_type = "Debug"
65- build_args = ["--config" , build_type ]
66- cmake_args += ["-DCMAKE_BUILD_TYPE=" + build_type ]
6765 max_jobs = os .getenv ("MAX_JOBS" , str (2 * os .cpu_count ()))
68- build_args += ["-j" + max_jobs ]
66+ build_args = [
67+ "--build" ,
68+ self .build_temp ,
69+ "-j" + max_jobs ,
70+ ]
71+
72+ install_args = [
73+ "--build" ,
74+ self .build_temp ,
75+ "--target" ,
76+ "install" ,
77+ ]
6978
7079 env = os .environ .copy ()
71- cmake_dir = self .build_temp
72- subprocess .check_call (["cmake" , self .current_dir ] + cmake_args , cwd = cmake_dir , env = env )
73- subprocess .check_call (["cmake" , "--build" , "." ] + build_args , cwd = cmake_dir )
80+ print (" " .join (["cmake" ] + cmake_args ))
81+ subprocess .check_call (["cmake" ] + cmake_args , env = env )
82+ print (" " .join (["cmake" ] + build_args ))
83+ subprocess .check_call (["cmake" ] + build_args )
84+ print (" " .join (["cmake" ] + install_args ))
85+ subprocess .check_call (["cmake" ] + install_args )
7486
7587
7688cmake = CMakeBuild ()
@@ -80,4 +92,4 @@ def build_extension(self):
8092 "triton_kernels_benchmark" ,
8193], package_dir = {
8294 "triton_kernels_benchmark" : "triton_kernels_benchmark" ,
83- }, package_data = {"triton_kernels_benchmark" : ["xetla_kernel.so" ]})
95+ }, package_data = {"triton_kernels_benchmark" : ["xetla_kernel.cpython-*. so" ]})
0 commit comments