YouTubeDownloader v1.1.2
YouTube content downloader
Loading...
Searching...
No Matches
generate_version_file.py
Go to the documentation of this file.
1"""!
2********************************************************************************
3@file generate_version_file.py
4@brief Utility script to create a version info .txt file for the executable.
5********************************************************************************
6"""
7
8# autopep8: off
9import sys
10import os
11import logging
12
13from PyInstaller.utils.win32.versioninfo import VSVersionInfo, FixedFileInfo, StringFileInfo, StringTable, StringStruct, VarFileInfo, VarStruct
14
15if __name__ == "__main__":
16 sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
17from Source.version import VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_BUILD, __title__, __description__, __version__, __copyright__ # pylint: disable=wrong-import-position
18
19log = logging.getLogger("GenerateVersionFile")
20# autopep8: on
21
22versionInfo = VSVersionInfo(
23 ffi=FixedFileInfo(
24 # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
25 # Set not needed items to zero 0.
26 filevers=(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_BUILD),
27 prodvers=(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_BUILD),
28 # Contains a bitmask that specifies the Boolean attributes of the file
29 mask=0x0,
30 # Contains a bitmask that specifies the Boolean attributes of the file.
31 flags=0x0,
32 # THe operating system for which this flag was designed
33 # 0x4 - NT and there no need to change it.
34 OS=0x0,
35 # The general type of file.
36 # 0x1 - the function is not defined for this fileType
37 subtype=0x0,
38 # Creation date and time stamp.
39 date=(0, 0)
40 ),
41 kids=[
42 StringFileInfo(
43 [
44 StringTable(
45 "040904E4",
46 [
47 StringStruct("FileDescription", __description__),
48 StringStruct("FileVersion", __version__),
49 StringStruct("LegalCopyright", __copyright__),
50 StringStruct("ProductName", __title__),
51 StringStruct("ProductVersion", __version__)
52 ])
53 ]),
54 VarFileInfo([VarStruct("Translation", [1033, 1252])])
55 ]
56)
57
58
59def generate_version_file(s_filename: str, s_workpath: str) -> None:
60 """!
61 @brief Generate version file
62 @param s_filename : version file name
63 @param s_workpath : workpath
64 """
65 s_version_file = os.path.join(s_workpath, s_filename)
66 log.info("Generate version file %s (Version: %s)", s_version_file, __version__)
67 if not os.path.exists(s_workpath):
68 os.mkdir(s_workpath)
69 else:
70 log.info("Directory %s already exists", s_workpath)
71 with open(s_version_file, mode="w", encoding="utf-8") as version_file:
72 version_file.write(str(versionInfo))
73
74
75if __name__ == "__main__":
76 workpath = sys.argv[1]
77 filename = "version_info.txt"
78 generate_version_file(filename, workpath)
79 sys.exit()