From 7dc3af0798423d9c472ec00f0ed4e6e2ee46f03e Mon Sep 17 00:00:00 2001 From: cheng zhen Date: Sun, 29 Dec 2024 08:59:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CursorKeepAlive.mac.spec | 56 ---------------------------------------- CursorKeepAlive.spec | 20 +------------- CursorKeepAlive.win.spec | 44 ------------------------------- build.py | 47 +++++++++++++++++++-------------- config.ini.example | 5 ++++ 5 files changed, 33 insertions(+), 139 deletions(-) delete mode 100644 CursorKeepAlive.mac.spec delete mode 100644 CursorKeepAlive.win.spec create mode 100644 config.ini.example diff --git a/CursorKeepAlive.mac.spec b/CursorKeepAlive.mac.spec deleted file mode 100644 index c15dc91..0000000 --- a/CursorKeepAlive.mac.spec +++ /dev/null @@ -1,56 +0,0 @@ -# -*- mode: python ; coding: utf-8 -*- - -a = Analysis( - ['cursor_pro_keep_alive.py'], - pathex=[], - binaries=[], - datas=[ - ('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.spec b/CursorKeepAlive.spec index 8044369..4776be6 100644 --- a/CursorKeepAlive.spec +++ b/CursorKeepAlive.spec @@ -5,7 +5,6 @@ a = Analysis( pathex=[], binaries=[], datas=[ - ('config.ini', '.'), ('turnstilePatch', 'turnstilePatch'), ('cursor_auth_manager.py', '.'), ], @@ -19,10 +18,6 @@ a = Analysis( noarchive=False, ) -import os -if not os.path.exists('config.ini'): - raise FileNotFoundError('config.ini 文件不存在!请确保它在正确的位置。') - pyz = PYZ(a.pure) exe = EXE( @@ -45,17 +40,4 @@ exe = EXE( 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 deleted file mode 100644 index 439dbbb..0000000 --- a/CursorKeepAlive.win.spec +++ /dev/null @@ -1,44 +0,0 @@ -# -*- 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 index defebcc..0e3615b 100644 --- a/build.py +++ b/build.py @@ -2,34 +2,41 @@ 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: + spec_file = "CursorKeepAlive.spec" + + if system not in ["darwin", "windows"]: print(f"不支持的操作系统: {system}") return - + + output_dir = f"dist/{system if system != 'darwin' else 'mac'}" + # 创建输出目录 os.makedirs(output_dir, exist_ok=True) - + # 运行 PyInstaller - subprocess.run(['pyinstaller', spec_file, '--distpath', output_dir, '--workpath', f'build/{system}']) - + 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/']) + if os.path.exists("config.ini.example"): + if system == "darwin": + subprocess.run(["cp", "config.ini.example", f"{output_dir}/config.ini"]) else: - subprocess.run(['cp', 'config.ini', output_dir]) - + subprocess.run(["cp", "config.ini.example", f"{output_dir}/config.ini"]) + print(f"构建完成,输出目录: {output_dir}") -if __name__ == '__main__': - build() \ No newline at end of file + +if __name__ == "__main__": + build() diff --git a/config.ini.example b/config.ini.example new file mode 100644 index 0000000..e775c66 --- /dev/null +++ b/config.ini.example @@ -0,0 +1,5 @@ +[Account] +email = xxx@mailto.plus +password = xxxx +first_name = xxx +last_name = xxx