是否有一种方法来更新使用cx_freeze创建的应用程序?



我已经使用cx_freeze为我的python项目创建并分发了一个msi文件。我在项目中做了一些更改,比如v2.0。有没有什么方法可以让我在客户端电脑上更新应用程序,而不必再次发送msi ?

或者有其他的包库可以让我这样做吗?

您可以使用MSI升级码来升级您的应用程序。用cx_Freeze创建一个可升级的msi文件作为参考。

首先,需要为升级代码创建一个UUID (GUID):

import uuid str(uuid.uuid3(uuid.NAMESPACE_DNS, 'appname.orgname.org')).upper()

您只需将'appname.orgname.org'替换为合适的名称即可。

下一步,制备setup.py

#Application information
name = 'memopad'
version = '1.0.0'
author = 'example'
author_email = 'sample@example.xxx'
url = 'http://example.xxx'
description = 'Text Editor'
#Specify the GUID here (basically it should not be changed)
upgrade_code = '{3F2504E0-4F89-11D3-9A0C-0305E82C3301}'
#For 64-bit Windows, switch the installation folder
# ProgramFiles(64)Folder seems to be replaced with the actual directory on the msi side
programfiles_dir = 'ProgramFiles64Folder' if distutils.util.get_platform() == 'win-amd64' else 'ProgramFilesFolder'
#Options to use with the build command on Windows
build_exe_options = {
'packages': ['os'],
'excludes': ['tkinter'], #Exclude tkinter as it is not used
'includes': ['PySide.QtCore', 'PySide.QtGui', 'gui', 'commands'],
'include_files': ['img/', 'lang/', 'license/'],
'include_msvcr': True, #Since it uses PySide, it cannot be started unless Microsoft's C runtime is included.
'compressed'   : True
}
# bdist_Options to use with the msi command
bdist_msi_options = {
'upgrade_code': upgrade_code,
'add_to_path': False,
'initial_target_dir': '[%s]%s%s' % (programfiles_dir, author, name)
}
options = {
'build_exe': build_exe_options,
'bdist_msi': bdist_msi_options
}
#exe information
base = 'Win32GUI' if sys.platform == 'win32' else None
icon = 'img/app_icon.ico'
mainexe = Executable(
'main.py',
targetName = 'Memopad.exe',
base = base,
icon = icon,
copyDependentFiles = True
)
setup(
name=name,
version=version,
author=author,
author_email=author_email,
url=url,
description=description,
options=options,
executables=[mainexe]
)

请注意,如果您更改了UpgradeCode,它将不被视为相同的包,并且您将无法正确管理包。

最新更新