12
12
import multiprocessing
13
13
import platform
14
14
import site
15
+ from urllib .request import urlretrieve
15
16
16
17
def dynamorio_tag_and_patch ():
17
18
if "macOS" in platform .platform ():
@@ -25,30 +26,17 @@ def run_command(command, cwd=None, env=None):
25
26
subprocess .check_call (command , cwd = cwd , env = env )
26
27
27
28
def download_and_extract (url , extract_dir ):
28
- import urllib .request
29
29
import tarfile
30
30
31
31
filename = url .split ('/' )[- 1 ]
32
- urllib . request . urlretrieve (url , filename )
32
+ urlretrieve (url , filename )
33
33
34
34
with tarfile .open (filename ) as tar :
35
35
tar .extractall (path = extract_dir )
36
36
37
37
os .remove (filename )
38
38
39
- class CustomBuildCommand (Command ):
40
- description = "Build Pyda"
41
- user_options = []
42
-
43
- def initialize_options (self ):
44
- self .build_temp = None
45
- self .build_lib = None
46
-
47
- def finalize_options (self ):
48
- self .set_undefined_options ('build' ,
49
- ('build_temp' , 'build_temp' ),
50
- ('build_lib' , 'build_lib' ))
51
-
39
+ class CustomBuildCommand (build_ext ):
52
40
def run (self ):
53
41
# Create temporary build directory
54
42
build_temp_dir = tempfile .TemporaryDirectory ()
@@ -68,10 +56,10 @@ def run(self):
68
56
libunwind_dir = os .path .join (build_temp , 'libunwind' )
69
57
os .makedirs (libunwind_dir , exist_ok = True )
70
58
download_and_extract (
71
- 'https://github.com/libunwind/libunwind/releases/download/v1.6.2 /libunwind-1.6.2 .tar.gz' ,
59
+ 'https://github.com/libunwind/libunwind/releases/download/v1.8.1 /libunwind-1.8.1 .tar.gz' ,
72
60
libunwind_dir
73
61
)
74
- libunwind_build_dir = os .path .join (libunwind_dir , 'libunwind-1.6.2 ' )
62
+ libunwind_build_dir = os .path .join (libunwind_dir , 'libunwind-1.8.1 ' )
75
63
run_command (['./configure' , f'--prefix={ os .path .abspath (libunwind_install_dir )} ' ], cwd = libunwind_build_dir )
76
64
run_command (['make' , f'-j{ multiprocessing .cpu_count ()} ' ], cwd = libunwind_build_dir )
77
65
run_command (['make' , 'install' ], cwd = libunwind_build_dir )
@@ -92,8 +80,11 @@ def run(self):
92
80
if os .path .exists (patch_path ):
93
81
run_command (['git' , 'apply' , patch_path ], cwd = dynamorio_dir )
94
82
95
- run_command (["bash" , "-c" , "wget https://github.com/DynamoRIO/dynamorio/commit/f1b67a4b0cf0a13314d500dd3aaefe9869597021.patch && git apply f1b67a4b0cf0a13314d500dd3aaefe9869597021.patch && rm f1b67a4b0cf0a13314d500dd3aaefe9869597021.patch && git submodule update --init" ], cwd = dynamorio_dir )
96
- run_command (["bash" , "-c" , "wget https://github.com/DynamoRIO/dynamorio/commit/c46d736f308e6e734bd0477f7b8a2dcbefb155d3.patch && git apply c46d736f308e6e734bd0477f7b8a2dcbefb155d3.patch && rm c46d736f308e6e734bd0477f7b8a2dcbefb155d3.patch" ], cwd = dynamorio_dir )
83
+ urlretrieve ('https://github.com/DynamoRIO/dynamorio/commit/f1b67a4b0cf0a13314d500dd3aaefe9869597021.patch' , os .path .join (dynamorio_dir , 'f1b67a4b0cf0a13314d500dd3aaefe9869597021.patch' ))
84
+ urlretrieve ('https://github.com/DynamoRIO/dynamorio/commit/c46d736f308e6e734bd0477f7b8a2dcbefb155d3.patch' , os .path .join (dynamorio_dir , 'c46d736f308e6e734bd0477f7b8a2dcbefb155d3.patch' ))
85
+
86
+ run_command (["bash" , "-c" , "git apply f1b67a4b0cf0a13314d500dd3aaefe9869597021.patch && rm f1b67a4b0cf0a13314d500dd3aaefe9869597021.patch && git submodule update --init" ], cwd = dynamorio_dir )
87
+ run_command (["bash" , "-c" , "git apply c46d736f308e6e734bd0477f7b8a2dcbefb155d3.patch && rm c46d736f308e6e734bd0477f7b8a2dcbefb155d3.patch" ], cwd = dynamorio_dir )
97
88
98
89
# Build DynamoRIO
99
90
dynamorio_build_dir = os .path .join (dynamorio_dir , 'build' )
@@ -184,7 +175,6 @@ def run(self):
184
175
# Custom install command that runs our build command first
185
176
class CustomInstallCommand (install ):
186
177
def run (self ):
187
- self .run_command ('build_pyda' )
188
178
install .run (self )
189
179
prepend_env = f"""
190
180
BASE=$(python3 -c "from importlib.resources import files; print(files('pyda'))" 2>/dev/null)
@@ -232,7 +222,6 @@ def run(self):
232
222
# Custom develop command that runs our build command first
233
223
class CustomDevelopCommand (develop ):
234
224
def run (self ):
235
- self .run_command ('build_pyda' )
236
225
develop .run (self )
237
226
238
227
setup (
@@ -241,7 +230,7 @@ def run(self):
241
230
author = 'Andrew Haberlandt' ,
242
231
243
232
cmdclass = {
244
- 'build_pyda ' : CustomBuildCommand ,
233
+ 'build_ext ' : CustomBuildCommand ,
245
234
'install' : CustomInstallCommand ,
246
235
'develop' : CustomDevelopCommand ,
247
236
},
@@ -260,5 +249,6 @@ def run(self):
260
249
# Add your Python package dependencies here
261
250
],
262
251
scripts = [],
252
+ ext_modules = [Extension ("dummy" , sources = [])],
263
253
)
264
254
0 commit comments