[Pythonmac-SIG] py2app: How can I run tests using the bundled python interpreter?

Ronald Oussoren ronaldoussoren at mac.com
Tue Nov 5 16:24:48 CET 2013


On 1 Nov, 2013, at 21:10, Berg, Stuart <bergs at janelia.hhmi.org> wrote:

> Hi all,
> 
> I just posted a question about py2app to stackoverflow:
> http://stackoverflow.com/questions/19734558/py2app-how-can-i-run-tests-using-the-bundled-python-interpreter
> 
> For your convenience, I've also pasted the question below.  Any responses (via your preferred venue :-) are much appreciated.
> 
> Many thanks,
> Stuart
> 
> I use py2app to package my application.  A few quick notes about my app:
> 
> - It uses a special python executable (i.e. non-system python), which py2app includes in the bundle.
> - I explicitly exclude a few packages from site-packages.zip using the py2app recipe feature.
> 
> In the past, I've sometimes had issues with my app bundle because I forgot to exclude certain packages from site-packages.zip.  This was easy to fix once I discovered the problem, but I wasn't quick to discover it because the packages in question *mostly* worked.  The problem only showed itself after testing special cases that happen to exercise specific submodules in the problematic dependency.
> 
> In order to avoid problems like this in the future, I want to run a test suite using the same exact interpreter that py2app includes in my bundle.  For that to work, I need the proper environment setup that is somehow automatically created when the app starts up (including PYTHONPATH, DYLD_LIBRARY_PATH, etc.).
> 
> Just using ./dist/MyBundle.app/Contents/MacOS/python to run my tests doesn't seem to do the trick.  What's the recommended method to run tests on the fully built app bundle itself?

Recent versions of py2app have a way to specify secondary python scripts to be included in the app bundle (the --extra-scripts option, introduced in version 0.7). You could use that to include the test script in the app bundle and launch it using the helper binary in ./dist/MyBundle.app/Contents/MacOS. 

A helper script to launch a script with the right environment could also be useful (that way you don't have to copy your script in the application bundle). Could you file an issue about this in the py2app tracker (<https://bitbucket.org/ronaldoussoren/py2app/issues>)?

Ronald

> 
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> https://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG



More information about the Pythonmac-SIG mailing list