Pārlūkot izejas kodu

HPCC-18717 Python 3 embedded code may fail on imports

Apply same workaround to Python3 plugin as was needed on Python2 (for some
distros).

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 7 gadi atpakaļ
vecāks
revīzija
0dfee12b60
2 mainītis faili ar 11 papildinājumiem un 1 dzēšanām
  1. 1 1
      plugins/Rembed/Rembed.cpp
  2. 10 0
      plugins/py3embed/py3embed.cpp

+ 1 - 1
plugins/Rembed/Rembed.cpp

@@ -624,7 +624,7 @@ public:
     virtual void processBeginSet(const RtlFieldInfo * field, bool &isAll)
     {
         nextField(field);
-        isAll = false;  // No concept of an 'all' set in Python
+        isAll = false;  // No concept of an 'all' set in R
         Rcpp::List childrec = ::Rcpp::as<Rcpp::List>(elem);  // MORE - is converting it to a list inefficient? Keeps the code simpler!
         stack.append(*new ListState(childrec, field));
     }

+ 10 - 0
plugins/py3embed/py3embed.cpp

@@ -268,6 +268,16 @@ public:
             return;
         }
 #endif
+#ifndef _WIN32
+        // We need to ensure all symbols in the python3.x so are loaded - due to bugs in some distro's python installations
+        // However this will likely break python2.
+        // Therefore on systems where both are present, do NOT do this - people using centos systems that suffer from issue
+        // https://bugs.centos.org/view.php?id=6063 will need to choose which version of python plugin to install but not both
+
+        StringBuffer modname, py2modname;
+        if  (findLoadedModule(modname, "libpython3.") && !findLoadedModule(py2modname, "libpython2."))
+            pythonLibrary = dlopen(modname.str(), RTLD_NOW|RTLD_GLOBAL);
+#endif
         // Initialize the Python Interpreter
         Py_Initialize();
         const wchar_t *argv[] = { nullptr };