views:

73

answers:

1
+1  Q: 

py2app prescripts

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?

A: 

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.

Alex Martelli
Thanks. I saw this already, but couldn't work out which kind of recipes I should add where. Ended up using a completely different solution that doesn't involve any of those after all...