简体   繁体   English

py2app规范

[英]py2app prescripts

The py2app documentation mentions prescripts, being run by __boot__.py prior to the main python script. py2app文档中提到了规范,这些规范是在主要python脚本之前由__boot__.py运行的。 I couldn't find a way to easily specify any prescript on the setup.py file or build process. 我找不到一种方法可以轻松地在setup.py文件或构建过程中指定任何规范。

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. 但是,我确实设法手动“破解”了__boot__.py并在我的主要_run(main_script)之前添加了另一个_run(prescript)命令,它似乎可以正常工作。 It would however be much better using the standard py2app build process. 但是使用标准的py2app构建过程会更好。

What I'm essentially trying to do is monkey-patch my sites-packages.zip file prior to the main script being launched. 我本质上想做的是在启动主脚本之前先对我的sites-packages.zip文件进行猴子补丁。 The prescript essentially checks for updates on the server, and if there are any, downloads them, and then overwrites the site-packages.zip file. 该规定实际上检查服务器上的更新,如果有更新,则下载它们,然后覆盖site-packages.zip文件。 Much quicker than having to re-install the application from scratch. 比必须从头开始重新安装应用程序快得多。

Any ideas? 有任何想法吗?

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, 请参阅文档 :您的py2app.recipes软件包必须包含一个配方,该配方的check方法返回一个dict其中包括'prescripts'键,该键的值为,我引用,

A list of additional Python scripts to run before initializing the main script. 在初始化主脚本之前要运行的其他Python脚本的列表。 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 (eg StringIO). 规定可以是模块名称,文件名或包含Python代码的文件状对象(例如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. 该软件包(安装在计算机上)是您需要添加自己的自定义配方的地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM