From 474eeff4df868de994758753ae70752e6efd5cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 1 May 2024 19:34:32 +0800 Subject: [PATCH] fix --- plugins/exec/PyStand.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/exec/PyStand.cpp b/plugins/exec/PyStand.cpp index 0f832243..4198f652 100644 --- a/plugins/exec/PyStand.cpp +++ b/plugins/exec/PyStand.cpp @@ -259,6 +259,11 @@ int PyStand::DetectScript() return -1; } SetEnvironmentVariableW(L"PYSTAND_SCRIPT", _script.c_str()); + + std::vector buffer(MAX_PATH); + GetModuleFileNameW(GetModuleHandle(0), buffer.data(), MAX_PATH); + SetEnvironmentVariableW(L"LUNA_EXE_NAME", buffer.data()); + return 0; } @@ -294,7 +299,7 @@ const auto init_script = L" sys.stderr = fp\n" L" attached = False\n" #endif - L"sys.argv = [sys.argv[0], PYSTAND_SCRIPT] + sys.argv[1:]\n" + L"sys.argv = [os.environ['LUNA_EXE_NAME'] ,sys.argv[0], PYSTAND_SCRIPT] + sys.argv[1:]\n" L"text = open(PYSTAND_SCRIPT, 'rb').read()\n" L"environ = {'__file__': PYSTAND_SCRIPT, '__name__': '__main__'}\n" L"environ['__package__'] = None\n"