From 85c83a9d6214d34a7041f93bcf72fb3fc54f1a70 Mon Sep 17 00:00:00 2001 From: cheng zhen Date: Sat, 28 Dec 2024 20:08:49 +0800 Subject: [PATCH] Implement build system for Cursor Pro with platform-specific packaging - Added build.py script to automate the packaging process for macOS and Windows. - Created CursorKeepAlive.mac.spec and CursorKeepAlive.win.spec for application specifications. - Updated .gitignore to exclude build artifacts and IDE files. - Enhanced directory structure for output files and included configuration file handling in the build process. --- .gitignore | 25 +++++++++++++++--- CursorKeepAlive.mac.spec | 57 ++++++++++++++++++++++++++++++++++++++++ CursorKeepAlive.win.spec | 44 +++++++++++++++++++++++++++++++ build.py | 35 ++++++++++++++++++++++++ 4 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 CursorKeepAlive.mac.spec create mode 100644 CursorKeepAlive.win.spec create mode 100644 build.py diff --git a/.gitignore b/.gitignore index 6b606d2..3e6e208 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,23 @@ -.idea -__pycache__ +# PyInstaller +build/ +dist/ +*.spec +!CursorKeepAlive.mac.spec +!CursorKeepAlive.win.spec -build +# Python +__pycache__/ +*.py[cod] +*$py.class -venv +# Logs +*.log + +# IDE +.vscode/ +.idea/ + +# Mac +.DS_Store + +venv/ diff --git a/CursorKeepAlive.mac.spec b/CursorKeepAlive.mac.spec new file mode 100644 index 0000000..5dbdff4 --- /dev/null +++ b/CursorKeepAlive.mac.spec @@ -0,0 +1,57 @@ +# -*- mode: python ; coding: utf-8 -*- + +a = Analysis( + ['cursor_pro_keep_alive.py'], + pathex=[], + binaries=[], + datas=[ + ('config.ini', '.'), + ('turnstilePatch', 'turnstilePatch'), + ('cursor_auth_manager.py', '.'), + ], + hiddenimports=[ + 'cursor_auth_manager' + ], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, +) + +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='CursorPro', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, + icon=None +) + +app = BUNDLE( + exe, + name='CursorPro.app', + icon=None, + bundle_identifier='com.yourcompany.cursorpro', + info_plist={ + 'CFBundleShortVersionString': '1.0.0', + 'CFBundleVersion': '1.0.0', + 'NSHighResolutionCapable': True, + 'LSBackgroundOnly': False, + }, +) \ No newline at end of file diff --git a/CursorKeepAlive.win.spec b/CursorKeepAlive.win.spec new file mode 100644 index 0000000..439dbbb --- /dev/null +++ b/CursorKeepAlive.win.spec @@ -0,0 +1,44 @@ +# -*- mode: python ; coding: utf-8 -*- + +a = Analysis( + ['cursor_pro_keep_alive.py'], + pathex=[], + binaries=[], + datas=[ + ('config.ini', '.'), + ('turnstilePatch', 'turnstilePatch'), + ('cursor_auth_manager.py', '.'), + ], + hiddenimports=[ + 'cursor_auth_manager' + ], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, +) + +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='CursorPro', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, + icon=None +) \ No newline at end of file diff --git a/build.py b/build.py new file mode 100644 index 0000000..defebcc --- /dev/null +++ b/build.py @@ -0,0 +1,35 @@ +import os +import platform +import subprocess + +def build(): + system = platform.system().lower() + + if system == 'darwin': + spec_file = 'CursorKeepAlive.mac.spec' + output_dir = 'dist/mac' + elif system == 'windows': + spec_file = 'CursorKeepAlive.win.spec' + output_dir = 'dist/windows' + else: + print(f"不支持的操作系统: {system}") + return + + # 创建输出目录 + os.makedirs(output_dir, exist_ok=True) + + # 运行 PyInstaller + subprocess.run(['pyinstaller', spec_file, '--distpath', output_dir, '--workpath', f'build/{system}']) + + # 复制配置文件 + if os.path.exists('config.ini'): + if system == 'darwin': + os.makedirs(f'{output_dir}/CursorPro.app/Contents/MacOS', exist_ok=True) + subprocess.run(['cp', 'config.ini', f'{output_dir}/CursorPro.app/Contents/MacOS/']) + else: + subprocess.run(['cp', 'config.ini', output_dir]) + + print(f"构建完成,输出目录: {output_dir}") + +if __name__ == '__main__': + build() \ No newline at end of file