图像

pyinstaller zip python to exe

最近在写微信脚本工具,为了让同事方便使用,我把它们打包为exe,我用了三款工具,pyinstaller用起来比较好,适合喜欢自定义的家伙。
具体的使用官方都有,我就不重复了,下面的片段一是做笔记,二是这个版本信息值得参考。

bash

pyinstaller getuserinfo.py --noconfirm --log-level=WARN --onefile --nowindow --upx-dir=upx -F --icon=lst.ico --version-file=verson.txt --paths=D:/soft/Python27/Lib/site-packages/django

version.txt

VSVersionInfo(
  ffi=FixedFileInfo(
    filevers=(1, 0, 0, 0),
    prodvers=(1, 0, 0, 1),
    mask=0x3f,
    flags=0x0,
    OS=0x40004,
    fileType=0x1,
    subtype=0x0,
    date=(0, 0)
    ),
  kids=[
    StringFileInfo(
      [
      StringTable(
        u'040904B0',
        [StringStruct(u'CompanyName', u'Connove Software'),
        StringStruct(u'FileDescription', u'Get User Information From Wechat'),
        StringStruct(u'FileVersion', u'Windows'),
        StringStruct(u'InternalName', u'mpwxuser'),
        StringStruct(u'LegalCopyright', u'\xa9 Microsoft Corporation. All rights reserved.'),
        StringStruct(u'OriginalFilename', u'MpWeChatUser.Exe'),
        StringStruct(u'ProductName', u'Connove\xae Software'),
        StringStruct(u'ProductVersion', u'1.0.0.1')])
      ]),
    VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
  ]
)

getuserinfo.spec

# -*- mode: python -*-
a = Analysis(['getuserinfo.py'],
             pathex=['D:\\soft\\Python27\\Lib\\site-packages\\django', 'F:\\pycode\\wechatuser\\wechat'],
             hiddenimports=[],
             hookspath=None,
             runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='GetUserInfo.exe',
          debug=False,
          strip=None,
          upx=True,
          console=True , version='verson.txt', icon='lst.ico')

发表评论