agkyra.spec 2.12 KB
Newer Older
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
1 2 3
# -*- mode: python -*-
import glob
import os
4 5 6 7 8 9 10
import sys

def iswin():
    return sys.platform.startswith("win")

def isosx():
    return sys.platform.startswith("darwin")
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

HERE = os.getcwd()

a = Analysis(['agkyra/scripts/agkyra'],
             pathex=[HERE],
             hiddenimports=[],
             hookspath=None,
             runtime_hooks=None)

def extra_datas(prefix, path):
    def recursive_glob(path, files):
        for file_path in glob.glob(path):
            if os.path.isfile(file_path):
                files.append(os.path.join(prefix, file_path))
            recursive_glob('{}/*'.format(file_path), files)

    files = []
    extra_datas = []

    full_path = os.path.join(prefix, path)
    if os.path.isfile(full_path):
        files.append(full_path)
    else:
        recursive_glob('{}/*'.format(full_path), files)

    for f in files:
        extra_datas.append((f.split(prefix)[1][1:], f, 'DATA'))
    return extra_datas

a.datas += extra_datas(os.path.join(HERE, 'agkyra'), os.path.join('resources', 'nwjs'))
a.datas += extra_datas(os.path.join(HERE, 'agkyra'), os.path.join('resources', 'nwgui'))
a.datas += extra_datas(os.path.join(HERE, 'agkyra'), os.path.join('resources', 'ui_data'))
43
a.datas += extra_datas(os.path.join(HERE, 'agkyra'), os.path.join('resources', 'main.json'))
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
44
a.datas += extra_datas(os.path.join(HERE, 'agkyra'), os.path.join('resources', 'cacert.pem'))
45
a.datas += extra_datas(os.path.join(HERE, 'agkyra'), os.path.join('resources', 'defaults.conf'))
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
46 47 48 49 50

pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
51
          name='agkyra.exe' if iswin() else 'agkyra',
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
52 53 54
          debug=False,
          strip=None,
          upx=True,
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
55
          console=isosx())
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
56 57 58 59 60 61 62
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=None,
               upx=True,
               name='agkyra')
63 64 65 66
if isosx():
    app = BUNDLE(coll,
                 name='agkyra.app',
                 icon=None)
67 68 69
    import shutil
    shutil.copy2('agkyra/resources/nwgui/static/images/logo.icns',
                 'dist/agkyra.app/Contents/Resources/icon-windowed.icns')