场景分支1.0.1 macm1打包成功
This commit is contained in:
73
build_mac_new.py
Normal file
73
build_mac_new.py
Normal file
@@ -0,0 +1,73 @@
|
||||
import PyInstaller.__main__
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
# 获取当前脚本所在目录
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# 清理之前的构建
|
||||
dist_dir = os.path.join(current_dir, 'dist')
|
||||
build_dir = os.path.join(current_dir, 'build')
|
||||
if os.path.exists(dist_dir):
|
||||
shutil.rmtree(dist_dir)
|
||||
if os.path.exists(build_dir):
|
||||
shutil.rmtree(build_dir)
|
||||
|
||||
# 创建必要的目录
|
||||
os.makedirs('dist', exist_ok=True)
|
||||
os.makedirs('build', exist_ok=True)
|
||||
|
||||
# 创建logs目录
|
||||
logs_dir = os.path.join(current_dir, 'logs')
|
||||
os.makedirs(logs_dir, exist_ok=True)
|
||||
|
||||
# 打包参数
|
||||
params = [
|
||||
'gui/main_mac.py', # 主程序入口
|
||||
'--name=CursorPro', # 应用名称
|
||||
'-w', # 不显示控制台窗口
|
||||
'--clean', # 清理临时文件
|
||||
'--noconfirm', # 不确认覆盖
|
||||
'--debug=imports', # 只显示导入相关的调试信息
|
||||
'--osx-bundle-identifier=com.cursor.pro', # macOS包标识符
|
||||
f'--distpath={os.path.join(current_dir, "dist")}', # 输出目录
|
||||
f'--workpath={os.path.join(current_dir, "build")}', # 工作目录
|
||||
f'--specpath={current_dir}', # spec文件目录
|
||||
'--add-data=logger.py:.', # 添加额外文件 (Mac系统使用:分隔符)
|
||||
'--add-data=update_cursor_token.py:.',
|
||||
'--add-data=cursor_auth_manager.py:.',
|
||||
'--add-data=reset_machine.py:.',
|
||||
'--add-data=patch_cursor_get_machine_id.py:.',
|
||||
'--add-data=exit_cursor.py:.',
|
||||
'--add-data=go_cursor_help.py:.',
|
||||
'--add-data=logo.py:.',
|
||||
'--add-data=config.py:.',
|
||||
'--add-data=browser_utils.py:.',
|
||||
'--add-data=get_email_code.py:.',
|
||||
'--hidden-import=PyQt5',
|
||||
'--hidden-import=PyQt5.QtCore',
|
||||
'--hidden-import=PyQt5.QtGui',
|
||||
'--hidden-import=PyQt5.QtWidgets',
|
||||
'--hidden-import=requests',
|
||||
'--hidden-import=urllib3',
|
||||
'--hidden-import=psutil',
|
||||
'--hidden-import=colorama',
|
||||
]
|
||||
|
||||
# 执行打包
|
||||
PyInstaller.__main__.run(params)
|
||||
|
||||
print("打包完成!应用程序包(.app)已生成在dist目录下。")
|
||||
|
||||
# 创建必要的目录和文件
|
||||
app_path = os.path.join(current_dir, 'dist', 'CursorPro.app', 'Contents', 'MacOS')
|
||||
if os.path.exists(app_path):
|
||||
# 创建logs目录
|
||||
os.makedirs(os.path.join(app_path, 'logs'), exist_ok=True)
|
||||
|
||||
# 创建空的error.log文件
|
||||
with open(os.path.join(app_path, 'error.log'), 'w') as f:
|
||||
f.write('')
|
||||
|
||||
print("已创建必要的目录和文件")
|
||||
Reference in New Issue
Block a user