PyInstaller,但保持.py文件可升级 [英] PyInstaller but keeping .py files upgradeable

查看:297
本文介绍了PyInstaller,但保持.py文件可升级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功地将PyQt4应用程序打包为Windows上的独立"应用程序.

I've managed to package my PyQt4 app as a "standalone" application on windows, it works.

但是此应用程序可以自我升级,方法是通过互联网下载我用新版本替换的我写的实际代码(.py文件)来实现.

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.

我如何告诉PyInstaller进行工作(将DLL放在一起,使用闪亮的图标生成启动器等),但是让.py文件保持不变?

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.

推荐答案

您可以更改规范文件以明确不按名称包含文件(在构建列表时),然后确保包含这些文件-我必须检查是否有包含但不编译的选项.

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.

我自己还没有尝试过(我在工作中使用pyInstaller,但没有在家用PC上进行设置),但这是我认为应该可以的事情:

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:

a = Analysis(['main.py'])
excluded = ['myfile0.py', 'myfile1.py', 'myfile2.py']
a.scripts = [script from script in a.scripts if script not in excluded]
pyz = PYZ(a.pure)
exe = EXE(a.scripts, pyz, name="main.exe", exclude_binaries=1)
dist = COLLECT(exe, a.binaries, excluded, name="dist")

这篇关于PyInstaller,但保持.py文件可升级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆