py2app 说明

发布于 2024-08-27 06:30:46 字数 502 浏览 9 评论 0原文

py2app 文档 提到了由 运行的说明__boot__.py 在主 python 脚本之前。我找不到一种方法可以轻松地在 setup.py 文件或构建过程中指定任何规定。

不过,我确实设法手动“破解”__boot__.py,并在我的主_run(main_script)之前添加另一个_run(prescript)命令,它似乎工作正常。然而,使用标准 py2app 构建过程会更好。

我本质上想做的是在启动主脚本之前对我的sites-packages.zip 文件进行猴子修补。该规定本质上是检查服务器上的更新,如果有,则下载它们,然后覆盖 site-packages.zip 文件。比从头开始重新安装应用程序要快得多。

有什么想法吗?

The py2app documentation mentions prescripts, being run by __boot__.py prior to the main python script. I couldn't find a way to easily specify any prescript on the setup.py file or build process.

I did however manage to 'hack' __boot__.py manually and add another _run(prescript) command before my main _run(main_script) and it seemed to work fine. It would however be much better using the standard py2app build process.

What I'm essentially trying to do is monkey-patch my sites-packages.zip file prior to the main script being launched. The prescript essentially checks for updates on the server, and if there are any, downloads them, and then overwrites the site-packages.zip file. Much quicker than having to re-install the application from scratch.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦醒时光 2024-09-03 06:30:46

请参阅文档:您的py2app.recipes 包必须包含一个配方,其 check 方法返回一个 dict,其中包含 'prescripts' 键,其值为,并且我引用,

附加 Python 脚本列表
在初始化主程序之前运行
脚本。这经常被用来
Monkey-patch 包含模块,以便
他们在冰冻的环境中工作。这
说明可以是模块名称、文件
名称或类似文件的对象包含
Python 代码(例如 StringIO)。注意
如果使用类似文件的对象,它将
当前未扫描
额外的依赖项。

有关示例,请参阅内置食谱源。您需要在该软件包(安装在您的计算机上)中添加您自己的自定义配方。

See the docs: your py2app.recipes package must contain a recipe whose check method returns a dict including the 'prescripts' key whose value is, and I quote,

A list of additional Python scripts to
run before initializing the main
script. This is often used to
monkey-patch included modules so that
they work in a frozen environment. The
prescripts may be module names, file
names, or file-like objects containing
Python code (e.g. StringIO). Note that
if a file-like object is used, it will
not currently be scanned for
additional dependencies.

See the built-in recipes sources for examples. This package (as installed on your machine) is where you'll need to add your own custom recipes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文