summaryrefslogtreecommitdiff
path: root/src/if_python.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-01-31 21:49:05 +0100
committerBram Moolenaar <Bram@vim.org>2018-01-31 21:49:05 +0100
commit94073167e3aa8cbe18380e93a2fc8e8165438cc8 (patch)
tree2e7c3078ffc53518b95979a118b16403699381ae /src/if_python.c
parent1dd45fb4f3371f0256653b2186c8b4b3d26b3f41 (diff)
downloadvim-git-94073167e3aa8cbe18380e93a2fc8e8165438cc8.tar.gz
patch 8.0.1451: difficult to set the python home directories properlyv8.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)
Diffstat (limited to 'src/if_python.c')
-rw-r--r--src/if_python.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/if_python.c b/src/if_python.c
index f9fc5e1a5..ab9c854b2 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -912,6 +912,8 @@ python_loaded(void)
}
#endif
+static char *py_home_buf = NULL;
+
static int
Python_Init(void)
{
@@ -929,10 +931,15 @@ Python_Init(void)
}
#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
-# ifdef DYNAMIC_PYTHON
- if (mch_getenv((char_u *)"PYTHONHOME") == NULL)
-# endif
+ else if (mch_getenv((char_u *)"PYTHONHOME") == NULL)
Py_SetPythonHome(PYTHON_HOME);
#endif