# 可执行文件构建
# 参考
# pyinstaller
安装pyinstaller
pip install pyinstaller在命令行下执行命令
这里测试的是一个简单的flask应用
(test) lei@leideMacBook-Pro flask_t % tree . . ├── app.py ├── requirements.txt ├── routes.py └── templates └── index.html
-F打出来的是单文件 - 还有个-D选项打出来的是一个文件夹
-w没有命令行
--clean 打包完成后清理临时文件
--add-data ./templates:./templates添加额外的文件,冒号前后分别是src和dest其余选项可以看官方文档 (opens new window)
pyinstaller -F -w --clean --add-data ./templates:./templates app.py在dist目录下已经生成可执行文件,
app和app.app都可以双击执行。最主要的看懂自动生成的
app.spec文件,可以修改这个文件来做更多事情-pyinstaller可以指定已有的spec文件来进行打包。. ├── app.py ├── app.spec ├── build │ └── app │ ├── Analysis-00.toc │ ├── BUNDLE-00.toc │ ├── EXE-00.toc │ ├── PKG-00.toc │ ├── PYZ-00.pyz │ ├── PYZ-00.toc │ ├── app.pkg │ ├── base_library.zip │ ├── localpycs │ │ ├── pyimod01_archive.pyc │ │ ├── pyimod02_importers.pyc │ │ ├── pyimod03_ctypes.pyc │ │ └── struct.pyc │ ├── warn-app.txt │ └── xref-app.html ├── dist │ ├── app │ └── app.app │ └── Contents │ ├── Frameworks │ ├── Info.plist │ ├── MacOS │ │ └── app │ ├── Resources │ │ └── icon-windowed.icns │ └── _CodeSignature │ └── CodeResources ├── requirements.txt ├── routes.py └── templates └── index.html
# auto-py-to-exe
auto-py-to-exe本质上是pyinstaller的gui版本。
pip install auto-py-to-exe
# Nuitka
Nuitka