Question

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?

Was it helpful?

Solution

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top