2********************************************************************************
3@file generate_version_file.py
4@brief Utility script to create a version info .txt file for the executable.
5********************************************************************************
13from PyInstaller.utils.win32.versioninfo
import VSVersionInfo, FixedFileInfo, StringFileInfo, StringTable, StringStruct, VarFileInfo, VarStruct
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__
19log = logging.getLogger(
"GenerateVersionFile")
22versionInfo = VSVersionInfo(
26 filevers=(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_BUILD),
27 prodvers=(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_BUILD),
47 StringStruct(
"FileDescription", __description__),
48 StringStruct(
"FileVersion", __version__),
49 StringStruct(
"LegalCopyright", __copyright__),
50 StringStruct(
"ProductName", __title__),
51 StringStruct(
"ProductVersion", __version__)
54 VarFileInfo([VarStruct(
"Translation", [1033, 1252])])
59def generate_version_file(s_filename: str, s_workpath: str) ->
None:
61 @brief Generate version file
62 @param s_filename : version file name
63 @param s_workpath : workpath
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):
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))
75if __name__ ==
"__main__":
76 workpath = sys.argv[1]
77 filename =
"version_info.txt"
78 generate_version_file(filename, workpath)