# -*- mode: python ; coding: utf-8 -*-


import sys
import shutil
import lc18report
from os import path

site_packages = next(p for p in sys.path if 'site-packages' in p)
version = lc18report.__version__
block_cipher = pyi_crypto.PyiBlockCipher(
    key='w!z%C*F-JaNdRgUkXp2s5u8x/A?D(G+K')


a = Analysis(
    ['run.py'],
    pathex=[
        'Y:\\wangyifan\\projects\\proj-003-PN1956QLD\\report_automation'],
    binaries=[],
    datas=[
        (path.join(site_packages,"docx","templates"), "docx/templates"),
        (path.join(site_packages,"lxml","_elementpath.py"), "lxml"),
        (path.join(site_packages, 'Cryptodome'), 'Cryptodome'),
        (path.join(site_packages, 'lc18report/kdb'), 'lc18report/kdb'),
        (path.join(site_packages, 'lc18report/template'), 'lc18report/template'),
    ],
    hiddenimports=[
        'lc18report', 'Cryptodome', 'docx', 'pandas', 'yaml',
        'openpyxl', 'xlrd'
    ],
    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='run',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True,
          disable_windowed_traceback=False,
          target_arch=None,
          codesign_identity=None,
          entitlements_file=None,
          icon='run.ico')
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               upx_exclude=[],
               name=f'lc18_report_cli-{version}')


def clean_up():
    build_dir = 'build'
    shutil.rmtree(build_dir, ignore_errors=True)

clean_up()