update script to use virtual environment

This commit is contained in:
sudacode 2025-04-04 03:43:22 -07:00
parent 5260564aaf
commit f0237be035

View File

@ -15,13 +15,30 @@ function callback(success, result, error)
end
local function get_python_command()
-- Determine OS type
local os_name = package.config:sub(1, 1)
-- Get the path to this Lua file
local info = debug.getinfo(1, "S")
local script_path = info.source:sub(info.source:find("@") == 1 and 2 or 1)
-- Extract the directory containing this file
local script_dir
if os_name == "\\" then
-- Windows
return "python"
script_dir = script_path:match("(.+)\\[^\\]+$") or "."
else
-- Linux
return "python3"
-- Unix
script_dir = script_path:match("(.+)/[^/]+$") or "."
end
-- Build absolute path to the Python executable in the virtual environment
if os_name == "\\" then
-- Windows
return script_dir .. "\\env\\Scripts\\python.exe"
else
-- Unix
return script_dir .. "/env/bin/python3"
end
end