From 087da376b72b24a51b077fe067cbdea675884ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Tue, 4 Mar 2025 01:40:09 +0900 Subject: [PATCH] Change sys.executable to python executable inside venv --- lib/pythonx.ex | 5 ++++- lib/pythonx/uv.ex | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/pythonx.ex b/lib/pythonx.ex index 733904d..f12a300 100644 --- a/lib/pythonx.ex +++ b/lib/pythonx.ex @@ -76,7 +76,10 @@ defmodule Pythonx do # located in `{python_home_path}/lib/pythonx.y` (Linux and macOS) # or `{python_home_path}/Lib` (Windows). # - # `python_executable_path` is the Python executable file. + # `python_executable_path` is the Python executable file. When using + # venv, it is preferable to point to an executable in the venv + # directory, which is relevant if additional packages are installed + # at runtime. # # ## Options # diff --git a/lib/pythonx/uv.ex b/lib/pythonx/uv.ex index 41f3a04..e274c3f 100644 --- a/lib/pythonx/uv.ex +++ b/lib/pythonx/uv.ex @@ -107,8 +107,8 @@ defmodule Pythonx.Uv do python_home_path = make_windows_slashes(root_dir) python_executable_path = - abs_executable_dir - |> Path.join("python.exe") + project_dir + |> Path.join(".venv/Scripts/python.exe") |> make_windows_slashes() venv_packages_path = @@ -135,7 +135,7 @@ defmodule Pythonx.Uv do python_home_path = root_dir - python_executable_path = Path.join(abs_executable_dir, "python") + python_executable_path = Path.join(project_dir, ".venv/bin/python") venv_packages_path = project_dir