To: vim_dev@googlegroups.com Subject: Patch 8.0.1451 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1451 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) Files: runtime/doc/options.txt, runtime/doc/quickref.txt, runtime/optwin.vim, src/if_python.c, src/if_python3.c, src/option.c, src/option.h *** ../vim-8.0.1450/runtime/doc/options.txt 2018-01-31 20:51:40.297835998 +0100 --- runtime/doc/options.txt 2018-01-31 21:18:11.164009636 +0100 *************** *** 5863,5868 **** --- 5967,5986 ---- This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. + *'pythonhome'* + 'pythonhome' string (default "") + global + {not in Vi} + {only available when compiled with the |+python/dyn| + feature} + Specifies the name of the Python 2.x home directory. When 'pythonhome' + and the PYTHONHOME environment variable are not set, PYTHON_HOME, + which was specified at compile time, will be used for the Python 2.x + home directory. + Environment variables are expanded |:set_env|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + *'pythonthreedll'* 'pythonthreedll' string (default depends on the build) global *************** *** 5875,5880 **** --- 5993,6012 ---- This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. + *'pythonthreehome'* + 'pythonthreehome' string (default "") + global + {not in Vi} + {only available when compiled with the |+python3/dyn| + feature} + Specifies the name of the Python 3 home directory. When + 'pythonthreehome' and the PYTHONHOME environment variable are not set, + PYTHON3_HOME, which was specified at compile time, will be used for + the Python 3 home directory. + Environment variables are expanded |:set_env|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + *'pyxversion'* *'pyx'* 'pyxversion' 'pyx' number (default depends on the build) global *** ../vim-8.0.1450/runtime/doc/quickref.txt 2017-03-05 17:43:10.612245634 +0100 --- runtime/doc/quickref.txt 2018-01-31 21:19:11.648106570 +0100 *************** *** 835,841 **** --- 839,847 ---- 'prompt' 'prompt' enable prompt in Ex mode 'pumheight' 'ph' maximum height of the popup menu 'pythondll' name of the Python 2 dynamic library + 'pythonhome' name of the Python 2 home directory 'pythonthreedll' name of the Python 3 dynamic library + 'pythonthreehome' name of the Python 3 home directory 'pyxversion' 'pyx' Python version used for pyx* commands 'quoteescape' 'qe' escape characters used in a string 'readonly' 'ro' disallow writing the buffer *** ../vim-8.0.1450/runtime/optwin.vim 2017-08-19 23:17:58.321226115 +0200 --- runtime/optwin.vim 2018-01-31 21:18:11.168009645 +0100 *************** *** 1,7 **** " These commands create the option window. " " Maintainer: Bram Moolenaar ! " Last Change: 2017 Aug 19 " If there already is an option window, jump to that one. let buf = bufnr('option-window') --- 1,7 ---- " These commands create the option window. " " Maintainer: Bram Moolenaar ! " Last Change: 2017 Nov 21 " If there already is an option window, jump to that one. let buf = bufnr('option-window') *************** *** 647,657 **** endif call append("$", "linespace\tnumber of pixel lines to use between characters") call append("$", " \tset lsp=" . &lsp) ! if has("balloon_eval") call append("$", "balloondelay\tdelay in milliseconds before a balloon may pop up") call append("$", " \tset bdlay=" . &bdlay) ! call append("$", "ballooneval\twhether the balloon evaluation is to be used") ! call BinOptionG("beval", &beval) if has("eval") call append("$", "balloonexpr\texpression to show in balloon eval") call append("$", " \tset bexpr=" . &bexpr) --- 647,663 ---- endif call append("$", "linespace\tnumber of pixel lines to use between characters") call append("$", " \tset lsp=" . &lsp) ! if has("balloon_eval") || has("balloon_eval_term") call append("$", "balloondelay\tdelay in milliseconds before a balloon may pop up") call append("$", " \tset bdlay=" . &bdlay) ! if has("balloon_eval") ! call append("$", "ballooneval\tuse balloon evaluation in the GUI") ! call BinOptionG("beval", &beval) ! endif ! if has("balloon_eval_term") ! call append("$", "balloonevalterm\tuse balloon evaluation in the terminal") ! call BinOptionG("bevalterm", &beval) ! endif if has("eval") call append("$", "balloonexpr\texpression to show in balloon eval") call append("$", " \tset bexpr=" . &bexpr) *************** *** 1225,1230 **** --- 1231,1238 ---- call append("$", "iminsert\tin Insert mode: 1: use :lmap; 2: use IM; 0: neither") call append("$", "\t(local to window)") call OptionL("imi") + call append("$", "imstyle\tinput method style, 0: on-the-spot, 1: over-the-spot") + call OptionG("imst", &imst) call append("$", "imsearch\tentering a search pattern: 1: use :lmap; 2: use IM; 0: neither") call append("$", "\t(local to window)") call OptionL("ims") *************** *** 1346,1355 **** --- 1354,1371 ---- call append("$", "pythondll\tname of the Python 2 dynamic library") call OptionG("pythondll", &pythondll) endif + if exists("&pythonhome") + call append("$", "pythonhome\tname of the Python 2 home directory") + call OptionG("pythonhome", &pythonhome) + endif if exists("&pythonthreedll") call append("$", "pythonthreedll\tname of the Python 3 dynamic library") call OptionG("pythonthreedll", &pythonthreedll) endif + if exists("&pythonthreehome") + call append("$", "pythonthreehome\tname of the Python 3 home directory") + call OptionG("pythonthreehome", &pythonthreehome) + endif if exists("&rubydll") call append("$", "rubydll\tname of the Ruby dynamic library") call OptionG("rubydll", &rubydll) *************** *** 1358,1363 **** --- 1374,1385 ---- call append("$", "tcldll\tname of the Tcl dynamic library") call OptionG("tcldll", &tcldll) endif + if exists("&mzschemedll") + call append("$", "mzschemedll\tname of the Tcl dynamic library") + call OptionG("mzschemedll", &mzschemedll) + call append("$", "mzschemegcdll\tname of the Tcl GC dynamic library") + call OptionG("mzschemegcdll", &mzschemegcdll) + endif set cpo&vim *** ../vim-8.0.1450/src/if_python.c 2017-10-28 21:08:38.983456981 +0200 --- src/if_python.c 2018-01-31 21:39:21.583889498 +0100 *************** *** 912,917 **** --- 912,919 ---- } #endif + static char *py_home_buf = NULL; + static int Python_Init(void) { *************** *** 929,938 **** } #endif #ifdef PYTHON_HOME ! # ifdef DYNAMIC_PYTHON ! if (mch_getenv((char_u *)"PYTHONHOME") == NULL) ! # endif Py_SetPythonHome(PYTHON_HOME); #endif --- 931,945 ---- } #endif + if (*p_pyhome != NUL) + { + /* The string must not change later, make a copy in static memory. */ + py_home_buf = (char *)vim_strsave(p_pyhome); + if (py_home_buf != NULL) + Py_SetPythonHome(py_home_buf); + } #ifdef PYTHON_HOME ! else if (mch_getenv((char_u *)"PYTHONHOME") == NULL) Py_SetPythonHome(PYTHON_HOME); #endif *** ../vim-8.0.1450/src/if_python3.c 2017-10-28 21:08:38.983456981 +0200 --- src/if_python3.c 2018-01-31 21:42:19.990861260 +0100 *************** *** 842,847 **** --- 842,849 ---- } #endif + static wchar_t *py_home_buf = NULL; + static int Python3_Init(void) { *************** *** 857,867 **** init_structs(); #ifdef PYTHON3_HOME ! # ifdef DYNAMIC_PYTHON3 ! if (mch_getenv((char_u *)"PYTHONHOME") == NULL) ! # endif Py_SetPythonHome(PYTHON3_HOME); #endif --- 859,876 ---- init_structs(); + if (*p_py3home != NUL) + { + size_t len = mbstowcs(NULL, (char *)p_py3home, 0) + 1; + /* The string must not change later, make a copy in static memory. */ + py_home_buf = (wchar_t *)alloc(len * sizeof(wchar_t)); + if (py_home_buf != NULL && mbstowcs( + py_home_buf, (char *)p_py3home, len) != (size_t)-1) + Py_SetPythonHome(py_home_buf); + } #ifdef PYTHON3_HOME ! else if (mch_getenv((char_u *)"PYTHONHOME") == NULL) Py_SetPythonHome(PYTHON3_HOME); #endif *** ../vim-8.0.1450/src/option.c 2017-12-05 16:57:52.230668085 +0100 --- src/option.c 2018-01-31 21:22:21.556088818 +0100 *************** *** 2248,2253 **** --- 2248,2262 ---- {(char_u *)NULL, (char_u *)0L} #endif SCRIPTID_INIT}, + {"pythonthreehome", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, + #if defined(FEAT_PYTHON3) + (char_u *)&p_py3home, PV_NONE, + {(char_u *)"", (char_u *)0L} + #else + (char_u *)NULL, PV_NONE, + {(char_u *)NULL, (char_u *)0L} + #endif + SCRIPTID_INIT}, {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, #if defined(DYNAMIC_PYTHON) (char_u *)&p_pydll, PV_NONE, *************** *** 2255,2260 **** --- 2264,2278 ---- #else (char_u *)NULL, PV_NONE, {(char_u *)NULL, (char_u *)0L} + #endif + SCRIPTID_INIT}, + {"pythonhome", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, + #if defined(FEAT_PYTHON) + (char_u *)&p_pyhome, PV_NONE, + {(char_u *)"", (char_u *)0L} + #else + (char_u *)NULL, PV_NONE, + {(char_u *)NULL, (char_u *)0L} #endif SCRIPTID_INIT}, {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE, *** ../vim-8.0.1450/src/option.h 2017-11-25 17:14:29.608189513 +0100 --- src/option.h 2018-01-31 21:23:07.892023392 +0100 *************** *** 696,704 **** --- 696,710 ---- #if defined(DYNAMIC_PYTHON3) EXTERN char_u *p_py3dll; /* 'pythonthreedll' */ #endif + #ifdef FEAT_PYTHON3 + EXTERN char_u *p_py3home; /* 'pythonthreehome' */ + #endif #if defined(DYNAMIC_PYTHON) EXTERN char_u *p_pydll; /* 'pythondll' */ #endif + #ifdef FEAT_PYTHON + EXTERN char_u *p_pyhome; /* 'pythonhome' */ + #endif #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) EXTERN long p_pyx; /* 'pyxversion' */ #endif *** ../vim-8.0.1450/src/version.c 2018-01-31 21:09:57.643847455 +0100 --- src/version.c 2018-01-31 21:46:56.757207791 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1451, /**/ -- Life would be so much easier if we could just look at the source code. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///