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


##########
extensions/python/CMakeLists.txt:
##########
@@ -38,9 +41,7 @@ endif()
 target_compile_definitions(minifi-python-script-extension PUBLIC 
PY_SSIZE_T_CLEAN)
 
 target_sources(minifi-python-script-extension PRIVATE ${PY_SOURCES})
-if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
-    target_link_libraries(minifi-python-script-extension PUBLIC 
-Wl,--no-as-needed ${Python_LIBRARIES} -Wl,--as-needed)
-else()
+if (WIN32 OR APPLE)

Review Comment:
   A comment would be nice here to explain that on Linux, libpython is loaded 
dynamically in PythonLibLoader.cpp



##########
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();
+    }

Review Comment:
   I don't think this finds the latest installed version e.g. on RHEL8, where 
python 3.6 and python 3.12 can be installed at the same time.



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