]>
Commit | Line | Data |
---|---|---|
915f2a92 U |
1 | from PyInstaller.utils.win32.versioninfo import ( |
2 | VarStruct, VarFileInfo, StringStruct, StringTable, | |
3 | StringFileInfo, FixedFileInfo, VSVersionInfo, SetVersion, | |
4 | ) | |
5 | import PyInstaller.__main__ | |
6 | ||
7 | from datetime import datetime | |
8 | ||
9 | FILE_DESCRIPTION = 'Media Downloader' | |
10 | ||
11 | exec(compile(open('youtube_dlc/version.py').read(), 'youtube_dlc/version.py', 'exec')) | |
12 | ||
13 | _LATEST_VERSION = locals()['__version__'] | |
14 | ||
15 | _OLD_VERSION = _LATEST_VERSION.rsplit("-", 1) | |
16 | ||
17 | if len(_OLD_VERSION) > 0: | |
18 | old_ver = _OLD_VERSION[0] | |
19 | ||
20 | old_rev = '' | |
21 | if len(_OLD_VERSION) > 1: | |
22 | old_rev = _OLD_VERSION[1] | |
23 | ||
24 | ver = f'{datetime.today():%Y.%m.%d}' | |
25 | rev = '' | |
26 | ||
27 | if old_ver == ver: | |
28 | if old_rev: | |
29 | rev = int(old_rev) + 1 | |
30 | else: | |
31 | rev = 1 | |
32 | ||
33 | _SEPARATOR = '-' | |
34 | ||
35 | version = _SEPARATOR.join(filter(None, [ver, str(rev)])) | |
36 | ||
37 | print(version) | |
38 | ||
39 | version_list = ver.split(".") | |
40 | _year, _month, _day = [int(value) for value in version_list] | |
41 | _rev = 0 | |
42 | if rev: | |
43 | _rev = rev | |
44 | _ver_tuple = _year, _month, _day, _rev | |
45 | ||
46 | version_file = VSVersionInfo( | |
47 | ffi=FixedFileInfo( | |
48 | filevers=_ver_tuple, | |
49 | prodvers=_ver_tuple, | |
50 | mask=0x3F, | |
51 | flags=0x0, | |
52 | OS=0x4, | |
53 | fileType=0x1, | |
54 | subtype=0x0, | |
55 | date=(0, 0), | |
56 | ), | |
57 | kids=[ | |
58 | StringFileInfo( | |
59 | [ | |
60 | StringTable( | |
61 | "040904B0", | |
62 | [ | |
63 | StringStruct("Comments", "Youtube-dlc Command Line Interface."), | |
64 | StringStruct("CompanyName", "theidel@uni-bremen.de"), | |
65 | StringStruct("FileDescription", FILE_DESCRIPTION), | |
66 | StringStruct("FileVersion", version), | |
67 | StringStruct("InternalName", "youtube-dlc"), | |
68 | StringStruct( | |
69 | "LegalCopyright", | |
70 | "theidel@uni-bremen.de | UNLICENSE", | |
71 | ), | |
72 | StringStruct("OriginalFilename", "youtube-dlc.exe"), | |
73 | StringStruct("ProductName", "Youtube-dlc"), | |
74 | StringStruct("ProductVersion", version + " | git.io/JUGsM"), | |
75 | ], | |
76 | ) | |
77 | ] | |
78 | ), | |
79 | VarFileInfo([VarStruct("Translation", [0, 1200])]) | |
80 | ] | |
81 | ) | |
82 | ||
83 | PyInstaller.__main__.run([ | |
84 | '--name=youtube-dlc', | |
85 | '--onefile', | |
86 | '--icon=win/icon/cloud.ico', | |
87 | 'youtube_dlc/__main__.py', | |
88 | ]) | |
89 | SetVersion('dist/youtube-dlc.exe', version_file) |