feat: 删除无用依赖 sys
This commit is contained in:
59
build.py
59
build.py
@@ -2,7 +2,6 @@ import warnings
|
|||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
@@ -18,6 +17,7 @@ CURSOR_LOGO = """
|
|||||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝
|
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class LoadingAnimation:
|
class LoadingAnimation:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.is_running = False
|
self.is_running = False
|
||||||
@@ -42,38 +42,46 @@ class LoadingAnimation:
|
|||||||
idx += 1
|
idx += 1
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
def print_logo():
|
def print_logo():
|
||||||
print("\033[96m" + CURSOR_LOGO + "\033[0m")
|
print("\033[96m" + CURSOR_LOGO + "\033[0m")
|
||||||
print("\033[93m" + "Building Cursor Keep Alive...".center(56) + "\033[0m\n")
|
print("\033[93m" + "Building Cursor Keep Alive...".center(56) + "\033[0m\n")
|
||||||
|
|
||||||
def progress_bar(progress, total, prefix='', length=50):
|
|
||||||
|
def progress_bar(progress, total, prefix="", length=50):
|
||||||
filled = int(length * progress // total)
|
filled = int(length * progress // total)
|
||||||
bar = '█' * filled + '░' * (length - filled)
|
bar = "█" * filled + "░" * (length - filled)
|
||||||
percent = f"{100 * progress / total:.1f}"
|
percent = f"{100 * progress / total:.1f}"
|
||||||
print(f'\r{prefix} |{bar}| {percent}% Complete', end='', flush=True)
|
print(f"\r{prefix} |{bar}| {percent}% Complete", end="", flush=True)
|
||||||
if progress == total:
|
if progress == total:
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
def simulate_progress(message, duration=1.0, steps=20):
|
def simulate_progress(message, duration=1.0, steps=20):
|
||||||
print(f"\033[94m{message}\033[0m")
|
print(f"\033[94m{message}\033[0m")
|
||||||
for i in range(steps + 1):
|
for i in range(steps + 1):
|
||||||
time.sleep(duration / steps)
|
time.sleep(duration / steps)
|
||||||
progress_bar(i, steps, prefix='Progress:', length=40)
|
progress_bar(i, steps, prefix="Progress:", length=40)
|
||||||
|
|
||||||
|
|
||||||
def filter_output(output):
|
def filter_output(output):
|
||||||
"""ImportantMessage"""
|
"""ImportantMessage"""
|
||||||
if not output:
|
if not output:
|
||||||
return ""
|
return ""
|
||||||
important_lines = []
|
important_lines = []
|
||||||
for line in output.split('\n'):
|
for line in output.split("\n"):
|
||||||
# Only keep lines containing specific keywords
|
# Only keep lines containing specific keywords
|
||||||
if any(keyword in line.lower() for keyword in ['error:', 'failed:', 'completed', 'directory:']):
|
if any(
|
||||||
|
keyword in line.lower()
|
||||||
|
for keyword in ["error:", "failed:", "completed", "directory:"]
|
||||||
|
):
|
||||||
important_lines.append(line)
|
important_lines.append(line)
|
||||||
return '\n'.join(important_lines)
|
return "\n".join(important_lines)
|
||||||
|
|
||||||
|
|
||||||
def build():
|
def build():
|
||||||
# Clear screen
|
# Clear screen
|
||||||
os.system('cls' if platform.system().lower() == "windows" else 'clear')
|
os.system("cls" if platform.system().lower() == "windows" else "clear")
|
||||||
|
|
||||||
# Print logo
|
# Print logo
|
||||||
print_logo()
|
print_logo()
|
||||||
@@ -99,7 +107,7 @@ def build():
|
|||||||
output_dir,
|
output_dir,
|
||||||
"--workpath",
|
"--workpath",
|
||||||
f"build/{system}",
|
f"build/{system}",
|
||||||
"--noconfirm"
|
"--noconfirm",
|
||||||
]
|
]
|
||||||
|
|
||||||
loading = LoadingAnimation()
|
loading = LoadingAnimation()
|
||||||
@@ -107,20 +115,22 @@ def build():
|
|||||||
simulate_progress("Running PyInstaller...", 2.0)
|
simulate_progress("Running PyInstaller...", 2.0)
|
||||||
loading.start("Building in progress")
|
loading.start("Building in progress")
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
pyinstaller_command,
|
pyinstaller_command, check=True, capture_output=True, text=True
|
||||||
check=True,
|
|
||||||
capture_output=True,
|
|
||||||
text=True
|
|
||||||
)
|
)
|
||||||
loading.stop()
|
loading.stop()
|
||||||
|
|
||||||
if result.stderr:
|
if result.stderr:
|
||||||
filtered_errors = [line for line in result.stderr.split('\n')
|
filtered_errors = [
|
||||||
if any(keyword in line.lower()
|
line
|
||||||
for keyword in ['error:', 'failed:', 'completed', 'directory:'])]
|
for line in result.stderr.split("\n")
|
||||||
|
if any(
|
||||||
|
keyword in line.lower()
|
||||||
|
for keyword in ["error:", "failed:", "completed", "directory:"]
|
||||||
|
)
|
||||||
|
]
|
||||||
if filtered_errors:
|
if filtered_errors:
|
||||||
print("\033[93mBuild Warnings/Errors:\033[0m")
|
print("\033[93mBuild Warnings/Errors:\033[0m")
|
||||||
print('\n'.join(filtered_errors))
|
print("\n".join(filtered_errors))
|
||||||
|
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
loading.stop()
|
loading.stop()
|
||||||
@@ -131,7 +141,9 @@ def build():
|
|||||||
return
|
return
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
loading.stop()
|
loading.stop()
|
||||||
print("\033[91mError: Please ensure PyInstaller is installed (pip install pyinstaller)\033[0m")
|
print(
|
||||||
|
"\033[91mError: Please ensure PyInstaller is installed (pip install pyinstaller)\033[0m"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
loading.stop()
|
loading.stop()
|
||||||
@@ -144,11 +156,16 @@ def build():
|
|||||||
if os.path.exists("config.ini.example"):
|
if os.path.exists("config.ini.example"):
|
||||||
simulate_progress("Copying configuration file...", 0.5)
|
simulate_progress("Copying configuration file...", 0.5)
|
||||||
if system == "windows":
|
if system == "windows":
|
||||||
subprocess.run(["copy", "config.ini.example", f"{output_dir}\\config.ini"], shell=True)
|
subprocess.run(
|
||||||
|
["copy", "config.ini.example", f"{output_dir}\\config.ini"], shell=True
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
subprocess.run(["cp", "config.ini.example", f"{output_dir}/config.ini"])
|
subprocess.run(["cp", "config.ini.example", f"{output_dir}/config.ini"])
|
||||||
|
|
||||||
print(f"\n\033[92mBuild completed successfully! Output directory: {output_dir}\033[0m")
|
print(
|
||||||
|
f"\n\033[92mBuild completed successfully! Output directory: {output_dir}\033[0m"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
build()
|
build()
|
||||||
Reference in New Issue
Block a user