# -*- mode: python ; coding: utf-8 -*-
# 目录版：无 onefile 解压、无 exe 旁 runtime 文件夹，DLL 与主程序同发行目录，可避免
# 「Failed to load Python DLL / 找不到指定的模块」（onefile 在 %TEMP%/_MEI 下偶发）。
# 构建: pyinstaller build_onedir.spec
# 发布: 将 dist/CursorTokenLogin/ 整夹打包 zip；用户解压后运行 CursorTokenLogin.exe
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"))
if not os.path.isfile(_LOGO_ICO):
    raise FileNotFoundError(
        "找不到图标文件: %s\n请将 logo.ico 放在与 build_onedir.spec 同一目录后重新打包。" % _LOGO_ICO
    )
_LOGO_ICO_ABS = os.path.abspath(_LOGO_ICO)

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,
    [],
    exclude_binaries=True,
    name='CursorTokenLogin',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=False,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon=_LOGO_ICO_ABS,
)

coll = COLLECT(
    exe,
    a.binaries,
    a.zipfiles,
    a.datas,
    strip=False,
    upx=False,
    upx_exclude=[],
    name='CursorTokenLogin',
)
