From bergs at janelia.hhmi.org Fri Nov 1 21:10:35 2013 From: bergs at janelia.hhmi.org (Berg, Stuart) Date: Fri, 1 Nov 2013 20:10:35 +0000 Subject: [Pythonmac-SIG] py2app: How can I run tests using the bundled python interpreter? Message-ID: 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? From aahz at pythoncraft.com Sat Nov 2 17:48:30 2013 From: aahz at pythoncraft.com (Aahz) Date: Sat, 2 Nov 2013 09:48:30 -0700 Subject: [Pythonmac-SIG] py2app: How can I run tests using the bundled python interpreter? In-Reply-To: References: Message-ID: <20131102164830.GA28059@panix.com> On Fri, Nov 01, 2013, Berg, Stuart wrote: > > 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? Dunno about "recommended" but I just fiddled around until I got PYTHONPATH etc set up correctly -- I think I may have created some fake apps (using py2app) that dumped the env for debugging purposes. This was a couple of years ago in a previous job, so I don't have more details, sorry. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "I don't long for a gender-free society, but I would dearly love one that wasn't gender-*stupid*." --Elise Matthesen From ronaldoussoren at mac.com Tue Nov 5 16:24:48 2013 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Tue, 05 Nov 2013 16:24:48 +0100 Subject: [Pythonmac-SIG] py2app: How can I run tests using the bundled python interpreter? In-Reply-To: References: Message-ID: <92074D1D-361C-4065-A09D-FE5466D4D72D@mac.com> On 1 Nov, 2013, at 21:10, Berg, Stuart 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 ()? 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 From bergs at janelia.hhmi.org Thu Nov 7 20:34:28 2013 From: bergs at janelia.hhmi.org (Berg, Stuart) Date: Thu, 7 Nov 2013 19:34:28 +0000 Subject: [Pythonmac-SIG] py2app: How can I run tests using the bundled python interpreter? In-Reply-To: <92074D1D-361C-4065-A09D-FE5466D4D72D@mac.com> References: <92074D1D-361C-4065-A09D-FE5466D4D72D@mac.com> Message-ID: Hi Ronald, > 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. The --extra-scripts option will satisfy my needs. Thanks! Somehow I overlooked this option when reading the documentation. I didn't understand what this option actually did. > 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 ()? Done! (Issue #125) Thanks for your help, and thanks for your great work on py2app! Cheers, Stuart