You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.5 KiB

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