/*
* This wrapper program executes a python executable hidden inside an
* application bundle inside the Python framework. This is needed to run
* GUI code: some GUI API's don't work unless the program is inside an
* application bundle.
*
* This program uses posix_spawn rather than plain execv because we need
* slightly more control over how the "real" interpreter is executed.
*
* On OSX 10.4 (and earlier) this falls back to using exec because the
* posix_spawnv functions aren't available there.
*/
#pragma weak_import posix_spawnattr_init
#pragma weak_import posix_spawnattr_setbinpref_np
#pragma weak_import posix_spawnattr_setflags
#pragma weak_import posix_spawn
#include
#include
#ifdef HAVE_SPAWN_H
#include
#endif
#include
#include
#include
#include
#include
#include
extern char** environ;
/*
* Locate the python framework by looking for the
* library that contains Py_Initialize.
*
* In a regular framework the structure is:
*
* Python.framework/Versions/2.7
* /Python
* /Resources/Python.app/Contents/MacOS/Python
*
* In a virtualenv style structure the expected
* structure is:
*
* ROOT
* /bin/pythonw
* /.Python