issue-pythonw-10-4 OS X pythonw.c broken with 10.4 deployment target r77031 (trunk) and r77032 (py3k) for Issue6834 enhanced the the OS X python interpreter launcher, python/pythonw, to allow user-selection of the interpreter execution architecture for multiple architecture builds, i.e. 32-bit vs 64-bit, by using the enhanced capability of the posix_spawn system call instead of execv. However, posix_spawn does not exist prior to OS X 10.5 and it is still important for the OS X installer to support builds and execution on 10.4 and earlier systems. The solution here is to modify Mac/Tools/pythonw.c to conditionally compile calls to execv for builds with a deployment target of 10.4 or earlier and use posix_spawn for deployments of 10.5 or above. Also, correct 32-bit arch names in configure/configure.in: for 10.4, they must be the more general "ppc", not "ppc7400". APPLIES py3k, trunk diff -r 3757a6a163d6 Mac/Tools/pythonw.c --- Mac/Tools/pythonw.c Thu Jan 07 23:48:19 2010 -0800 +++ Mac/Tools/pythonw.c Thu Jan 07 23:49:07 2010 -0800 @@ -4,11 +4,12 @@ * 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 + * On builds with a deployment target of OS X 10.5 and above, + * this program uses posix_spawn rather than plain execv because we need * slightly more control over how the "real" interpreter is executed. */ +#include #include -#include #include #include #include @@ -17,16 +18,20 @@ #include #include +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 +#include extern char** environ; +#endif + /* * 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.framework/Versions/m.n * /Python * /Resources/Python.app/Contents/MacOS/Python * @@ -74,6 +79,10 @@ return g_path; } +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 + +/* OS X 10.5 and later */ + static void setup_spawnattr(posix_spawnattr_t* spawnattr) { @@ -145,3 +154,20 @@ err(1, "posix_spawn: %s", argv[0]); /* NOTREACHED */ } + +#else + +/* OS X 10.4 and earlier */ + +int +main(int argc, char **argv) { + char* exec_path = get_python_path(); + + + argv[0] = exec_path; + execv(exec_path, argv); + err(1, "execv: %s", argv[0]); + /* NOTREACHED */ +} + +#endif diff -r 3757a6a163d6 configure --- configure Thu Jan 07 23:48:19 2010 -0800 +++ configure Thu Jan 07 23:49:07 2010 -0800 @@ -4692,7 +4692,7 @@ if test "$UNIVERSAL_ARCHS" = "32-bit" ; then UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386" ARCH_RUN_32BIT="" - LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" + LIPO_32BIT_FLAGS="-extract ppc -extract i386" elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64" @@ -4701,7 +4701,7 @@ elif test "$UNIVERSAL_ARCHS" = "all" ; then UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64" - LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" + LIPO_32BIT_FLAGS="-extract ppc -extract i386" ARCH_RUN_32BIT="arch -i386 -ppc" elif test "$UNIVERSAL_ARCHS" = "intel" ; then @@ -4711,8 +4711,8 @@ elif test "$UNIVERSAL_ARCHS" = "3-way" ; then UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64" - LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" - ARCH_RUN_32BIT="arch -i386 -ppc7400" + LIPO_32BIT_FLAGS="-extract ppc -extract i386" + ARCH_RUN_32BIT="arch -i386 -ppc" else { { echo "$as_me:$LINENO: error: proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way" >&5 diff -r 3757a6a163d6 configure.in --- configure.in Thu Jan 07 23:48:19 2010 -0800 +++ configure.in Thu Jan 07 23:49:07 2010 -0800 @@ -942,7 +942,7 @@ if test "$UNIVERSAL_ARCHS" = "32-bit" ; then UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386" ARCH_RUN_32BIT="" - LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" + LIPO_32BIT_FLAGS="-extract ppc -extract i386" elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64" @@ -951,7 +951,7 @@ elif test "$UNIVERSAL_ARCHS" = "all" ; then UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64" - LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" + LIPO_32BIT_FLAGS="-extract ppc -extract i386" ARCH_RUN_32BIT="arch -i386 -ppc" elif test "$UNIVERSAL_ARCHS" = "intel" ; then @@ -961,8 +961,8 @@ elif test "$UNIVERSAL_ARCHS" = "3-way" ; then UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64" - LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" - ARCH_RUN_32BIT="arch -i386 -ppc7400" + LIPO_32BIT_FLAGS="-extract ppc -extract i386" + ARCH_RUN_32BIT="arch -i386 -ppc" else AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])