Skip to content

Commit c573339

Browse files
committed
Up
1 parent da1a394 commit c573339

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

c_src/pythonx/pythonx.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ fine::Ok<> init(ErlNifEnv *env, std::string python_dl_path,
263263
// containing the built-in Python modules [1].
264264
//
265265
// [1]: https://docs.python.org/3/using/cmdline.html#envvar-PYTHONHOME
266-
// Py_SetPythonHome(python_home_path_w.c_str());
266+
Py_SetPythonHome(python_home_path_w.c_str());
267267
Py_SetProgramName(python_executable_path_w.c_str());
268268

269269
Py_InitializeEx(0);
@@ -299,14 +299,14 @@ fine::Ok<> init(ErlNifEnv *env, std::string python_dl_path,
299299
raise_if_failed(env, py_sys_path);
300300
auto py_sys_path_guard = PyDecRefGuard(py_sys_path);
301301

302-
// for (const auto &path : sys_paths) {
303-
// auto py_path = PyUnicode_FromStringAndSize(
304-
// reinterpret_cast<const char *>(path.data), path.size);
305-
// raise_if_failed(env, py_path);
306-
// auto py_path_guard = PyDecRefGuard(py_path);
302+
for (const auto &path : sys_paths) {
303+
auto py_path = PyUnicode_FromStringAndSize(
304+
reinterpret_cast<const char *>(path.data), path.size);
305+
raise_if_failed(env, py_path);
306+
auto py_path_guard = PyDecRefGuard(py_path);
307307

308-
// raise_if_failed(env, PyList_Append(py_sys_path, py_path));
309-
// }
308+
raise_if_failed(env, PyList_Append(py_sys_path, py_path));
309+
}
310310

311311
// Define global stdout and stdin overrides
312312

lib/pythonx.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ defmodule Pythonx do
3939
"""
4040
@spec init(String.t(), String.t(), keyword()) :: :ok
4141
def init(python_dl_path, python_home_path, python_executable_path, opts \\ [])
42-
when is_binary(python_dl_path) and is_binary(python_home_path) and is_list(opts) do
42+
when is_binary(python_dl_path) and is_binary(python_home_path)
43+
when is_binary(python_executable_path) and is_list(opts) do
4344
opts = Keyword.validate!(opts, sys_paths: [])
4445

4546
if not File.exists?(python_dl_path) do
@@ -50,6 +51,10 @@ defmodule Pythonx do
5051
raise ArgumentError, "the given python home directory does not exist: #{python_home_path}"
5152
end
5253

54+
if not File.exists?(python_home_path) do
55+
raise ArgumentError, "the given python executable does not exist: #{python_executable_path}"
56+
end
57+
5358
Pythonx.NIF.init(python_dl_path, python_home_path, python_executable_path, opts[:sys_paths])
5459
end
5560

lib/pythonx/uv.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ defmodule Pythonx.Uv do
106106

107107
python_home_path = make_windows_slashes(root_dir)
108108

109-
python_executable_path = Path.join(abs_executable_dir, "python.exe")
109+
python_executable_path =
110+
abs_executable_dir
111+
|> Path.join("python.exe")
112+
|> make_windows_slashes()
110113

111114
venv_packages_path =
112115
project_dir

0 commit comments

Comments
 (0)