Open gilescope opened 4 years ago
Sorry for the delayed response here. What would your example use case be for Py_SetPythonHome
? I've never come across a situation where I've needed to change the python library location (virtualenvs?), but that could just be me.
The reason is we are using conda, and therefore python is not in the "standard location". This breaks the python interpreter initialization code, unless you have pythonhome set. And setting it today requires a bit of platform specific code in the vein of : ` unsafe {
let raw_ptr = WideCString::from_str(conda_prefix).unwrap().into_raw();
#[cfg(not(windows))]
let raw_ptr = WideCString::from_str(conda_prefix).unwrap().into_raw() as *mut i32;
pyo3::ffi::Py_SetPythonHome(raw_ptr);
};`
Online python doc explaining: https://docs.python.org/2.0/api/embedding.html
(We are using setuptools-rust not maturin if thst sheds any light. I am guessing at some point we should switch over?)
Sent with GitHawk
All of the above sounds reasonable. We could easily add some wrappers for these functions.
Just one stupid question - I'm assuming you have reasons why you want to use this function rather than set the PYTHONHOME
env var?
Could there be an os independent wrapper around things like Py_SetPythonHome? It's not the most rustic of ffi interfaces and the sizes change between windows and linux.