@@ -192,7 +192,7 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp)
192192** Initialization code, shared by interpreter and applets
193193*/
194194static void
195- init_common (int * argcp , char * * * argvp )
195+ init_common (int * argcp , char * * * argvp , int embedded )
196196{
197197 /* Remember resource fork refnum, for later */
198198 PyMac_AppRefNum = CurResFile ();
@@ -223,11 +223,18 @@ init_common(int *argcp, char ***argvp)
223223 options .keep_error = 1 ; /* default-default */
224224 PyMac_PreferenceOptions (& options );
225225
226- /* Create argc/argv. Do it before we go into the options event loop. */
227- * argcp = PyMac_GetArgv (argvp , options .noargs );
228-
229- /* Do interactive option setting, if allowed and <option> depressed */
230- PyMac_InteractiveOptions (& options , argcp , argvp );
226+ if ( embedded ) {
227+ static char * emb_argv [] = {"embedded-python" , 0 };
228+
229+ * argcp = 1 ;
230+ * argvp = emb_argv ;
231+ } else {
232+ /* Create argc/argv. Do it before we go into the options event loop. */
233+ * argcp = PyMac_GetArgv (argvp , options .noargs );
234+
235+ /* Do interactive option setting, if allowed and <option> depressed */
236+ PyMac_InteractiveOptions (& options , argcp , argvp );
237+ }
231238
232239 /* Copy selected options to where the machine-independent stuff wants it */
233240 Py_VerboseFlag = options .verbose ;
@@ -310,7 +317,7 @@ PyMac_InitApplet()
310317 char * * argv ;
311318 int err ;
312319
313- init_common (& argc , & argv );
320+ init_common (& argc , & argv , 0 );
314321
315322 Py_Initialize ();
316323 PySys_SetArgv (argc , argv );
@@ -325,6 +332,20 @@ PyMac_InitApplet()
325332 /* XXX Should we bother to Py_Exit(sts)? */
326333}
327334
335+ /*
336+ ** Hook for embedding python.
337+ */
338+ void
339+ PyMac_Initialize ()
340+ {
341+ int argc ;
342+ char * * argv ;
343+
344+ init_common (& argc , & argv , 1 );
345+ Py_Initialize ();
346+ PySys_SetArgv (argc , argv );
347+ }
348+
328349#endif /* USE_MAC_APPLET_SUPPORT */
329350
330351/* For normal application */
@@ -334,7 +355,7 @@ PyMac_InitApplication()
334355 int argc ;
335356 char * * argv ;
336357
337- init_common (& argc , & argv );
358+ init_common (& argc , & argv , 0 );
338359
339360 if ( argc > 1 ) {
340361 /* We're running a script. Attempt to change current directory */
0 commit comments