pyinstaller 打包flask工程exe

小豆苗 4月前 ⋅ 427 阅读

废话不多,直接贴过程,懂得都懂,不懂的自行学习。如果没按照pyinstaller的要先安装,安装命令:pip install pyinstaller

 

1. windowns下,这样用就可以

pyinstaller --clean -F --add-data templates;templates --add-data static/css/;static/css/ --add-data static/js/;static/js/ --add-data static/images/;static/images/ main.py

2. exe包,添加版本信息

pyinstaller -F --version-file file_version_info.txt main.py

3. version-info范例

# 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, 0, 0, 0),
    prodvers=(1, 0, 0, 0),
    # 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'000004b0',
        [StringStruct(u'Comments', u''),
        StringStruct(u'CompanyName', u'test'),
        StringStruct(u'FileDescription', u'test'),
        StringStruct(u'FileVersion', u'1.0.0.0'),
        StringStruct(u'InternalName', u'test'),
        StringStruct(u'LegalCopyright', u''),
        StringStruct(u'LegalTrademarks', u''),
        StringStruct(u'OriginalFilename', u'test.exe'),
        StringStruct(u'ProductName', u'test'),
        StringStruct(u'ProductVersion', u'1.0.0.0'),
        StringStruct(u'Assembly Version', u'1.0.0.0')])
      ]), 
    VarFileInfo([VarStruct(u'Translation', [0, 1200])])
  ]
)

4. exe更换icon图标

pyinstaller -F -i ./favicon.ico --version-file file_version_info.txt main.py

全部评论: 0

    我有话说: