PyInstaller 但保持 .py 文件可升级
我已经成功地将我的 PyQt4 应用程序打包为 Windows 上的“独立”应用程序,它可以工作。
然而,这个应用程序可以自我升级,这是通过用通过互联网下载的新版本替换我编写的实际代码(.py 文件)来完成的。
我怎样才能告诉 PyInstaller 完成它的工作(将 DLL 放在一起,生成带有闪亮图标的启动器等),但让 .py 文件保持不变?
我需要将这些文件直接存储在磁盘上,以便自动更新正常工作。
I've managed to package my PyQt4 app as a "standalone" application on windows, it works.
However this application can upgrade itself, which is done by replacing the actual code written by me (.py files) with new versions, downloaded via the internet.
How can I tell PyInstaller do its job (putting together the DLLs, generating the launcher with the shiny icon, etc), BUT let the .py files untouched?
I need those files directly on disk, in order for the auto-update to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以更改规范文件以明确不按名称包含文件(在构建列表时),然后确保包含这些文件 - 我必须检查是否有包含但不编译的选项。
我自己没有尝试过(我在工作中使用 pyInstaller,但没有在我的家用电脑上设置它),但这是我认为应该没问题的事情:
You can change the spec file to specifically not include files by name (when building lists), then make sure these files are included - I'd have to check whether there's an option to include but not compile.
I've not tried this myself (I use pyInstaller at work but don't have it set up on my home PC) but this is the sort of thing I think should be ok:
实际上它更像是这样的:
由于脚本实际上是一个具有以下形式的元组:
您可能还必须防止文件包含在 PYZ 中,请参阅 pyz 目录以查看它们是否包含在内,我设法使用 excepts=[ 排除它们myfile0] 在 Analysis() 中。
Actually it's more like this :
As script is actually a tuple with the form :
You may also have to prevent files from being included in PYZ, refer to the pyz toc to see if they get included, I managed to exlude them using excludes=[myfile0] in Analysis().
我认为可执行文件中的嵌入式解释器仍会在同一目录和/或 PYTHONPATH 中搜索 .py 文件,py2exe 使用本机 python 组件的 zip 文件,iirc pyinstaller 将所有这些文件嵌入可执行文件中,也许有一个选项像 py2exe 一样保留 zip(或者不在规范中添加它们),然后尝试在没有文件的情况下运行应用程序并使用 procmon 监视文件访问。
I think the embedded interpreter in the executable will still search for .py files in the same directory and/or PYTHONPATH, py2exe uses a zip file for native python components, iirc pyinstaller embeds all of them in the executable, maybe there is an option to keep a zip like in py2exe (or not add them in the spec), then try to run the application without the files and monitor file accesses with procmon.
pyinstaller 提供 --exclude 选项供您使用case ,也可以使用
.spec
中Analysis()
的excludes
参数设置要忽略的模块或包文件 。pyinstaller provides the --exclude option for your use case , and it is also possible to set the module or package you want to ignore using the
excludes
parameter ofAnalysis()
in the.spec
file .