0

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?

Stuart Berg
  • 17,026
  • 12
  • 67
  • 99
  • It's been awhile since I've used py2app, but I recall the info.plist of the app containing a bunch of python environment stuff. – Brad Allred Nov 01 '13 at 20:11
  • What are you using to run tests? Seems you could just create a custom packaged version of your app that calls the test entry point rather than starting your app as usual... – Nicholas Riley Nov 03 '13 at 22:44
  • How did you manage to get py2app to bundle the non-system executable? I am trying to achieve this, without success: http://stackoverflow.com/questions/34845112/app-built-with-non-system-python-in-pyenv-not-runnable-on-other-machines – Pyderman Jan 18 '16 at 01:46

1 Answers1

1

You can use the --extra-scripts option introduced in py2app 0.7 to include a second script that starts the test in the application bundle and use that to run the tests.

I agree that it would be nice to have a way to run scripts with the application environment, could you file an issue for this in py2app's repository at https://bitbucket.org/ronaldoussoren/py2app?

Ronald Oussoren
  • 2,715
  • 20
  • 29
  • Thanks, @Ronald!. The --extra-scripts option will work for my purposes. As requested, I just added an issue to the py2app issue tracker for a more general solution. – Stuart Berg Nov 07 '13 at 19:28