What does a “version file” look like?

前端 未结 5 1914
别那么骄傲
别那么骄傲 2020-12-08 07:15

I\'ve been googling this for ages now without results. The PyInstaller manual says:

--version-file=FILE
    add a version resource from FILE to the exe

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 07:42

    Just had a quick look at the sources. It appears that the version file is expected to be Python source itself as the provided version file with be read and then eval'ed.

    The GrabVersion.py script appears to generate errors as you've already found, so I modified the __repr__ function of FixedFileInfo to manually convert tuple arguments to strings.

    The Windows cmd.exe has a Windows version resource embedded, here's the output from GrabVersion.py which you would save to a file and feed to PyInstaller.

    VSVersionInfo(
      ffi=FixedFileInfo(
        filevers=(6, 1, 7601, 17514),
        prodvers=(6, 1, 7601, 17514),
        mask=0x3f,
        flags=0x0,
        OS=0x40004,
        fileType=0x1,
        subtype=0x0,
        date=(0, 0)
        ),
      kids=[
        StringFileInfo(
          [
          StringTable(
            u'040904B0',
            [StringStruct(u'CompanyName', u'Microsoft Corporation'),
            StringStruct(u'FileDescription', u'Windows Command Processor'),
            StringStruct(u'FileVersion', u'6.1.7601.17514 (win7sp1_rtm.101119-1850)'),
            StringStruct(u'InternalName', u'cmd'),
            StringStruct(u'LegalCopyright', u'\xa9 Microsoft Corporation. All rights reserved.'),
            StringStruct(u'OriginalFilename', u'Cmd.Exe'),
            StringStruct(u'ProductName', u'Microsoft\xae Windows\xae Operating System'),
            StringStruct(u'ProductVersion', u'6.1.7601.17514')])
          ]), 
        VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
      ]
    )
    

    I haven't tried setting a version resource with PyInstaller so I'm not sure if this will work, I'd be interested in your feedback.

提交回复
热议问题