-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.py
More file actions
114 lines (95 loc) · 3.45 KB
/
Copy pathbuild.py
File metadata and controls
114 lines (95 loc) · 3.45 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import os
import sys
import PyInstaller.__main__
from PIL import Image, ImageDraw, ImageFont
def create_icon():
"""Create a black square icon with white music note"""
# Create a new image with a black background
size = (256, 256)
icon = Image.new('RGB', size, 'black')
draw = ImageDraw.Draw(icon)
try:
# Try to use a font that has music note symbol
font = ImageFont.truetype("arial.ttf", 150)
# Unicode for music note
music_note = "♪"
except:
# Fallback if font not found
font = ImageFont.load_default()
music_note = "♪"
# Get text size
text_bbox = draw.textbbox((0, 0), music_note, font=font)
text_width = text_bbox[2] - text_bbox[0]
text_height = text_bbox[3] - text_bbox[1]
# Calculate center position
x = (size[0] - text_width) // 2
y = (size[1] - text_height) // 2
# Draw white music note
draw.text((x, y), music_note, fill='white', font=font)
# Save as ICO file
icon_path = os.path.join('assets', 'icon.ico')
os.makedirs('assets', exist_ok=True)
icon.save(icon_path, format='ICO')
return icon_path
def build_exe():
"""Build the executable using PyInstaller"""
# Create icon
icon_path = create_icon()
# PyInstaller command line arguments
args = [
'gui.py', # Main script
'--onefile',
'--noconsole',
f'--icon={icon_path}',
'--name=TikTok Profile Archiver',
'--add-data=assets;assets',
# Add all required hidden imports
'--hidden-import=PIL._tkinter_finder',
'--hidden-import=customtkinter',
'--hidden-import=selenium',
'--hidden-import=webdriver_manager',
'--hidden-import=requests',
'--hidden-import=json',
'--hidden-import=datetime',
'--hidden-import=threading',
'--hidden-import=tkinter',
'--hidden-import=PIL',
'--hidden-import=src.licensing.license_manager',
'--hidden-import=src.licensing.activation_wizard',
'--hidden-import=src.licensing.activation_splash',
'--hidden-import=src.splash_screen',
# Add collect-all for key packages
'--collect-all=customtkinter',
'--collect-all=selenium',
'--collect-all=webdriver_manager',
# Add debug and logging
'--debug=all',
'--log-level=DEBUG',
]
# Add all required data files and folders
additional_data = [
('src', 'src'),
('licensing', 'licensing'),
('requirements.txt', '.'),
('README.md', '.'),
('tt-backup.py', '.'),
('web', 'web'),
('assets', 'assets'),
]
for src, dst in additional_data:
if os.path.exists(src):
args.append(f'--add-data={src};{dst}')
# Run PyInstaller
PyInstaller.__main__.run(args)
if __name__ == "__main__":
# Clean previous builds
for dir_name in ['build', 'dist']:
if os.path.exists(dir_name):
import shutil
shutil.rmtree(dir_name)
# Install required packages
os.system(f"{sys.executable} -m pip install -r requirements.txt")
os.system(f"{sys.executable} -m pip install pillow pyinstaller")
# Build the executable
build_exe()
print("\nBuild complete! Executable is in the dist folder.")