lordgamez commented on code in PR #1889:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1889#discussion_r1829324015


##########
extensions/python/pythonlibloader/PythonLibLoader.cpp:
##########
@@ -0,0 +1,96 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#if !defined(WIN32) && !defined(__APPLE__)
+#include <dlfcn.h>
+#include <cstdio>
+#include <iostream>
+#include <string>
+#include <array>
+#include "utils/StringUtils.h"
+#include "core/logging/LoggerConfiguration.h"
+#endif
+#include "core/extension/Extension.h"
+
+namespace minifi = org::apache::nifi::minifi;
+
+#if !defined(WIN32) && !defined(__APPLE__)
+class PythonLibLoader {
+ public:
+  explicit PythonLibLoader(const std::shared_ptr<minifi::Configure>& config) {
+    std::string python_command = "python3";
+    if (auto python_binary = 
config->get(minifi::Configure::nifi_python_env_setup_binary)) {
+      python_command = python_binary.value();
+    }
+    std::string command = python_command +
+      " -c \"import sysconfig, os, glob; 
print(min(glob.glob(os.path.join(sysconfig.get_config_var('LIBDIR'), 
f\\\"libpython{sysconfig.get_config_var('VERSION')}.so*\\\")), key=len, 
default=''))\"";
+    auto lib_python_path = execCommand(command);
+    if (lib_python_path.empty()) {

Review Comment:
   Good idea, added version check and error message with exception in 
0e1f0b84d0008e6fe93abd33ee24e4924da581cd



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to