From f0237be035e052c06c6a4182670065a329821ae5 Mon Sep 17 00:00:00 2001 From: sudacode Date: Fri, 4 Apr 2025 03:43:22 -0700 Subject: [PATCH] update script to use virtual environment --- scripts/anilistUpdater/main.lua | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/anilistUpdater/main.lua b/scripts/anilistUpdater/main.lua index 07dee7e..14ee38c 100644 --- a/scripts/anilistUpdater/main.lua +++ b/scripts/anilistUpdater/main.lua @@ -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