自动更新由 pyinstaller 生成的 python 可执行文件 [英] Auto updating a python executable generated with pyinstaller
问题描述
我有一个正在开发的桌面应用程序,我正在使用 PyInstaller
来生成分发文件.
I have a desktop app that I'm working on and I am using PyInstaller
to generate de distribution files.
我选择了 PyInstaller
而不是 py2exe
因为它非常易于使用而且我不需要关心 windows dll,但是当我使用 py2exe 时
我可以简单地使用 Esky 来自动更新,但我不能将它与 PyInstaller
一起使用.
I have chosen PyInstaller
over py2exe
because it is very easy to use and I don't need to care about windows dlls, but when I use py2exe
I can simply use Esky to autoupdate, but I can't use it with PyInstaller
.
所以我不知道如何启动自动更新应用程序.有人有一些想法或只是知道我如何使用 PyInstaller
和 esky?
So I don't know how to start a auto-updating application. Someone have some thoughts or just know how can I use PyInstaller
and esky?
推荐答案
您可以为您的主应用程序创建一个启动器应用程序并在那里添加所有更新逻辑.启动器应用程序执行以下操作:
You can create a launcher application for your main application and add all the update logic there. The launcher application does the following:
显示一个弹出窗口(向用户提供程序正在加载的快速反馈)
Displays a pop up (this gives a quick feedback to the user that the program is loading)
检查本地和存储库版本
如果本地<远程(比如 v1.0 < v2.0)然后:
if local < remote (say v1.0 < v2.0) then:
.... 检查远程存储库中是否存在名为 updater_v2.0.exe 的更新程序应用程序.
.... Check at the remote repository for the existence of an updater application called updater_v2.0.exe.
........如果有:下载运行它退出.(见下文)
........ If there is one: download it run it and exit. (see bellow)
........如果没有:下载最新的主应用程序exe并替换本地的(这一步要注意文件访问权限——您正在尝试写入c:\program files).
........ If there is not: download the latest main application exe and replace the local one (beware of file access rights at this step -- you're trying to write to c:\program files).
如果本地 > 远程则:
if local > remote then:
....显示错误/警告除非如果这是开发人员工作站(您需要为此设置)
.... Display an error/warning except if this is a developers workstation (you need a setting for this)
启动主应用程序.
更新程序应用程序的目的是适应获取新的主应用程序 exe 不够的情况.我还使用它来更新启动器应用程序本身(这就是启动器在运行更新程序后立即退出的原因 - 顺便说一句,在尝试覆盖 laucher 可执行文件之前给 windows 一些时间)
The purpose of the updater application is to accommodate cases where fetching a fresh main application exe is not enough. I also use it in order to update the launcher application itself (that's why the launcher is exiting as soon as it runs the updater - BTW give windows a bit of time before trying to overwrite the laucher executable)
这篇关于自动更新由 pyinstaller 生成的 python 可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!