]>
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 | ||
1f6cf754 U |
25 | now = datetime.now() |
26 | # ver = f'{datetime.today():%Y.%m.%d}' | |
27 | ver = now.strftime("%Y.%m.%d") | |
915f2a92 U |
28 | rev = '' |
29 | ||
30 | if old_ver == ver: | |
31 | if old_rev: | |
32 | rev = int(old_rev) + 1 | |
33 | else: | |
34 | rev = 1 | |
35 | ||
36 | _SEPARATOR = '-' | |
37 | ||
38 | version = _SEPARATOR.join(filter(None, [ver, str(rev)])) | |
39 | ||
40 | print(version) | |
41 | ||
42 | version_list = ver.split(".") | |
43 | _year, _month, _day = [int(value) for value in version_list] | |
44 | _rev = 0 | |
45 | if rev: | |
46 | _rev = rev | |
47 | _ver_tuple = _year, _month, _day, _rev | |
48 | ||
49 | version_file = VSVersionInfo( | |
50 | ffi=FixedFileInfo( | |
51 | filevers=_ver_tuple, | |
52 | prodvers=_ver_tuple, | |
53 | mask=0x3F, | |
54 | flags=0x0, | |
55 | OS=0x4, | |
56 | fileType=0x1, | |
57 | subtype=0x0, | |
58 | date=(0, 0), | |
59 | ), | |
60 | kids=[ | |
61 | StringFileInfo( | |
62 | [ | |
63 | StringTable( | |
64 | "040904B0", | |
65 | [ | |
66 | StringStruct("Comments", "Youtube-dlc Command Line Interface."), | |
67 | StringStruct("CompanyName", "theidel@uni-bremen.de"), | |
68 | StringStruct("FileDescription", FILE_DESCRIPTION), | |
69 | StringStruct("FileVersion", version), | |
70 | StringStruct("InternalName", "youtube-dlc"), | |
71 | StringStruct( | |
72 | "LegalCopyright", | |
73 | "theidel@uni-bremen.de | UNLICENSE", | |
74 | ), | |
75 | StringStruct("OriginalFilename", "youtube-dlc.exe"), | |
76 | StringStruct("ProductName", "Youtube-dlc"), | |
77 | StringStruct("ProductVersion", version + " | git.io/JUGsM"), | |
78 | ], | |
79 | ) | |
80 | ] | |
81 | ), | |
82 | VarFileInfo([VarStruct("Translation", [0, 1200])]) | |
83 | ] | |
84 | ) | |
85 | ||
86 | PyInstaller.__main__.run([ | |
87 | '--name=youtube-dlc', | |
88 | '--onefile', | |
89 | '--icon=win/icon/cloud.ico', | |
90 | 'youtube_dlc/__main__.py', | |
91 | ]) | |
92 | SetVersion('dist/youtube-dlc.exe', version_file) |