使用pyinstaller打出最小的exe包的案例

源代码:https://github.com/JayHeng/Jays-PyCOM

打包后的大小为9.08mb。执行文件的地址:https://github.com/JayHeng/Jays-PyCOM/blob/master/bin/Jays-PyCOM.exe

 

打包步骤

pyinstaller.exe pyinstaller_pack_fw.spec
copy .\dist\Jays-PyCOM.exe ..\bin
rd /q /s .\build
rd /q /s .\dist

打包说明文件pyinstaller_pack_fw.spec

 

# -*- mode: python -*-

block_cipher = None


a = Analysis(['..\\src\\main.py',
              '..\\src\\formatter.py',
              '..\\src\\win.py'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='Jays-PyCOM',
          debug=False,
          strip=False,
          upx=True,
          runtime_tmpdir=None,
          console=False , icon='..\\img\\Jays-PyCOM.ico')

 

Author: bkdwei