What does a “version file” look like?

前端 未结 5 1919
别那么骄傲
别那么骄傲 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:46

    I might be missing this in the previous answers, or maybe PyInstaller has been updated since these answers were originally provided, but the current docs for PyInstaller teach a fairly simple method for this using a command-line tool provided with PyInstaller (though I missed this section the first few times I looked to the docs).

    Point this tool at an .exe file on your system that has "good looking" version info, and it will create a human-readable, commented, editable version resource file that you can use as a starting point.

    pyi-grab_version executable_with_version_resource
    

    which by default writes a file file_version_info.txt to the working directory.

    Running the above on my local copy of svn.exe produces:

    # UTF-8
    #
    # For more details about fixed file info 'ffi' see:
    # http://msdn.microsoft.com/en-us/library/ms646997.aspx
    VSVersionInfo(
      ffi=FixedFileInfo(
    # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
    # Set not needed items to zero 0.
    filevers=(1, 9, 7, 30920),
    prodvers=(1, 9, 7, 30920),
    # Contains a bitmask that specifies the valid bits 'flags'r
    mask=0x3f,
    # Contains a bitmask that specifies the Boolean attributes of the file.
    flags=0x0,
    # The operating system for which this file was designed.
    # 0x4 - NT and there is no need to change it.
    OS=0x4,
    # The general type of file.
    # 0x1 - the file is an application.
    fileType=0x1,
    # The function of the file.
    # 0x0 - the function is not defined for this fileType
    subtype=0x0,
    # Creation date and time stamp.
    date=(0, 0)
    ),
      kids=[
    StringFileInfo(
      [
      StringTable(
        u'040904B0',
        [StringStruct(u'CompanyName', u'Apache Software Foundation'),
        StringStruct(u'FileDescription', u'svn'),
        StringStruct(u'FileVersion', u'1.9.7'),
        StringStruct(u'InternalName', u'SVN'),
        StringStruct(u'LegalCopyright', u'Copyright (c) The Apache Software Foundation'),
        StringStruct(u'OriginalFilename', u'svn.exe'),
        StringStruct(u'ProductName', u'Subversion'),
        StringStruct(u'ProductVersion', u'1.9.7 (r1800392)')])
      ]), 
    VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
      ]
    )
    

    edit this to your purpose, and feed it back to PyInstaller as a --version-file, e.g.

    pyinstaller [options] myscript.py --version-file file_version_info.txt
    

提交回复
热议问题