comparison src/if_python3.c @ 13154:53cc7ea77c54 v8.0.1451

patch 8.0.1451: difficult to set the python home directories properly commit https://github.com/vim/vim/commit/94073167e3aa8cbe18380e93a2fc8e8165438cc8 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 31 21:49:05 2018 +0100 patch 8.0.1451: difficult to set the python home directories properly Problem: It is difficult to set the python home directory properly for Python 2.7 and 3.5 since both use $PYTHONHOME. Solution: Add the 'pythonhome' and 'pythonthreehome' options. (Kazuki Sakamoto, closes #1266)
author Christian Brabandt <cb@256bit.org>
date Wed, 31 Jan 2018 22:00:07 +0100
parents 351cf7c67bbe
children eafe575966ff
comparison
equal deleted inserted replaced
13153:c30f721849cb 13154:53cc7ea77c54
840 { 840 {
841 return (hinstPy3 != 0); 841 return (hinstPy3 != 0);
842 } 842 }
843 #endif 843 #endif
844 844
845 static wchar_t *py_home_buf = NULL;
846
845 static int 847 static int
846 Python3_Init(void) 848 Python3_Init(void)
847 { 849 {
848 if (!py3initialised) 850 if (!py3initialised)
849 { 851 {
855 } 857 }
856 #endif 858 #endif
857 859
858 init_structs(); 860 init_structs();
859 861
860 862 if (*p_py3home != NUL)
863 {
864 size_t len = mbstowcs(NULL, (char *)p_py3home, 0) + 1;
865
866 /* The string must not change later, make a copy in static memory. */
867 py_home_buf = (wchar_t *)alloc(len * sizeof(wchar_t));
868 if (py_home_buf != NULL && mbstowcs(
869 py_home_buf, (char *)p_py3home, len) != (size_t)-1)
870 Py_SetPythonHome(py_home_buf);
871 }
861 #ifdef PYTHON3_HOME 872 #ifdef PYTHON3_HOME
862 # ifdef DYNAMIC_PYTHON3 873 else if (mch_getenv((char_u *)"PYTHONHOME") == NULL)
863 if (mch_getenv((char_u *)"PYTHONHOME") == NULL)
864 # endif
865 Py_SetPythonHome(PYTHON3_HOME); 874 Py_SetPythonHome(PYTHON3_HOME);
866 #endif 875 #endif
867 876
868 PyImport_AppendInittab("vim", Py3Init_vim); 877 PyImport_AppendInittab("vim", Py3Init_vim);
869 878