-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutable2.py
More file actions
46 lines (39 loc) · 1.68 KB
/
Copy pathexecutable2.py
File metadata and controls
46 lines (39 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import shutil
import PyInstaller.__main__
import importlib.util
import pymobiledevice3
# Get the path to the installed pymobiledevice3 package
pymobiledevice3_path = os.path.dirname(importlib.util.find_spec('pymobiledevice3').origin)
pymobiledevice3_cli_path = os.path.join(pymobiledevice3_path, 'cli')
resources_dir = os.path.join(pymobiledevice3_path, 'resources')
out_dir = "./output"
if os.path.exists(out_dir):
shutil.rmtree(out_dir)
hidden_imports = []
# Iterate over the files in the pymobiledevice3/cli directory
for module in os.listdir(pymobiledevice3_cli_path):
if module.endswith('.py') and module != '__init__.py': # Avoid including the __init__.py
# Create the module name to be added to hidden imports
module_name = 'pymobiledevice3.cli.' + module[:-3] # Strip off '.py' from the file name
hidden_imports.append('--hidden-import=' + module_name)
pyinstaller_args = [
os.path.join(pymobiledevice3_path, '__main__.py'),
'--hidden-import=ipsw_parser',
'--hidden-import=zeroconf',
'--hidden-import=pyimg4',
'--hidden-import=apple_compress',
'--hidden-import=zeroconf._utils.ipaddress',
'--hidden-import=zeroconf._handlers.answers',
'--hidden-import=readchar',
'--copy-metadata=pyimg4',
'--copy-metadata=readchar',
'--copy-metadata=apple_compress',
'--add-binary', f"{pymobiledevice3_path}/pytun_pmd3;pytun_pmd3",
'--onefile',
'--add-data', f'{resources_dir}/webinspector;pymobiledevice3/resources/webinspector'
]
# Add the dynamically generated hidden imports to the PyInstaller arguments
pyinstaller_args.extend(hidden_imports)
PyInstaller.__main__.run(pyinstaller_args)
shutil.move('dist', out_dir)