Py2app preliminary scripts

The py2app documentation mentions presets executed by __boot__.py before the main python script. I could not find a way to easily specify any predicate in the setup.py file or the build process.

However, I managed to “hack” __boot__.py manually and add another _run(prescript) command to my main _run(main_script) , and it seems to work fine. However, it would be much better to use the standard py2app build process.

What I'm essentially trying to do is monkey-patch my sites-packages.zip file before running the main script. The prescription basically checks for updates on the server, and if so, downloads them, and then overwrites the site-packages.zip file. Much faster than reinstalling the application from scratch.

Any ideas?

+4
source share
1 answer

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

List of additional Python scripts for before initializing the main script. This is often used for monkey-patch enabled modules so that they work in a frozen environment. prescript can be module names, file names, or file objects containing Python (such as StringIO). Please note that if a file-like object is used, it will not currently scan additional dependencies.

See built-in recipe sources for an example. This package (as installed on your computer) is where you will need to add your own recipes.

+1
source

Source: https://habr.com/ru/post/1305530/


All Articles