Changeset 431

Show
Ignore:
Timestamp:
Sat Feb 23 11:18:02 2008
Author:
naufraghi
Message:

Merge dal branch dl

Files:

Legend:

Unmodified
Added
Removed
Modified
  • branches/python2.5/bindepend.py

    r328 r431  
    266 266     #print "I: analyzing", pth  
    267 267     seen[string.upper(nm)] = 1  
      268     for lib, npth in selectImports(pth):  
      269         if seen.get(string.upper(lib),0):  
      270             continue  
      271         lTOC.append((lib, npth, 'BINARY'))  
      272  
      273   return lTOC  
      274  
      275 def selectImports(pth):  
      276     """Return the dependencies of a binary that should be included.  
      277  
      278     Return a list of pairs (name, fullpath)  
      279     """  
      280     rv = []  
    268 281     dlls = getImports(pth)  
    269 282     for lib in dlls:  
    270           #print "I: found", lib  
    271 283         if not iswin and not cygwin:  
    272 284             npth = lib  
     
    277 289             npth = getfullnameof(lib, os.path.dirname(pth))  
    278 290         if excludesRe.search(npth):  
    279               continue  
    280           if seen.get(string.upper(lib),0):  
    281               continue  
      291             if 'libpython' not in npth and 'Python.framework' not in npth:  
      292                 continue  
    282 293         if npth:  
    283               lTOC.append((lib, npth, 'BINARY'))  
      294             rv.append((lib, npth))  
    283 294         else:  
    284 295             print "E: lib not found:", lib, "dependency of", pth  
    285     return lTOC  
      296  
      297     return rv  
    286 298  
    287 299 def _getImports_ldd(pth):  
     
    354 366     return _bpath  
    355 367  
      368 def fixOsxPaths(moduleName):  
      369     for name, lib in selectImports(moduleName):  
      370         dest = os.path.join("@executable_path", name)  
      371         cmd = "install_name_tool -change %s %s %s" % (lib, dest, moduleName)  
      372         os.system(cmd)  
      373  
    356 374 if __name__ == "__main__":  
    357 375   if len(sys.argv) < 2:  
  • branches/python2.5/Build.py

    r378 r431  
    324 324     return digest  
    325 325  
    326   def checkCache(fnm, strip, upx):  
    327       if not strip and not upx:  
      326 def checkCache(fnm, strip, upx, fix_paths=1):  
      327     # On darwin a cache is required anyway to keep the libaries  
      328     # with relative install names  
      329     if not strip and not upx and sys.platform != 'darwin':  
    328 330         return fnm  
    329 331     if strip:  
     
    350 352     digest = cacheDigest(fnm)  
    351 353     cachedfile = os.path.join(cachedir, basenm)  
      354     cmd = None  
    352 355     if cache_index.has_key(basenm):  
    353 356         if digest != cache_index[basenm]:  
     
    357 360     if upx:  
    358 361         if strip:  
    359               fnm = checkCache(fnm, 1, 0)  
      362             fnm = checkCache(fnm, 1, 0, fix_paths=0)  
    359 362         cmd = "upx --best -q \"%s\"" % cachedfile  
    360 363     else:  
    361           cmd = "strip \"%s\"" % cachedfile  
      364         if strip:  
      365             cmd = "strip \"%s\"" % cachedfile  
    362 366     shutil.copy2(fnm, cachedfile)  
    363 367     os.chmod(cachedfile, 0755)  
    364       os.system(cmd)  
      368     if cmd: os.system(cmd)  
      369  
      370     if sys.platform == 'darwin' and fix_paths:  
      371         bindepend.fixOsxPaths(cachedfile)  
    365 372  
    366 373     # update cache index  
  • branches/python2.5/source/linux/Make.py

    r307 r431  
    165 165         cflags.append('-DNONELF')  
    166 166  
    167       libs = [os.path.join(sysconfig.get_config_vars('LIBPL')[0], sysconfig.get_config_vars('LIBRARY')[0])]  
    168       if not os.path.isfile(libs[0]):  
    169           print "WARNING: could not find Python static library at:", libs[0]  
    170    
    171 167     somevars = {}  
    172 168     if os.path.exists(makefile_in):  
     
    179 175     somevars['CFLAGS'] = string.join(cflags) # override  
    180 176     files = ['$(OPT)', '$(LDFLAGS)', '$(LINKFORSHARED)', 'getpath.c'] + \  
    181               files + libs + \  
      177             files + \  
    181 177             ['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)', '-lz']  # XXX zlib not always -lz  
    182 178  
  • branches/python2.5/source/linux/main.c

    r330 r431  
    27 27  */  
    28 28 #include "launch.h"  
      29 #include "getpath.h"  
    29 30  
    30 31 #ifdef FREEZE_EXCEPTIONS  
     
    55 56         strcpy(thisfile, argv[0]);  
    56 57         strcat(thisfile, ".exe");  
    57           Py_SetProgramName(thisfile);  
      58         PI_SetProgramName(thisfile);  
    57 58     }  
    58 59     else  
    59 60 #endif  
    60           Py_SetProgramName(argv[0]);  
    61       strcpy(thisfile, Py_GetProgramFullPath());  
      61         PI_SetProgramName(argv[0]);  
      62     strcpy(thisfile, PI_GetProgramFullPath());  
    62 63     VS("thisfile is %s\n", thisfile);  
    63 64      
     
    67 68  
    68 69     /* fill in here (directory of thisfile) */  
    69       strcpy(homepath, Py_GetPrefix());  
      70     strcpy(homepath, PI_GetPrefix());  
    69 70     strcat(homepath, "/");  
    70 71     VS("homepath is %s\n", homepath);  
  • branches/python2.5/source/linux/getpath.c

    r2 r431  
    37 37 /* Return the initial module search path. */  
    38 38  
    39   #include "Python.h"  
      39 #include "getpath.h"  
    39 39 #include "osdefs.h"  
    40 40  
     
    43 43 #include <sys/stat.h>  
    44 44 #include <string.h>  
      45 #include <stdlib.h>     /* getenv */  
    45 46  
    46 47 #if HAVE_UNISTD_H  
     
    150 151 calculate_path(void)  
    151 152 {  
    152           char *prog = Py_GetProgramName();       /* use Py_SetProgramName(argv[0]) before Py_Initialize() */  
      153         char *prog = PI_GetProgramName();       /* use Py_SetProgramName(argv[0]) before Py_Initialize() */  
    152 153         char argv0_path[MAXPATHLEN+1];  
    153 154         char *epath;  
    154 155         char *path = NULL;  
    155 156         char *ppath = NULL;  
    156           int  numchars;  
      157 #if HAVE_READLINK  
      158         int  numchars;  
      159 #endif  
    157 160  
    158 161         if (strchr(prog, SEP))  
     
    237 240 /* External interface */  
    238 241  
      242 static char *progname = "python";  
      243  
      244 void  
      245 PI_SetProgramName(char *pn)  
      246 {  
      247         if (pn && *pn)  
      248                 progname = pn;  
      249 }  
      250  
      251 char *  
      252 PI_GetProgramName(void)  
      253 {  
      254         return progname;  
      255 }  
      256  
    239 257 char *  
    240   Py_GetPath(void)  
      258 PI_GetPath(void)  
    240 258 {  
    241 259         if (!module_search_path)  
     
    246 264  
    247 265 char *  
    248   Py_GetPrefix(void)  
      266 PI_GetPrefix(void)  
    248 266 {  
    249 267         if (!module_search_path)  
     
    254 272  
    255 273 char *  
    256   Py_GetExecPrefix(void)  
      274 PI_GetExecPrefix(void)  
    256 274 {  
    257 275         if (!module_search_path)  
     
    262 280  
    263 281 char *  
    264   Py_GetProgramFullPath(void)  
      282 PI_GetProgramFullPath(void)  
    264 282 {  
    265 283         if (!module_search_path)  
  • branches/python2.5/source/common/launch.h

    r329 r431  
    43 43 #endif  
    44 44  
    45   /* On Windows, we use dynamic loading so one binary  
      45 /* We use dynamic loading so one binary  
    45 45    can be used with (nearly) any Python version.  
    46      This is the cruft necessary to do Windows dynamic loading  
      46    This is the cruft necessary to do dynamic loading  
    46 46 */  
    47 47  
    48   #ifdef WIN32  
    49 48 /*  
    50 49  * These macros used to define variables to hold dynamically accessed entry  
    51 50  * points. These are declared 'extern' in this header, and defined fully later.  
    52 51  */  
      52 #ifdef WIN32  
      53  
    53 54 #define EXTDECLPROC(result, name, args)\  
    54 55     typedef result (__cdecl *__PROC__##name) args;\  
    55       extern __PROC__##name name;  
      56     extern __PROC__##name PI_##name;  
    55 56  
    56 57 #define EXTDECLVAR(vartyp, name)\  
    57 58     typedef vartyp __VAR__##name;\  
    58       extern __VAR__##name *name;  
      59     extern __VAR__##name *PI_##name;  
      60  
      61 #else  
      62  
      63 #define EXTDECLPROC(result, name, args)\  
      64     typedef result (*__PROC__##name) args;\  
      65     extern __PROC__##name PI_##name;  
    59 66  
    60   /*  
      67 #define EXTDECLVAR(vartyp, name)\  
      68     typedef vartyp __VAR__##name;\  
      69     extern __VAR__##name *PI_##name;  
      70  
      71 #endif /* WIN32 */  
      72  
      73 /*  
    61 74  * These types and macros are included from the Python header file object.h  
    62 75  * They are needed to do very basic Python functionality.  
    63 76  */  
    64   typedef _typeobject;  
      77 /*typedef _typeobject;*/  
    64 77 typedef struct _object {  
    65 78     int ob_refcnt;  
     
    126 139 EXTDECLPROC(int, Py_Initialize, (void));  
    127 140 EXTDECLPROC(int, Py_Finalize, (void));  
    128   EXTDECLPROC(PyObject *, Py_CompileString, (char *, char *, int));  
    129 141 EXTDECLPROC(PyObject *, PyImport_ExecCodeModule, (char *, PyObject *));  
    130 142 EXTDECLPROC(int, PyRun_SimpleString, (char *));  
    131   EXTDECLPROC(int, PySys_SetArgv, (int, char **));  
    132 143 EXTDECLPROC(void, Py_SetProgramName, (char *));  
    133 144 EXTDECLPROC(PyObject *, PyImport_ImportModule, (char *));  
     
    137 148 EXTDECLPROC(int, PyList_Append, (PyObject *, PyObject *));  
    138 149 EXTDECLPROC(PyObject *, Py_BuildValue, (char *, ...));  
    139   EXTDECLPROC(PyObject *, PyFile_FromString, (char *, char *));  
    140 150 EXTDECLPROC(PyObject *, PyString_FromStringAndSize, (const char *, int));  
    141 151 EXTDECLPROC(PyObject *, PyObject_CallFunction, (PyObject *, char *, ...));  
    142 152 EXTDECLPROC(PyObject *, PyModule_GetDict, (PyObject *));  
    143 153 EXTDECLPROC(PyObject *, PyDict_GetItemString, (PyObject *, char *));  
    144   EXTDECLPROC(void, PyErr_Clear, () );  
    145   EXTDECLPROC(PyObject *, PyErr_Occurred, () );  
    146   EXTDECLPROC(void, PyErr_Print, () );  
    147   EXTDECLPROC(PyObject *, PyObject_CallObject, (PyObject *, PyObject*) );  
    148   EXTDECLPROC(PyObject *, PyObject_CallMethod, (PyObject *, char *, char *, ...) );  
    149   EXTDECLPROC(void, PySys_AddWarnOption, (char *));  
    150   EXTDECLPROC(void, PyEval_InitThreads, () );  
      154 EXTDECLPROC(void, PyErr_Clear, (void) );  
      155 EXTDECLPROC(PyObject *, PyErr_Occurred, (void) );  
      156 EXTDECLPROC(void, PyErr_Print, (void) );  
      157 EXTDECLPROC(void, PySys_AddWarnOption, (char *));  
      158 EXTDECLPROC(void, PyEval_InitThreads, (void) );  
    151 159 EXTDECLPROC(void, PyEval_AcquireThread, (PyThreadState *) );  
    152 160 EXTDECLPROC(void, PyEval_ReleaseThread, (PyThreadState *) );  
    153   EXTDECLPROC(void, PyEval_AcquireLock, (void) );  
    154   EXTDECLPROC(void, PyEval_ReleaseLock, (void) );  
    155 161 EXTDECLPROC(PyThreadState *, PyThreadState_Swap, (PyThreadState *) );  
    156   EXTDECLPROC(PyThreadState *, PyThreadState_New, (PyInterpreterState *) );  
    157   EXTDECLPROC(void, PyThreadState_Clear, (PyThreadState *) );  
    158   EXTDECLPROC(void, PyThreadState_Delete, (PyThreadState *) );  
    159   EXTDECLPROC(PyInterpreterState *, PyInterpreterState_New, () );  
    160   EXTDECLPROC(PyThreadState *, Py_NewInterpreter, () );  
      162 EXTDECLPROC(PyThreadState *, Py_NewInterpreter, (void) );  
    161 163 EXTDECLPROC(void, Py_EndInterpreter, (PyThreadState *) );  
    162   EXTDECLPROC(void, PyErr_Print, () );  
    163 164 EXTDECLPROC(long, PyInt_AsLong, (PyObject *) );  
    164 165 EXTDECLPROC(int, PySys_SetObject, (char *, PyObject *));  
     
    167 168  * Typedefs '__PROC__...' have been done above  
    168 169  */  
      170 #ifdef WIN32  
      171  
    169 172 #define DECLPROC(name)\  
    170       __PROC__##name name = NULL;  
      173     __PROC__##name PI_##name = NULL;  
    170 173 #define GETPROC(dll, name)\  
    171       name = (__PROC__##name)GetProcAddress (dll, #name);\  
    172       if (!name) {\  
      174     PI_##name = (__PROC__##name)GetProcAddress (dll, #name);\  
      175     if (!PI_##name) {\  
    173 176         FATALERROR ("Cannot GetProcAddress for " #name);\  
    174 177         return -1;\  
    175 178     }  
    176 179 #define DECLVAR(name)\  
    177       __VAR__##name *name = NULL;  
      180     __VAR__##name *PI_##name = NULL;  
    177 180 #define GETVAR(dll, name)\  
    178       name = (__VAR__##name *)GetProcAddress (dll, #name);\  
    179       if (!name) {\  
      181     PI_##name = (__VAR__##name *)GetProcAddress (dll, #name);\  
      182     if (!PI_##name) {\  
    180 183         FATALERROR ("Cannot GetProcAddress for " #name);\  
    181 184         return -1;\  
    182 185     }  
      186  
    183 187 #else  
    184   #include <Python.h>  
    185   #endif /* WIN32 dynamic load cruft */  
      188  
      189 #define DECLPROC(name)\  
      190     __PROC__##name PI_##name = NULL;  
      191 #define GETPROC(dll, name)\  
      192     PI_##name = (__PROC__##name)dlsym (dll, #name);\  
      193     if (!PI_##name) {\  
      194         FATALERROR ("Cannot dlsym for " #name);\  
      195         return -1;\  
      196     }  
      197 #define DECLVAR(name)\  
      198     __VAR__##name *PI_##name = NULL;  
      199 #define GETVAR(dll, name)\  
      200     PI_##name = (__VAR__##name *)dlsym(dll, #name);\  
      201     if (!PI_##name) {\  
      202         FATALERROR ("Cannot dlsym for " #name);\  
      203         return -1;\  
      204     }  
      205  
      206 #endif /* WIN32 */  
    186 207  
    187 208 /*  
  • branches/python2.5/source/common/launch.c

    r424 r431  
    35 35  #include <unistd.h>  
    36 36  #include <fcntl.h>  
      37  #include <dlfcn.h>  
    37 38  #include <dirent.h>  
    38 39 #endif  
     
    43 44 #include "zlib.h"  
    44 45 #endif  
    45   #ifdef WIN32  
      46  
    45 46 /*  
    46 47  * Python Entry point declarations (see macros in launch.h).  
     
    52 53 DECLPROC(Py_Initialize);  
    53 54 DECLPROC(Py_Finalize);  
    54   DECLPROC(Py_CompileString);  
    55 55 DECLPROC(PyImport_ExecCodeModule);  
    56 56 DECLPROC(PyRun_SimpleString);  
    57   DECLPROC(PySys_SetArgv);  
    58 57 DECLPROC(Py_SetProgramName);  
    59 58 DECLPROC(PyImport_ImportModule);  
     
    63 62 DECLPROC(PyList_Append);  
    64 63 DECLPROC(Py_BuildValue);  
    65   DECLPROC(PyFile_FromString);  
    66 64 DECLPROC(PyString_FromStringAndSize);  
    67 65 DECLPROC(PyObject_CallFunction);  
     
    71 69 DECLPROC(PyErr_Occurred);  
    72 70 DECLPROC(PyErr_Print);  
    73   DECLPROC(PyObject_CallObject);  
    74   DECLPROC(PyObject_CallMethod);  
    75 71 DECLPROC(PySys_AddWarnOption);  
    76 72 DECLPROC(PyEval_InitThreads);  
    77 73 DECLPROC(PyEval_AcquireThread);  
    78 74 DECLPROC(PyEval_ReleaseThread);  
    79   DECLPROC(PyEval_AcquireLock);  
    80   DECLPROC(PyEval_ReleaseLock);  
    81 75 DECLPROC(PyThreadState_Swap);  
    82   DECLPROC(PyThreadState_New);  
    83   DECLPROC(PyThreadState_Clear);  
    84   DECLPROC(PyThreadState_Delete);  
    85   DECLPROC(PyInterpreterState_New);  
    86 76 DECLPROC(Py_NewInterpreter);  
    87 77 DECLPROC(Py_EndInterpreter);  
    88 78 DECLPROC(PyInt_AsLong);  
    89 79 DECLPROC(PySys_SetObject);  
    90   #endif  
    91 80  
    92 81 #ifdef WIN32  
     
    172 161  
    173 162  
    174   #ifdef WIN32  
    175    
    176   int getTempPath(char *buff)  
      163 int testTempPath(char *buff)  
    177 164 {  
    178       int i;  
    179       char *ret;  
    180       char prefix[16];  
    181    
    182       GetTempPath(MAX_PATH, buff);  
    183       sprintf(prefix, "_MEI%d", getpid());  
    184    
    185       // Windows does not have a race-free function to create a temporary  
    186       // directory. Thus, we rely on _tempnam, and simply try several times  
    187       // to avoid stupid race conditions.  
    188       for (i=0;i<5;i++) {  
    189           ret = _tempnam(buff, prefix);  
    190           if (mkdir(ret) == 0) {  
    191               strcpy(buff, ret);  
    192               strcat(buff, "\\");  
    193               free(ret);  
    194               return 1;  
    195           }  
    196           free(ret);  
    197       }  
    198       return 0;  
    199   }  
      165         char base[16];  
      166         int n;  
    200 167  
      168         n = strlen(buff);  
      169         if ( buff[n-1] == '/' || buff[n-1] == '\\' )  
      170                 sprintf(base, "_MEI%d", getpid());  
      171         else  
      172                 sprintf(base, "%s_MEI%d", SEP, getpid());  
      173         strcat(buff, base);  
      174 #ifdef WIN32  
      175         if (mkdir(buff) == 0) {  
    201 176 #else  
    202    
    203   int testTempPath(char *buff)  
    204   {  
    205           strcat(buff, "/_MEIXXXXXX");  
    206       if (mkdtemp(buff))  
    207       {  
    208           strcat(buff, "/");  
    209           return 1;  
    210       }  
    211       return 0;     
      177         if (mkdir(buff, 0700) == 0) {  
      178 #endif  
      179                 strcat(buff, SEP);  
      180                 return 1;  
      181         }  
      182         return 0;  
    212 183 }  
    213 184  
    214   int getTempPath(char *buff)  
      185 void getTempPath(char *buff)  
    214 185 {  
      186 #ifdef WIN32  
      187         GetTempPath(MAX_PATH, buff);  
      188         testTempPath(buff);  
      189 #else  
    215 190         static const char *envname[] = {  
    216 191                 "TMPDIR", "TEMP", "TMP", 0  
     
    227 202                         strcpy(buff, p);  
    228 203                         if (testTempPath(buff))  
    229                                   return 1;  
      204                                 return;  
    229 204                 }  
    230 205         }  
     
    233 208                 strcpy(buff, dirname[i]);  
    234 209                 if (testTempPath(buff))  
    235                           return 1;  
      210                         return;  
    235 210         }  
    236       return 0;  
    237   }  
    238    
      211         buff[0] = '\0';  
    239 212 #endif  
    240    
      213 }  
    240 213 /*  
    241 214  * Set up paths required by rest of this module  
     
    320 293         return 0;  
    321 294 }  
    322   #ifdef WIN32  
      295 #ifndef WIN32  
      296 #define HMODULE void *  
      297 #define HINSTANCE void *  
      298 #endif  
      299  
    323 300 int mapNames(HMODULE dll)  
    324 301 {  
     
    329 306         GETPROC(dll, Py_Initialize);  
    330 307         GETPROC(dll, Py_Finalize);  
    331           GETPROC(dll, Py_CompileString);  
    332 308         GETPROC(dll, PyImport_ExecCodeModule);  
    333 309         GETPROC(dll, PyRun_SimpleString);  
    334           GETPROC(dll, PySys_SetArgv);  
    335 310         GETPROC(dll, Py_SetProgramName);  
    336 311         GETPROC(dll, PyImport_ImportModule);  
     
    340 315         GETPROC(dll, PyList_Append);  
    341 316         GETPROC(dll, Py_BuildValue);  
    342           GETPROC(dll, PyFile_FromString);  
    343 317         GETPROC(dll, PyString_FromStringAndSize);  
    344 318         GETPROC(dll, PyObject_CallFunction);  
     
    348 322         GETPROC(dll, PyErr_Occurred);  
    349 323         GETPROC(dll, PyErr_Print);  
    350           GETPROC(dll, PyObject_CallObject);  
    351           GETPROC(dll, PyObject_CallMethod);  
    352 324         if (ntohl(f_cookie.pyvers) >= 21) {  
    353 325                 GETPROC(dll, PySys_AddWarnOption);  
     
    356 328         GETPROC(dll, PyEval_AcquireThread);  
    357 329         GETPROC(dll, PyEval_ReleaseThread);  
    358           GETPROC(dll, PyEval_AcquireLock);  
    359           GETPROC(dll, PyEval_ReleaseLock);  
    360 330         GETPROC(dll, PyThreadState_Swap);  
    361           GETPROC(dll, PyThreadState_New);  
    362           GETPROC(dll, PyThreadState_Clear);  
    363           GETPROC(dll, PyThreadState_Delete);  
    364           GETPROC(dll, PyInterpreterState_New);  
    365 331         GETPROC(dll, Py_NewInterpreter);  
    366 332         GETPROC(dll, Py_EndInterpreter);  
    367           GETPROC(dll, PyErr_Print);  
    368 333         GETPROC(dll, PyInt_AsLong);  
    369 334         GETPROC(dll, PySys_SetObject);  
      335  
    370 336         return 0;  
    371 337 }  
    372   #endif  
      338  
    372 338 /*  
    373 339  * Load the Python DLL, and get all of the necessary entry points  
    374    * Windows only (dynamic load)  
    375 340  */  
    376 341 int loadPython()  
    377 342 {  
    378   #ifdef WIN32  
    379 343         HINSTANCE dll;  
    380 344         char dllpath[_MAX_PATH + 1];  
    381 345  
      346 #ifdef WIN32  
    382 347         /* Determine the path */  
    383 348         sprintf(dllpath, "%spython%02d.dll", f_homepathraw, ntohl(f_cookie.pyvers));  
     
    403 368  
    404 369         mapNames(dll);  
      370 #else  
      371  
      372         /* Determine the path */  
      373 #ifdef __APPLE__  
      374         sprintf(dllpath, "%sPython", f_homepath);  
      375 #else  
      376         sprintf(dllpath, "%slibpython%01d.%01d.so.1.0", f_homepath,  
      377            ntohl(f_cookie.pyvers) / 10, ntohl(f_cookie.pyvers) % 10);  
      378 #endif  
      379  
      380         /* Load the DLL */  
      381         dll = dlopen(dllpath, RTLD_NOW|RTLD_GLOBAL);  
      382         if (dll) {  
      383                 VS("%s\n", dllpath);  
      384         }  
      385         if (dll == 0) {  
      386                 FATALERROR("Error loading Python lib '%s': %s\n",  
      387                         dllpath, dlerror());  
      388                 return -1;  
      389         }  
      390  
      391         mapNames(dll);  
      392  
    405 393 #endif  
    406 394  
    407 395         return 0;  
    408 396 }  
    409   #ifdef WIN32  
      397  
    409 397 /*  
    410 398  * use this from a dll instead of loadPython()  
     
    415 403 int attachPython(int *loadedNew)  
    416 404 {  
      405 #ifdef WIN32  
    417 406         HMODULE dll;  
    418 407         char nm[_MAX_PATH + 1];  
     
    429 418         mapNames(dll);  
    430 419         *loadedNew = 0;  
      420 #endif  
    431 421         return 0;  
    432 422 }  
    433   #endif  
    434 423  
    435 424 /*  
     
    473 462                         switch (ptoc->name[0]) {  
    474 463                         case 'v':  
    475   #if defined  WIN32  
    476                                   *Py_VerboseFlag = 1;  
    477   #else  
    478                                   Py_VerboseFlag = 1;  
    479   #endif  
      464                                 *PI_Py_VerboseFlag = 1;  
    480 465                         break;  
    481 466                         case 'u':  
     
    485 470                         case 'W':  
    486 471                                 if (ntohl(f_cookie.pyvers) >= 21) {  
    487                                           PySys_AddWarnOption(&ptoc->name[2]);  
      472                                         PI_PySys_AddWarnOption(&ptoc->name[2]);  
    487 472                                 }  
    488 473                         break;  
    489 474 #endif  
    490 475                         case 's':  
    491   #if defined  WIN32  
    492                                   *Py_NoSiteFlag = 0;  
    493   #else  
    494                                   Py_NoSiteFlag = 0;  
    495   #endif  
      476                                 *PI_Py_NoSiteFlag = 0;  
    496 477                         break;  
    497 478                         case 'O':  
    498   #if defined  WIN32  
    499                                   *Py_OptimizeFlag = 1;  
    500   #else  
    501                                   Py_OptimizeFlag = 1;  
    502   #endif  
      479                                 *PI_Py_OptimizeFlag = 1;  
    503 480                         break;  
    504 481                         }  
     
    573 550         /* Start python. */  
    574 551         /* VS("Loading python\n"); */  
    575   #if defined  WIN32  
    576           *Py_NoSiteFlag = 1;     /* maybe changed to 0 by setRuntimeOptions() */  
    577   #else  
    578           Py_NoSiteFlag = 1;  
    579   #endif  
      552         *PI_Py_NoSiteFlag = 1;  /* maybe changed to 0 by setRuntimeOptions() */  
    580 553         setRuntimeOptions();  
    581   #ifdef WIN32  
    582           Py_SetProgramName(f_archivename); /*XXX*/  
    583   #endif  
    584           Py_Initialize();  
      554         PI_Py_SetProgramName(f_archivename); /*XXX*/  
      555         PI_Py_Initialize();  
    585 556  
    586 557         /* Set sys.path */  
     
    588 559         strcpy(tmp, f_homepath);  
    589 560         tmp[strlen(tmp)-1] = '\0';  
    590   &n