summaryrefslogtreecommitdiffstats
path: root/packaging/win/delugewin.spec
blob: b6b55736527839cb1979d65f43ae2ddf226d9d3c (plain)
1
2
3
4
5
6
7
8
9
10
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# -*- mode: python -*-
import os

from PyInstaller.utils.hooks import (
    collect_data_files,
    collect_submodules,
    copy_metadata,
)

datas = []
binaries = []
hiddenimports = ['pygame', 'ifaddr']

# Collect Meta Data
datas += copy_metadata('deluge', recursive=True)
datas += copy_metadata('service-identity', recursive=True)

# Add Deluge Hidden Imports
hiddenimports += collect_submodules('deluge')

# Add stdlib as Hidden Imports.
# This is filtered list that excludes some common examples or stuff not useful in
# plugins (such as tty, mailbox, turtledemo etc.).
# It is safe to assume that 90% of that list would already be included anyway.
stdlib = [
    'string',
    're',
    'unicodedata',
    'struct',
    'codecs',
    'datetime',
    'zoneinfo',
    'calendar',
    'collections',
    'array',
    'weakref',
    'types',
    'copy',
    'enum',
    'numbers',
    'math',
    'cmath',
    'decimal',
    'fractions',
    'random',
    'statistics',
    'itertools',
    'functools',
    'operator',
    'pathlib',
    'fileinput',
    'stat',
    'tempfile',
    'glob',
    'fnmatch',
    'shutil',
    'pickle',
    'copyreg',
    'shelve',
    'marshal',
    'dom',
    'sqlite3',
    'zlib',
    'gzip',
    'bz2',
    'lzma',
    'csv',
    'hashlib',
    'hmac',
    'secrets',
    'os',
    'io',
    'time',
    'logging',
    'platform',
    'errno',
    'queue',
    'socket',
    'ssl',
    'email',
    'json',
    'mimetypes',
    'base64',
    'binhex',
    'binascii',
    'quopri',
    'uu',
    'html',
    'xml',
    'urllib',
    'http',
    'ftplib',
    'smtplib',
    'uuid',
    'xmlrpc.client',
    'ipaddress',
    'locale',
    'sys',
]
for module in stdlib:
    hiddenimports += collect_submodules(module, filter=lambda name: 'test' not in name)

# Add Hidden Imports for Plugins
hiddenimports += collect_submodules('twisted', filter=lambda name: 'test' not in name)
datas += copy_metadata('twisted', recursive=True)

# Copy UI/Plugin and translation files to where pyinstaller expects
package_data = collect_data_files('deluge')
datas += package_data

icon = [src for src, dest in package_data if src.endswith('deluge.ico')][0]

# List of executables to produce
executables = {
    'deluge-script.pyw': {'name': 'deluge', 'console': False, 'gtk': True},
    'deluge-gtk-script.pyw': {'name': 'deluge-gtk', 'console': False, 'gtk': True},
    'deluge-debug-script.py': {'name': 'deluge-debug', 'console': True, 'gtk': True},
    'deluge-console-script.py': {
        'name': 'deluge-console',
        'console': True,
        'gtk': False,
    },
    'deluged-script.pyw': {'name': 'deluged', 'console': False, 'gtk': False},
    'deluged-debug-script.py': {'name': 'deluged-debug', 'console': True, 'gtk': False},
    'deluge-web-debug-script.py': {
        'name': 'deluge-web-debug',
        'console': True,
        'gtk': False,
    },
    'deluge-web-script.pyw': {'name': 'deluge-web', 'console': False, 'gtk': False},
}

analysis = {}
exe = {}
coll = []

# Perform analysis
for e, d in executables.items():
    runtime_hooks = []
    if d['gtk']:
        runtime_hooks += [os.path.join(SPECPATH, 'pyi_rth_gtk_csd.py')]

    analysis[e] = Analysis(
        [os.path.abspath(os.path.join(HOMEPATH, os.pardir, os.pardir, 'Scripts', e))],
        pathex=[],
        binaries=binaries,
        datas=datas,
        hiddenimports=hiddenimports,
        hookspath=[],
        hooksconfig={},
        runtime_hooks=runtime_hooks,
        excludes=[],
        win_no_prefer_redirects=False,
        win_private_assemblies=False,
        cipher=None,
        noarchive=False,
    )

# Executable
for e, d in executables.items():
    exe[e] = EXE(
        PYZ(analysis[e].pure, analysis[e].zipped_data, cipher=None),
        analysis[e].scripts,
        [],
        exclude_binaries=True,
        name=d['name'],
        debug=False,
        bootloader_ignore_signals=False,
        strip=False,
        upx=True,
        icon=icon,
        console=d['console'],
        disable_windowed_traceback=False,
        target_arch=None,
        codesign_identity=None,
        entitlements_file=None,
    )

# Collect
for e, d in executables.items():
    coll += exe[e], analysis[e].binaries, analysis[e].zipfiles, analysis[e].datas

COLLECT(*coll, strip=False, upx=True, upx_exclude=[], name='Deluge')