CursorTokenLogin/build.spec
2026-04-07 21:22:37 +08:00

69 lines
2.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- mode: python ; coding: utf-8 -*-
import os
try:
_SPEC_ROOT = os.path.dirname(os.path.abspath(SPEC))
except NameError:
_SPEC_ROOT = os.getcwd()
_LOGO_ICO = os.path.normpath(os.path.join(_SPEC_ROOT, "logo.ico"))
# 无此文件时 PyInstaller 会用默认图标,看起来像「没换」——必须存在且为合法 .ico文件头 00 00 01 00
if not os.path.isfile(_LOGO_ICO):
raise FileNotFoundError(
"找不到图标文件: %s\n请将 logo.ico 放在与 build.spec 同一目录后重新打包。" % _LOGO_ICO
)
_LOGO_ICO_ABS = os.path.abspath(_LOGO_ICO)
print("[build.spec] EXE 嵌入图标:", _LOGO_ICO_ABS)
block_cipher = None
_datas = [
(os.path.join(os.getcwd(), 'layout'), 'layout'),
(os.path.join(os.getcwd(), 'assets'), 'assets'),
(_LOGO_ICO_ABS, "."),
]
a = Analysis(
['main.py'],
pathex=[os.getcwd()],
binaries=[],
datas=_datas,
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='CursorTokenLogin',
debug=False,
bootloader_ignore_signals=False,
strip=False,
# UPX 压缩可能导致杀软误报或运行时无法加载 python3xx.dll发布包建议关闭
upx=False,
upx_exclude=[],
# onefile 解压目录:%LOCALAPPDATA%\CursorTokenLogin\runtime\_MEI*PyInstaller 在 Windows 上会展开环境变量)
runtime_tmpdir=r'%LOCALAPPDATA%\CursorTokenLogin\runtime',
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
# 必须用绝对路径;资源管理器若仍显示旧图标多半是 Windows 图标缓存,可改 exe 文件名或清 IconCache
icon=_LOGO_ICO_ABS,
)