fix: improve pythonpath env variable to include tsTempDir

This commit is contained in:
slzhou 2023-02-22 12:11:57 +08:00
parent 898bd0ed33
commit 21cb3d0821
1 changed files with 9 additions and 1 deletions

View File

@ -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;