-
Notifications
You must be signed in to change notification settings - Fork 244
/
Copy pathbuild.py
113 lines (91 loc) · 3.31 KB
/
build.py
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
import warnings
import os
import platform
import subprocess
import time
import threading
import shutil
from logo import print_logo
from dotenv import load_dotenv
# Ignore specific warnings
warnings.filterwarnings("ignore", category=SyntaxWarning)
class LoadingAnimation:
def __init__(self):
self.is_running = False
self.animation_thread = None
def start(self, message="Building"):
self.is_running = True
self.animation_thread = threading.Thread(target=self._animate, args=(message,))
self.animation_thread.start()
def stop(self):
self.is_running = False
if self.animation_thread:
self.animation_thread.join()
print("\r" + " " * 70 + "\r", end="", flush=True)
def _animate(self, message):
animation = "|/-\\"
idx = 0
while self.is_running:
print(f"\r{message} {animation[idx % len(animation)]}", end="", flush=True)
idx += 1
time.sleep(0.1)
def progress_bar(progress, total, prefix="", length=50):
filled = int(length * progress // total)
bar = "█" * filled + "░" * (length - filled)
percent = f"{100 * progress / total:.1f}"
print(f"\r{prefix} |{bar}| {percent}% Complete", end="", flush=True)
if progress == total:
print()
def simulate_progress(message, duration=1.0, steps=20):
print(f"\033[94m{message}\033[0m")
for i in range(steps + 1):
time.sleep(duration / steps)
progress_bar(i, steps, prefix="Progress:", length=40)
def build():
# Clean screen
os.system("cls" if platform.system().lower() == "windows" else "clear")
# Display logo
print_logo()
# Clean PyInstaller cache
print("\033[93m🧹 Cleaning build cache...\033[0m")
if os.path.exists('build'):
shutil.rmtree('build')
# Reload environment variables to ensure getting the latest version
load_dotenv(override=True)
version = os.getenv('VERSION', '1.0.0')
print(f"\033[93m📦 Building version: v{version}\033[0m")
try:
simulate_progress("Preparing build environment...", 0.5)
loading = LoadingAnimation()
loading.start("Building in progress")
# Set output name based on system type
system = platform.system().lower()
if system == "windows":
os_type = "windows"
ext = ".exe"
elif system == "linux":
os_type = "linux"
ext = ""
else: # Darwin
os_type = "mac"
ext = ""
output_name = f"CursorFreeVIP_{version}_{os_type}"
# Build command
build_command = f'pyinstaller --clean --noconfirm build.spec'
output_path = os.path.join('dist', f'{output_name}{ext}')
os.system(build_command)
loading.stop()
if os.path.exists(output_path):
print(f"\n\033[92m✅ Build completed!")
print(f"📦 Executable file located: {output_path}\033[0m")
else:
print("\n\033[91m❌ Build failed: Output file not found\033[0m")
return False
except Exception as e:
if loading:
loading.stop()
print(f"\n\033[91m❌ Build process error: {str(e)}\033[0m")
return False
return True
if __name__ == "__main__":
build()