Update freeInstaller.py

This commit is contained in:
Jeffreytsai1004 2025-01-15 23:26:52 +08:00
parent d5aecad5a2
commit 9b49f216c9

View File

@ -6,11 +6,11 @@ import shutil
import sys import sys
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
# Running in a bundle (PyInstaller) # 在捆绑中运行PyInstaller
source_folder = os.path.dirname(sys.executable) source_folder = os.path.dirname(sys.executable)
source_folder = os.path.join(source_folder, "metapipeFree") source_folder = os.path.join(source_folder, "metapipeFree")
else: else:
# Running in a normal Python environment # 在正常Python环境中运行
source_folder = os.path.dirname(os.path.abspath(__file__)) source_folder = os.path.dirname(os.path.abspath(__file__))
source_folder_data = os.path.join(source_folder, "data") source_folder_data = os.path.join(source_folder, "data")
source_folder_icons = os.path.join(source_folder, "Icons") source_folder_icons = os.path.join(source_folder, "Icons")
@ -28,12 +28,12 @@ def move_files(source_folder, destination_folder):
source = os.path.join(source_folder, file_name) source = os.path.join(source_folder, file_name)
destination = os.path.join(destination_folder, file_name) destination = os.path.join(destination_folder, file_name)
if os.path.isfile(source): # Check if the item is a file if os.path.isfile(source): # 检查项是否为文件
try: try:
shutil.copy(source, destination) shutil.copy(source, destination)
except PermissionError as e: except PermissionError as e:
print(f"Permission error: {e}") print(f"Permission error: {e}")
# Handle the permission error as needed # 根据需要处理权限错误
def run(): def run():
if not source_folder == destination_folder: if not source_folder == destination_folder: