@@ -23,6 +23,7 @@ using namespace python;
2323std::mutex init_mutex;
2424bool is_initialized = false ;
2525std::wstring python_home_path_w;
26+ std::wstring python_executable_path_w;
2627std::map<std::string, std::tuple<PyObjectPtr, PyObjectPtr>> compilation_cache;
2728std::mutex compilation_cache_mutex;
2829
@@ -225,6 +226,7 @@ ERL_NIF_TERM py_object_to_binary_term(ErlNifEnv *env, PyObjectPtr py_object) {
225226
226227fine::Ok<> init (ErlNifEnv *env, std::string python_dl_path,
227228 ErlNifBinary python_home_path,
229+ ErlNifBinary python_executable_path,
228230 std::vector<ErlNifBinary> sys_paths) {
229231 auto init_guard = std::lock_guard<std::mutex>(init_mutex);
230232
@@ -240,6 +242,10 @@ fine::Ok<> init(ErlNifEnv *env, std::string python_dl_path,
240242 python_home_path_w = std::wstring (
241243 python_home_path.data , python_home_path.data + python_home_path.size );
242244
245+ python_executable_path_w =
246+ std::wstring (python_executable_path.data ,
247+ python_executable_path.data + python_executable_path.size );
248+
243249 // As part of the initialization, sys.path is set. It is important
244250 // that it gets set correctly, so that the built-in modules can be
245251 // found, otherwise the initialization fails. This logic is internal
@@ -259,6 +265,8 @@ fine::Ok<> init(ErlNifEnv *env, std::string python_dl_path,
259265 // [1]: https://docs.python.org/3/using/cmdline.html#envvar-PYTHONHOME
260266 Py_SetPythonHome (python_home_path_w.c_str ());
261267
268+ Py_SetProgramName (python_executable_path_w.c_str ());
269+
262270 Py_InitializeEx (0 );
263271
264272 // In order to use any of the Python C API functions, the calling
0 commit comments