comparison src/if_python3.c @ 2641:b803b2776880 v7.3.062

updated for version 7.3.062 Problem: Python doesn't work properly when installed in another directory than expected. Solution: Figure out home directory in configure and use Py_SetPythonHome() at runtime. (Roland Puntaier)
author Bram Moolenaar <bram@vim.org>
date Tue, 16 Nov 2010 19:26:02 +0100
parents fa5dee44df3f
children 0b4a515b1254
comparison
equal deleted inserted replaced
2640:266f9d9f5109 2641:b803b2776880
78 78
79 # ifndef WIN3264 79 # ifndef WIN3264
80 # include <dlfcn.h> 80 # include <dlfcn.h>
81 # define FARPROC void* 81 # define FARPROC void*
82 # define HINSTANCE void* 82 # define HINSTANCE void*
83 # ifdef PY_NO_RTLD_GLOBAL 83 # if defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)
84 # define load_dll(n) dlopen((n), RTLD_LAZY) 84 # define load_dll(n) dlopen((n), RTLD_LAZY)
85 # else 85 # else
86 # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) 86 # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
87 # endif 87 # endif
88 # define close_dll dlclose 88 # define close_dll dlclose
130 # define PySys_SetArgv py3_PySys_SetArgv 130 # define PySys_SetArgv py3_PySys_SetArgv
131 # define PyType_Type (*py3_PyType_Type) 131 # define PyType_Type (*py3_PyType_Type)
132 # define PyType_Ready py3_PyType_Ready 132 # define PyType_Ready py3_PyType_Ready
133 #undef Py_BuildValue 133 #undef Py_BuildValue
134 # define Py_BuildValue py3_Py_BuildValue 134 # define Py_BuildValue py3_Py_BuildValue
135 # define Py_SetPythonHome py3_Py_SetPythonHome
135 # define Py_Initialize py3_Py_Initialize 136 # define Py_Initialize py3_Py_Initialize
136 # define Py_Finalize py3_Py_Finalize 137 # define Py_Finalize py3_Py_Finalize
137 # define Py_IsInitialized py3_Py_IsInitialized 138 # define Py_IsInitialized py3_Py_IsInitialized
138 # define _Py_NoneStruct (*py3__Py_NoneStruct) 139 # define _Py_NoneStruct (*py3__Py_NoneStruct)
139 # define PyModule_AddObject py3_PyModule_AddObject 140 # define PyModule_AddObject py3_PyModule_AddObject
168 169
169 /* 170 /*
170 * Pointers for dynamic link 171 * Pointers for dynamic link
171 */ 172 */
172 static int (*py3_PySys_SetArgv)(int, wchar_t **); 173 static int (*py3_PySys_SetArgv)(int, wchar_t **);
174 static void (*py3_Py_SetPythonHome)(wchar_t *home);
173 static void (*py3_Py_Initialize)(void); 175 static void (*py3_Py_Initialize)(void);
174 static PyObject* (*py3_PyList_New)(Py_ssize_t size); 176 static PyObject* (*py3_PyList_New)(Py_ssize_t size);
175 static PyGILState_STATE (*py3_PyGILState_Ensure)(void); 177 static PyGILState_STATE (*py3_PyGILState_Ensure)(void);
176 static void (*py3_PyGILState_Release)(PyGILState_STATE); 178 static void (*py3_PyGILState_Release)(PyGILState_STATE);
177 static int (*py3_PySys_SetObject)(char *, PyObject *); 179 static int (*py3_PySys_SetObject)(char *, PyObject *);
252 char *name; 254 char *name;
253 PYTHON_PROC *ptr; 255 PYTHON_PROC *ptr;
254 } py3_funcname_table[] = 256 } py3_funcname_table[] =
255 { 257 {
256 {"PySys_SetArgv", (PYTHON_PROC*)&py3_PySys_SetArgv}, 258 {"PySys_SetArgv", (PYTHON_PROC*)&py3_PySys_SetArgv},
259 {"Py_SetPythonHome", (PYTHON_PROC*)&py3_Py_SetPythonHome},
257 {"Py_Initialize", (PYTHON_PROC*)&py3_Py_Initialize}, 260 {"Py_Initialize", (PYTHON_PROC*)&py3_Py_Initialize},
258 {"PyArg_ParseTuple", (PYTHON_PROC*)&py3_PyArg_ParseTuple}, 261 {"PyArg_ParseTuple", (PYTHON_PROC*)&py3_PyArg_ParseTuple},
259 {"PyList_New", (PYTHON_PROC*)&py3_PyList_New}, 262 {"PyList_New", (PYTHON_PROC*)&py3_PyList_New},
260 {"PyGILState_Ensure", (PYTHON_PROC*)&py3_PyGILState_Ensure}, 263 {"PyGILState_Ensure", (PYTHON_PROC*)&py3_PyGILState_Ensure},
261 {"PyGILState_Release", (PYTHON_PROC*)&py3_PyGILState_Release}, 264 {"PyGILState_Release", (PYTHON_PROC*)&py3_PyGILState_Release},
334 py3_runtime_link_init(char *libname, int verbose) 337 py3_runtime_link_init(char *libname, int verbose)
335 { 338 {
336 int i; 339 int i;
337 void *ucs_from_string, *ucs_from_string_and_size; 340 void *ucs_from_string, *ucs_from_string_and_size;
338 341
339 # if !defined(PY_NO_RTLD_GLOBAL) && defined(UNIX) && defined(FEAT_PYTHON) 342 # if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON)
340 /* Can't have Python and Python3 loaded at the same time. 343 /* Can't have Python and Python3 loaded at the same time.
341 * It cause a crash, because RTLD_GLOBAL is needed for 344 * It cause a crash, because RTLD_GLOBAL is needed for
342 * standard C extension libraries of one or both python versions. */ 345 * standard C extension libraries of one or both python versions. */
343 if (python_loaded()) 346 if (python_loaded())
344 { 347 {
536 goto fail; 539 goto fail;
537 } 540 }
538 #endif 541 #endif
539 542
540 init_structs(); 543 init_structs();
544
545
546 #ifdef PYTHON3_HOME
547 Py_SetPythonHome(PYTHON3_HOME);
548 #endif
541 549
542 /* initialise threads */ 550 /* initialise threads */
543 PyEval_InitThreads(); 551 PyEval_InitThreads();
544 552
545 #if !defined(MACOS) || defined(MACOS_X_UNIX) 553 #if !defined(MACOS) || defined(MACOS_X_UNIX)