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


##########
extensions/python/PythonScriptEngine.cpp:
##########
@@ -68,6 +67,73 @@ void initThreads() {
 #pragma warning(pop)
 #endif
 }
+
+std::string encapsulateCommandInQuotesIfNeeded(const std::string& command) {
+#if WIN32
+    return "\"" + command + "\"";
+#else
+    return command;
+#endif
+}
+
+std::vector<std::filesystem::path> getRequirementsFilePaths(const 
std::shared_ptr<Configure> &configuration) {
+  std::vector<std::filesystem::path> paths;
+  if (auto python_processor_path = 
configuration->get(minifi::Configuration::nifi_python_processor_dir)) {
+    for (const auto& entry : 
std::filesystem::recursive_directory_iterator(std::filesystem::path{*python_processor_path}))
 {
+      if (std::filesystem::is_regular_file(entry.path()) && 
entry.path().filename() == "requirements.txt") {
+        paths.push_back(entry.path());
+      }
+    }
+  }
+  return paths;
+}
+
+std::string getPythonBinary(const std::shared_ptr<Configure> &configuration) {
+#if WIN32
+  std::string python_binary = "python";
+#else
+  std::string python_binary = "python3";
+#endif
+  if (auto binary = 
configuration->get(minifi::Configuration::nifi_python_env_setup_binary)) {
+    python_binary = *binary;
+  }
+  return python_binary;
+}
+
+void createVirtualEnvIfSpecified(const std::shared_ptr<Configure> 
&configuration) {
+  if (auto path = 
configuration->get(minifi::Configuration::nifi_python_virtualenv_directory)) {
+    PythonConfigState::getInstance().virtualenv_path = *path;
+    if 
(!std::filesystem::exists(PythonConfigState::getInstance().virtualenv_path) || 
!std::filesystem::is_empty(PythonConfigState::getInstance().virtualenv_path)) {

Review Comment:
   Good catch, we should only create a virtualenv if the directory is empty, 
probably didn't update the condition while refactoring and didn't retest this, 
updated in 44654b11b315ed6010424cb72abb334b8b286377



-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to