-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutable.py
More file actions
47 lines (40 loc) · 1.74 KB
/
Copy pathexecutable.py
File metadata and controls
47 lines (40 loc) · 1.74 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
47
import os
import shutil
import PyInstaller.__main__
import site
site_packages_path = site.getsitepackages()[1]
pymobiledevice3_cli_path = os.path.join(site_packages_path, 'pymobiledevice3', 'cli')
resources_dir = os.path.join(site_packages_path, 'pymobiledevice3', '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 = [
'Lib/site-packages/pymobiledevice3/__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"{site_packages_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', './dist')
# Move the dist folder to the desired output location
#if os.path.exists('./dist'):
# shutil.move('./dist', out_dir)