From 21cb3d0821b0963adc02ca6491840bac0eafc819 Mon Sep 17 00:00:00 2001 From: slzhou Date: Wed, 22 Feb 2023 12:11:57 +0800 Subject: [PATCH] fix: improve pythonpath env variable to include tsTempDir --- source/libs/function/src/udfd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index ed5f87647f..0e3c6a4def 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -347,8 +347,16 @@ void udfdInitializePythonPlugin(SUdfScriptPlugin *plugin) { return; } if (plugin->openFunc) { - SScriptUdfEnvItem items[] ={{"PYTHONPATH", tsUdfdLdLibPath}}; + int16_t lenPythonPath = strlen(tsUdfdLdLibPath) + strlen(tsTempDir) + 1 + 1; //tsTempDir:tsUdfdLdLibPath + char* pythonPath= taosMemoryMalloc(lenPythonPath); + #ifdef WINDOWS + snprintf(pythonPath, lenPythonPath, "%s;%s", tsTempDir, tsUdfdLdLibPath); + #else + snprintf(pythonPath, lenPythonPath, "%s:%s", tsTempDir, tsUdfdLdLibPath); + #endif + SScriptUdfEnvItem items[] ={{"PYTHONPATH", pythonPath}}; plugin->openFunc(items, 1); + taosMemoryFree(pythonPath); } plugin->libLoaded = true; return; -- GitLab