开发者

py2app prescripts

开发者 https://www.devze.com 2022-12-25 06:07 出处:网络
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开发者_Python百科

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开发者_Python百科 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消