This is an automated email from the ASF dual-hosted git repository.

szaszm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git

commit e1eae4ccc3c415a82173e14157ce031711a047ba
Author: Gabor Gyimesi <[email protected]>
AuthorDate: Tue Jul 16 16:01:54 2024 +0000

    MINIFICPP-2425 Prioritize virtualenv packages over system packages in 
python processors
    
    Closes #1837
    
    Signed-off-by: Marton Szasz <[email protected]>
---
 extensions/python/PythonDependencyInstaller.cpp | 2 +-
 extensions/python/PythonScriptEngine.cpp        | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/extensions/python/PythonDependencyInstaller.cpp 
b/extensions/python/PythonDependencyInstaller.cpp
index 6b6d92249..4df1bc83c 100644
--- a/extensions/python/PythonDependencyInstaller.cpp
+++ b/extensions/python/PythonDependencyInstaller.cpp
@@ -168,7 +168,7 @@ void PythonDependencyInstaller::addVirtualenvToPath() const 
{
     if (!std::filesystem::exists(site_package_path)) {
       throw PythonScriptException("Could not find python site package path: " 
+ site_package_path.string());
     }
-    evalScript("import sys\nsys.path.append(r'" + site_package_path.string() + 
"')");
+    evalScript("import sys\nsys.path.insert(0, r'" + 
site_package_path.string() + "')");
   }
 }
 
diff --git a/extensions/python/PythonScriptEngine.cpp 
b/extensions/python/PythonScriptEngine.cpp
index d3ac5927c..ccf615693 100644
--- a/extensions/python/PythonScriptEngine.cpp
+++ b/extensions/python/PythonScriptEngine.cpp
@@ -135,9 +135,9 @@ void PythonScriptEngine::evaluateModuleImports() {
 
   for (const auto& module_path : module_paths_) {
     if (std::filesystem::is_regular_file(module_path)) {
-      evalInternal("sys.path.append(r'" + module_path.parent_path().string() + 
"')");
+      evalInternal("sys.path.insert(0, r'" + 
module_path.parent_path().string() + "')");
     } else {
-      evalInternal("sys.path.append(r'" + module_path.string() + "')");
+      evalInternal("sys.path.insert(0, r'" + module_path.string() + "')");
     }
   }
 }

Reply via email to