-
Notifications
You must be signed in to change notification settings - Fork 36
/
postcompiler.spec
86 lines (77 loc) · 2.33 KB
/
postcompiler.spec
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
"""Build the postcompiler script."""
import shutil
from pathlib import Path
from PyInstaller.utils.hooks import collect_submodules
import versioningit
# PyInstaller-injected.
SPECPATH: str
workpath: str
root = Path(SPECPATH) # noqa
version = versioningit.get_version(SPECPATH, {
'vcs': {'method': 'git'},
'default-version': '(dev)',
'format': {
'distance': '{version}.dev_{distance}+{rev}',
'dirty': '{version}+dirty_{build_date:%Y%m%d}',
'distance-dirty': '{version}.dev_{distance}+{rev}.dirty_{build_date:%Y%m%d}',
},
})
with open(Path(SPECPATH, 'src', 'hammeraddons', '_version.py'), 'w') as f:
f.write(f'__version__ = {version!r}\n')
DATAS = [
(str(root / 'crowbar_command/Crowbar.exe'), '.'),
(str(root / 'crowbar_command/FluentCommandLineParser.dll'), '.'),
]
a = Analysis(
['src/hammeraddons/postcompiler.py'],
binaries=[],
datas=DATAS,
hiddenimports=[
# Ensure these modules are available for plugins.
'abc', 'array', 'base64', 'binascii', 'graphlib',
'bisect', 'colorsys', 'collections', 'csv', 'datetime', 'contextlib',
'decimal', 'difflib', 'enum', 'fractions', 'functools',
'io', 'itertools', 'json', 'math', 'random', 're',
'statistics', 'string', 'struct',
*collect_submodules('srctools', filter=lambda name: 'scripts' not in name),
*collect_submodules('attr'),
*collect_submodules('attrs'),
*collect_submodules('hammeraddons'),
],
excludes=[
'IPython', # Via trio
],
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='postcompiler',
debug=False,
bootloader_ignore_signals=False,
# Don't use bin/, in case someone puts this right in a game dir.
contents_directory='binaries',
strip=False,
upx=True,
console=True,
icon="postcompiler.ico",
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='postcompiler'
)
# Copy transforms to the same place as the EXE, not into the binaries subfolder.
app_folder = Path(coll.name)
for file in (root / 'transforms').rglob('*.py'):
dest = app_folder / file.relative_to(root)
print(file, '->', dest)
dest.parent.mkdir(parents=True, exist_ok=True)
shutil.copy(file, dest)