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