[Python-checkins] python/dist/src/Modules main.c,1.73,1.74

jvr@users.sourceforge.net jvr@users.sourceforge.net
Wed, 05 Mar 2003 07:46:59 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv685/Modules

Modified Files:
	main.c 
Log Message:
removing one Mac hack and add another:
- The applet logic has been replaced to bundlebuilder's bootstrap script
- Due to Apple being extremely string about argv[0], we need a way to
  specify the actual executable name for use with sys.executable. See
  the comment embedded in the code.


Index: main.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/main.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -C2 -d -r1.73 -r1.74
*** main.c	5 Mar 2003 14:15:19 -0000	1.73
--- main.c	5 Mar 2003 15:46:54 -0000	1.74
***************
*** 13,20 ****
  #endif
  
- #if defined(WITH_NEXT_FRAMEWORK)
- #include "pymactoolbox.h"
- #endif
- 
  #if (defined(PYOS_OS2) && !defined(PYCC_GCC)) || defined(MS_WINDOWS)
  #define PYTHONHOMEHELP "<prefix>\\lib"
--- 13,16 ----
***************
*** 155,179 ****
  	PySys_ResetWarnOptions();
  
- #if defined(WITH_NEXT_FRAMEWORK)
- 	/* If we are running from a framework it could be that we are actually
- 	** the main program for an applet. If so, the next call will return the
- 	** filename that we are supposed to run.
- 	*/
- 	filename = PyMac_GetAppletScriptFile();
- 	if (filename != NULL) {
- 		if ((fp = fopen(filename, "r")) == NULL) {
- 			fprintf(stderr, "%s: can't open file '%s'\n",
- 				argv[0], filename);
- #if defined(__VMS)
- 			/* STS$M_INHIB_MSG + SS$_ABORT */
- 			exit(0x1000002c);
- #else
- 			exit(2);
- #endif
- 		}
- 	}
- 	/* Skip option-processing if we are an applet */
- 	if (filename == NULL)
- #endif
  	while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
  		if (c == 'c') {
--- 151,154 ----
***************
*** 302,306 ****
  		unbuffered = 1;
  
! 	if (command == NULL && filename == NULL && _PyOS_optind < argc &&
  	    strcmp(argv[_PyOS_optind], "-") != 0)
  	{
--- 277,281 ----
  		unbuffered = 1;
  
! 	if (command == NULL && _PyOS_optind < argc &&
  	    strcmp(argv[_PyOS_optind], "-") != 0)
  	{
***************
*** 376,379 ****
--- 351,369 ----
  #endif /* __VMS */
  
+ #ifdef __APPLE__
+ 	/* On MacOS X, when the Python interpreter is embedded in an
+ 	   application bundle, it gets executed by a bootstrapping script
+ 	   that does os.execve() with an argv[0] that's different from the
+ 	   actual Python executable. This is needed to keep the Finder happy,
+ 	   or rather, to work around Apple's overly strict requirements of
+ 	   the process name. However, we still need a usable sys.executable,
+ 	   so the actual executable path is passed in an environment variable.
+ 	   See Lib/plat-mac/bundlebuiler.py for details about the bootstrap
+ 	   script. */
+ 	if ((p = Py_GETENV("PYTHONEXECUTABLE")) && *p != '\0')
+ 		Py_SetProgramName(p);
+ 	else
+ 		Py_SetProgramName(argv[0]);
+ #else
  	Py_SetProgramName(argv[0]);
  	Py_Initialize();