home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / pippy-0.6beta-src.tar.gz / pippy-0.6beta-src.tar / pippy-0.6beta-src / src / Palm / PalmGlue / python_utils.c < prev   
C/C++ Source or Header  |  2001-01-08  |  1KB  |  58 lines

  1. #include "Python.h"
  2. #include <PalmOS.h>
  3. #include "palmglue.h"
  4. #include "palm_lib.h"
  5.  
  6.  
  7. int initialize_FrozenModules();
  8. int cleanup_FrozenModules();
  9. extern struct _frozen _PyImport_FrozenModules[];
  10.  
  11. void python_init() {
  12.  
  13.     int verbose = 1;
  14.     int res;
  15.  
  16.     DMESSAGE("starting python_init");
  17.  
  18.     DMESSAGE("before set_flags");
  19.     set_flags(0, /* debug */
  20.           verbose, /* verbose */
  21.           0, /* interactive */
  22.           1, /* no site */
  23.           0, /* use class exceptions */
  24.           1, /* frozen */
  25.           0 /* optimize */
  26.           );
  27.  
  28.  
  29.     DMESSAGE("before initialize_FrozenModules");
  30.     res = initialize_FrozenModules();
  31.     ErrFatalDisplayIf( !res, "Problem with loading frozen modules");
  32.  
  33.     /* put the following statement in frozenmodule_importer */
  34.  
  35.     DMESSAGE("before set_frozen_tab");
  36.     set_frozen_tab(_PyImport_FrozenModules);
  37.  
  38.     DMESSAGE("before Py_Initialize()");
  39.     Py_Initialize();
  40.     DMESSAGE("before cleanup_FrozenModules()");
  41.     res = cleanup_FrozenModules();
  42.     ErrFatalDisplayIf( !res,
  43.                "Problem during frozen module cleanup");
  44.  
  45.     if (verbose)
  46.         fprintf(stderr, "Python %s\n%s\n",
  47.             Py_GetVersion(), Py_GetCopyright());
  48.     
  49.     PySys_SetArgv(0, NULL);
  50.     
  51. }
  52.  
  53. void python_finalize(){
  54.     Py_Finalize();
  55.     DMESSAGE("done python_finalize")
  56. }
  57.  
  58.