-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.py
More file actions
86 lines (73 loc) · 2.02 KB
/
build.py
File metadata and controls
86 lines (73 loc) · 2.02 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
"""
Build script for ArpCut
Run: python build.py
"""
import subprocess
import sys
import platform
# All the imports PyInstaller is too dumb to find on its own
HIDDEN_IMPORTS = [
'PyQt5',
'PyQt5.QtWidgets',
'PyQt5.QtCore',
'PyQt5.QtGui',
'PyQt5.sip',
'qdarkstyle',
'scapy',
'scapy.all',
'scapy.layers.all',
'manuf',
'pyperclip',
'requests',
'six',
]
COLLECT_ALL = [
'manuf',
'scapy',
'qdarkstyle',
]
def build():
system = platform.system()
# Base command
cmd = ['pyinstaller', '--name', 'ArpCut']
# Platform-specific options
if system == 'Windows':
cmd.extend(['--onefile', '--windowed'])
cmd.extend(['--add-data', 'exe/manuf;manuf'])
cmd.extend(['--icon', 'exe/icon.ico'])
cmd.extend(['--uac-admin']) # Force admin elevation prompt
elif system == 'Darwin': # macOS
cmd.extend(['--onedir', '--windowed'])
cmd.extend(['--add-data', 'exe/manuf:manuf'])
cmd.extend(['--icon', 'exe/icon.ico'])
else: # Linux
cmd.extend(['--onefile'])
cmd.extend(['--add-data', 'exe/manuf:manuf'])
# Add hidden imports
for imp in HIDDEN_IMPORTS:
cmd.extend(['--hidden-import', imp])
# Collect all data for these packages
for pkg in COLLECT_ALL:
cmd.extend(['--collect-all', pkg])
# Entry point
cmd.append('src/elmocut.py')
print(f"Building for {system}...")
print(f"Command: {' '.join(cmd)}")
print()
result = subprocess.run(cmd)
if result.returncode == 0:
print()
print("Build complete!")
if system == 'Windows':
print("Output: dist/ArpCut.exe")
elif system == 'Darwin':
print("Output: dist/ArpCut.app")
print("To create zip: cd dist && zip -r ArpCut-macOS.zip ArpCut.app")
else:
print("Output: dist/ArpCut")
else:
print("Build failed!")
sys.exit(1)
if __name__ == '__main__':
build()