summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-11-16 19:26:02 +0100
committerBram Moolenaar <Bram@vim.org>2010-11-16 19:26:02 +0100
commit644d37b84d8f520f807ef665b476c47b72862eff (patch)
treeab5ea0c766b10f74514876e10c50daa61ea8f919 /src
parent00b78c17b24e61b73f8ecf8fa3e5154d396c1d1a (diff)
downloadvim-644d37b84d8f520f807ef665b476c47b72862eff.zip
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)
Diffstat (limited to 'src')
-rwxr-xr-xsrc/auto/configure90
-rw-r--r--src/configure.in67
-rw-r--r--src/if_python.c11
-rw-r--r--src/if_python3.c12
-rw-r--r--src/version.c2
5 files changed, 159 insertions, 23 deletions
diff --git a/src/auto/configure b/src/auto/configure
index 336744183..fae21ff90 100755
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -5326,9 +5326,9 @@ fi
PYTHON_LIBS="${vi_cv_path_python_plibs}"
if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
- PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
+ PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
else
- PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version}"
+ PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
fi
PYTHON_SRC="if_python.c"
if test "x$MACOSX" = "xyes"; then
@@ -5339,7 +5339,7 @@ fi
if test "${vi_cv_var_python_version}" = "1.4"; then
PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
fi
- PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
+ PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -pthread should be used" >&5
$as_echo_n "checking if -pthread should be used... " >&6; }
@@ -5601,9 +5601,9 @@ fi
PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
- PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}"
+ PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
else
- PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}"
+ PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
fi
PYTHON3_SRC="if_python3.c"
if test "x$MACOSX" = "xyes"; then
@@ -5708,10 +5708,10 @@ if test "$python_ok" = yes && test "$python3_ok" = yes; then
$as_echo "#define DYNAMIC_PYTHON3 1" >>confdefs.h
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can do without RTLD_GLOBAL" >&5
-$as_echo_n "checking whether we can do without RTLD_GLOBAL... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can do without RTLD_GLOBAL for Python" >&5
+$as_echo_n "checking whether we can do without RTLD_GLOBAL for Python... " >&6; }
cflags_save=$CFLAGS
- CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
+ CFLAGS="$CFLAGS $PYTHON_CFLAGS"
ldflags_save=$LDFLAGS
LDFLAGS="$LDFLAGS -ldl"
if test "$cross_compiling" = yes; then :
@@ -5730,15 +5730,17 @@ else
* Only the first pyhton version used will be switched on.
*/
- int no_rtl_global_needed_for(char *python_instsoname)
+ int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
{
int needed = 0;
void* pylib = dlopen(python_instsoname, RTLD_LAZY);
if (pylib != 0)
{
+ void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
void (*init)(void) = dlsym(pylib, "Py_Initialize");
int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
void (*final)(void) = dlsym(pylib, "Py_Finalize");
+ (*pfx)(prefix);
(*init)();
needed = (*simple)("import termios") == -1;
(*final)();
@@ -5750,7 +5752,7 @@ else
int main(int argc, char** argv)
{
int not_needed = 0;
- if (no_rtl_global_needed_for("libpython2.7.so.1.0") && no_rtl_global_needed_for("libpython3.1.so.1.0"))
+ if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}"))
not_needed = 1;
return !not_needed;
}
@@ -5767,8 +5769,76 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
+
CFLAGS=$cflags_save
LDFLAGS=$ldflags_save
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can do without RTLD_GLOBAL for Python3" >&5
+$as_echo_n "checking whether we can do without RTLD_GLOBAL for Python3... " >&6; }
+ cflags_save=$CFLAGS
+ CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
+ ldflags_save=$LDFLAGS
+ LDFLAGS="$LDFLAGS -ldl"
+ if test "$cross_compiling" = yes; then :
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot run test program while cross compiling
+See \`config.log' for more details." "$LINENO" 5; }
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <dlfcn.h>
+ #include <wchar.h>
+ /* If this program fails, then RTLD_GLOBAL is needed.
+ * RTLD_GLOBAL will be used and then it is not possible to
+ * have both python versions enabled in the same vim instance.
+ * Only the first pyhton version used will be switched on.
+ */
+
+ int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
+ {
+ int needed = 0;
+ void* pylib = dlopen(python_instsoname, RTLD_LAZY);
+ if (pylib != 0)
+ {
+ void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
+ void (*init)(void) = dlsym(pylib, "Py_Initialize");
+ int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
+ void (*final)(void) = dlsym(pylib, "Py_Finalize");
+ (*pfx)(prefix);
+ (*init)();
+ needed = (*simple)("import termios") == -1;
+ (*final)();
+ dlclose(pylib);
+ }
+ return !needed;
+ }
+
+ int main(int argc, char** argv)
+ {
+ int not_needed = 0;
+ if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}"))
+ not_needed = 1;
+ return !not_needed;
+ }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; };$as_echo "#define PY3_NO_RTLD_GLOBAL 1" >>confdefs.h
+
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+ CFLAGS=$cflags_save
+ LDFLAGS=$ldflags_save
+
PYTHON_SRC="if_python.c"
PYTHON_OBJ="objects/if_python.o"
PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
diff --git a/src/configure.in b/src/configure.in
index 6ffc675d9..7b5e08f08 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -891,9 +891,9 @@ eof
PYTHON_LIBS="${vi_cv_path_python_plibs}"
if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
- PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
+ PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
else
- PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version}"
+ PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
fi
PYTHON_SRC="if_python.c"
dnl For Mac OSX 10.2 config.o is included in the Python library.
@@ -905,7 +905,7 @@ eof
if test "${vi_cv_var_python_version}" = "1.4"; then
PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
fi
- PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
+ PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
dnl On FreeBSD linking with "-pthread" is required to use threads.
dnl _THREAD_SAFE must be used for compiling then.
@@ -1063,9 +1063,9 @@ eof
PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
- PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}"
+ PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
else
- PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}"
+ PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
fi
PYTHON3_SRC="if_python3.c"
dnl For Mac OSX 10.2 config.o is included in the Python library.
@@ -1143,9 +1143,9 @@ dnl with dlopen(), dlsym(), dlclose()
if test "$python_ok" = yes && test "$python3_ok" = yes; then
AC_DEFINE(DYNAMIC_PYTHON)
AC_DEFINE(DYNAMIC_PYTHON3)
- AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL)
+ AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
cflags_save=$CFLAGS
- CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
+ CFLAGS="$CFLAGS $PYTHON_CFLAGS"
ldflags_save=$LDFLAGS
LDFLAGS="$LDFLAGS -ldl"
AC_RUN_IFELSE([
@@ -1156,15 +1156,17 @@ if test "$python_ok" = yes && test "$python3_ok" = yes; then
* Only the first pyhton version used will be switched on.
*/
- int no_rtl_global_needed_for(char *python_instsoname)
+ int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
{
int needed = 0;
void* pylib = dlopen(python_instsoname, RTLD_LAZY);
if (pylib != 0)
{
+ void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
void (*init)(void) = dlsym(pylib, "Py_Initialize");
int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
void (*final)(void) = dlsym(pylib, "Py_Finalize");
+ (*pfx)(prefix);
(*init)();
needed = (*simple)("import termios") == -1;
(*final)();
@@ -1176,13 +1178,60 @@ if test "$python_ok" = yes && test "$python3_ok" = yes; then
int main(int argc, char** argv)
{
int not_needed = 0;
- if (no_rtl_global_needed_for("libpython2.7.so.1.0") && no_rtl_global_needed_for("libpython3.1.so.1.0"))
+ if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}"))
not_needed = 1;
return !not_needed;
}],
[AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
+
CFLAGS=$cflags_save
LDFLAGS=$ldflags_save
+
+ AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
+ cflags_save=$CFLAGS
+ CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
+ ldflags_save=$LDFLAGS
+ LDFLAGS="$LDFLAGS -ldl"
+ AC_RUN_IFELSE([
+ #include <dlfcn.h>
+ #include <wchar.h>
+ /* If this program fails, then RTLD_GLOBAL is needed.
+ * RTLD_GLOBAL will be used and then it is not possible to
+ * have both python versions enabled in the same vim instance.
+ * Only the first pyhton version used will be switched on.
+ */
+
+ int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
+ {
+ int needed = 0;
+ void* pylib = dlopen(python_instsoname, RTLD_LAZY);
+ if (pylib != 0)
+ {
+ void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
+ void (*init)(void) = dlsym(pylib, "Py_Initialize");
+ int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
+ void (*final)(void) = dlsym(pylib, "Py_Finalize");
+ (*pfx)(prefix);
+ (*init)();
+ needed = (*simple)("import termios") == -1;
+ (*final)();
+ dlclose(pylib);
+ }
+ return !needed;
+ }
+
+ int main(int argc, char** argv)
+ {
+ int not_needed = 0;
+ if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}"))
+ not_needed = 1;
+ return !not_needed;
+ }],
+ [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
+
+ CFLAGS=$cflags_save
+ LDFLAGS=$ldflags_save
+
PYTHON_SRC="if_python.c"
PYTHON_OBJ="objects/if_python.o"
PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
diff --git a/src/if_python.c b/src/if_python.c
index f9bcf5892..26e5f1d88 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -102,7 +102,7 @@ struct PyMethodDef { Py_ssize_t a; };
# include <dlfcn.h>
# define FARPROC void*
# define HINSTANCE void*
-# ifdef PY_NO_RTLD_GLOBAL
+# if defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)
# define load_dll(n) dlopen((n), RTLD_LAZY)
# else
# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
@@ -168,6 +168,7 @@ struct PyMethodDef { Py_ssize_t a; };
# define Py_BuildValue dll_Py_BuildValue
# define Py_FindMethod dll_Py_FindMethod
# define Py_InitModule4 dll_Py_InitModule4
+# define Py_SetPythonHome dll_Py_SetPythonHome
# define Py_Initialize dll_Py_Initialize
# define Py_Finalize dll_Py_Finalize
# define Py_IsInitialized dll_Py_IsInitialized
@@ -226,6 +227,7 @@ static PyTypeObject* dll_PyType_Type;
static PyObject*(*dll_Py_BuildValue)(char *, ...);
static PyObject*(*dll_Py_FindMethod)(struct PyMethodDef[], PyObject *, char *);
static PyObject*(*dll_Py_InitModule4)(char *, struct PyMethodDef *, char *, PyObject *, int);
+static void(*dll_Py_SetPythonHome)(char *home);
static void(*dll_Py_Initialize)(void);
static void(*dll_Py_Finalize)(void);
static int(*dll_Py_IsInitialized)(void);
@@ -310,6 +312,7 @@ static struct
# else
{"Py_InitModule4", (PYTHON_PROC*)&dll_Py_InitModule4},
# endif
+ {"Py_SetPythonHome", (PYTHON_PROC*)&dll_Py_SetPythonHome},
{"Py_Initialize", (PYTHON_PROC*)&dll_Py_Initialize},
{"Py_Finalize", (PYTHON_PROC*)&dll_Py_Finalize},
{"Py_IsInitialized", (PYTHON_PROC*)&dll_Py_IsInitialized},
@@ -349,7 +352,7 @@ python_runtime_link_init(char *libname, int verbose)
{
int i;
-#if !defined(PY_NO_RTLD_GLOBAL) && defined(UNIX) && defined(FEAT_PYTHON3)
+#if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON3)
/* Can't have Python and Python3 loaded at the same time.
* It cause a crash, because RTLD_GLOBAL is needed for
* standard C extension libraries of one or both python versions. */
@@ -543,6 +546,10 @@ Python_Init(void)
}
#endif
+#ifdef PYTHON_HOME
+ Py_SetPythonHome(PYTHON_HOME);
+#endif
+
init_structs();
#if !defined(MACOS) || defined(MACOS_X_UNIX)
diff --git a/src/if_python3.c b/src/if_python3.c
index e56cdbdab..7f3f0f276 100644
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -80,7 +80,7 @@ static void init_structs(void);
# include <dlfcn.h>
# define FARPROC void*
# define HINSTANCE void*
-# ifdef PY_NO_RTLD_GLOBAL
+# if defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)
# define load_dll(n) dlopen((n), RTLD_LAZY)
# else
# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
@@ -132,6 +132,7 @@ static void init_structs(void);
# define PyType_Ready py3_PyType_Ready
#undef Py_BuildValue
# define Py_BuildValue py3_Py_BuildValue
+# define Py_SetPythonHome py3_Py_SetPythonHome
# define Py_Initialize py3_Py_Initialize
# define Py_Finalize py3_Py_Finalize
# define Py_IsInitialized py3_Py_IsInitialized
@@ -170,6 +171,7 @@ static void init_structs(void);
* Pointers for dynamic link
*/
static int (*py3_PySys_SetArgv)(int, wchar_t **);
+static void (*py3_Py_SetPythonHome)(wchar_t *home);
static void (*py3_Py_Initialize)(void);
static PyObject* (*py3_PyList_New)(Py_ssize_t size);
static PyGILState_STATE (*py3_PyGILState_Ensure)(void);
@@ -254,6 +256,7 @@ static struct
} py3_funcname_table[] =
{
{"PySys_SetArgv", (PYTHON_PROC*)&py3_PySys_SetArgv},
+ {"Py_SetPythonHome", (PYTHON_PROC*)&py3_Py_SetPythonHome},
{"Py_Initialize", (PYTHON_PROC*)&py3_Py_Initialize},
{"PyArg_ParseTuple", (PYTHON_PROC*)&py3_PyArg_ParseTuple},
{"PyList_New", (PYTHON_PROC*)&py3_PyList_New},
@@ -336,7 +339,7 @@ py3_runtime_link_init(char *libname, int verbose)
int i;
void *ucs_from_string, *ucs_from_string_and_size;
-# if !defined(PY_NO_RTLD_GLOBAL) && defined(UNIX) && defined(FEAT_PYTHON)
+# if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON)
/* Can't have Python and Python3 loaded at the same time.
* It cause a crash, because RTLD_GLOBAL is needed for
* standard C extension libraries of one or both python versions. */
@@ -539,6 +542,11 @@ Python3_Init(void)
init_structs();
+
+#ifdef PYTHON3_HOME
+ Py_SetPythonHome(PYTHON3_HOME);
+#endif
+
/* initialise threads */
PyEval_InitThreads();
diff --git a/src/version.c b/src/version.c
index d46d9a0d4..da022457b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -715,6 +715,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 62,
+/**/
61,
/**/
60,