Repository navigation
Expand file tree
/
Copy pathmake_version_file.py
More file actions
59 lines (52 loc) · 1.84 KB
/
Copy pathmake_version_file.py
File metadata and controls
59 lines (52 loc) · 1.84 KB
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
#!/usr/bin/env python3
"""Generate a PyInstaller Windows version-info resource from __version__.
Build_EXE.bat runs this before compiling; it reads the __version__ string out
of DMPRepackGUI.py (by regex, so importing the GUI is never triggered) and
writes version_info.txt, which PyInstaller stamps into the .exe's file
properties via --version-file.
Relative paths only, so it works from any checkout location / drive.
"""
import re
from pathlib import Path
HERE = Path(__file__).resolve().parent
SRC = HERE / "DMPRepackGUI.py"
OUT = HERE / "version_info.txt"
src = SRC.read_text(encoding="utf-8")
m = re.search(r'__version__\s*=\s*["\']([^"\']+)["\']', src)
version = m.group(1) if m else "0.0.0"
# Windows FILEVERSION / PRODUCTVERSION want a 4-tuple of ints.
parts = [int(n) for n in re.findall(r"\d+", version)][:4]
parts += [0] * (4 - len(parts))
vtuple = ", ".join(str(p) for p in parts)
template = f"""# UTF-8
# Auto-generated by make_version_file.py — do not edit by hand.
VSVersionInfo(
ffi=FixedFileInfo(
filevers=({vtuple}),
prodvers=({vtuple}),
mask=0x3f,
flags=0x0,
OS=0x40004,
fileType=0x1,
subtype=0x0,
date=(0, 0)
),
kids=[
StringFileInfo([
StringTable('040904B0', [
StringStruct('CompanyName', 'ARMGDDN Games'),
StringStruct('FileDescription', 'AG Repack GUI'),
StringStruct('FileVersion', '{version}'),
StringStruct('InternalName', 'AG Repack GUI'),
StringStruct('LegalCopyright', 'DMP of ARMGDDN Games'),
StringStruct('OriginalFilename', 'AG Repack GUI.exe'),
StringStruct('ProductName', 'AG Repack GUI'),
StringStruct('ProductVersion', '{version}')
])
]),
VarFileInfo([VarStruct('Translation', [1033, 1200])])
]
)
"""
OUT.write_text(template, encoding="utf-8")
print(f"version_info.txt written for v{version} ({vtuple})")