pyinstaller --windowed --onefile --clean --noconfirm HelloWorld.py
生成的对应文件 HelloWorld.spec 是打包配置文件,也可以通过配置文件进行打包:
pyinstaller --windowed --onefile --clean --noconfirm HelloWorld.spec
通过配置文件,我们可以对打包程序做更多的自定义处理,
比如在Mac上打包的程序默认在 Retina 高清屏幕下是分辨率不够高的,呈模糊状态
可以添加app的配置:
info_plist={ 'NSHighResolutionCapable': True }
大概样子如下,
# -*- mode: python -*- block_cipher = None a = Analysis(['HelloWorld.py'], pathex=['/Users/user/Projects/python-wxpython'], binaries=[], datas=[], hiddenimports=[], hookspath=[], runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, noarchive=False) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas, [], name='HelloWorld', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, runtime_tmpdir=None, console=False ) app = BUNDLE(exe, name='HelloWorld.app', icon=None, bundle_identifier=None, info_plist={ 'NSHighResolutionCapable': True })
我们使用配置文件再次打包,此时的程序就可以在高清屏下显示分辨率正常了
pyinstaller --windowed --onefile --clean --noconfirm HelloWorld.spec