You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by sz...@apache.org on 2022/11/09 02:05:07 UTC

[nifi-minifi-cpp] branch main updated: MINIFICPP-1977 Upgrade pybind11 to support Python 3.11

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


The following commit(s) were added to refs/heads/main by this push:
     new 4b6daa2f9 MINIFICPP-1977 Upgrade pybind11 to support Python 3.11
4b6daa2f9 is described below

commit 4b6daa2f9978987860e0dd6808be993a6abcc306
Author: Gabor Gyimesi <ga...@gmail.com>
AuthorDate: Tue Nov 8 18:11:29 2022 +0100

    MINIFICPP-1977 Upgrade pybind11 to support Python 3.11
    
    Pybind11 implemented support for Python 3.11 in version 2.10.1:
    https://pybind11.readthedocs.io/en/stable/changelog.html#version-2-10-1-oct-31-2022
    
    Upgraded to this version to avoid CI and other build failures using
    Python 3.11 libs.
    
    Closes #1448
    Signed-off-by: Marton Szasz <sz...@apache.org>
---
 .github/workflows/ci.yml                           |  2 +-
 cmake/Pybind11.cmake                               |  4 ++--
 extensions/script/CMakeLists.txt                   |  5 +---
 extensions/script/tests/CMakeLists.txt             | 28 ++++++++++++++++++----
 .../script/tests/ExecutePythonProcessorTests.cpp   |  2 +-
 .../TestExecuteScriptProcessorWithPythonScript.cpp |  6 +----
 .../standard-processors/tests/CMakeLists.txt       | 18 +++++++-------
 win_build_vs.bat                                   |  4 +++-
 8 files changed, 42 insertions(+), 27 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1aaf77db3..3ecbd4aff 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -55,7 +55,7 @@ jobs:
       - name: Set up Python
         uses: actions/setup-python@v4
         with:
-          python-version: '3.10'
+          python-version: '3.11'
       - name: Set up Lua
         uses: xpol/setup-lua@v0.3
       - id: install-sqliteodbc-driver
diff --git a/cmake/Pybind11.cmake b/cmake/Pybind11.cmake
index 5bceb2f93..ccaadc750 100644
--- a/cmake/Pybind11.cmake
+++ b/cmake/Pybind11.cmake
@@ -18,8 +18,8 @@
 include(FetchContent)
 
 FetchContent_Declare(pybind11_src
-    URL      https://github.com/pybind/pybind11/archive/refs/tags/v2.7.0.tar.gz
-    URL_HASH SHA256=6cd73b3d0bf3daf415b5f9b87ca8817cc2e2b64c275d65f9500250f9fee1677e
+    URL      https://github.com/pybind/pybind11/archive/refs/tags/v2.10.1.tar.gz
+    URL_HASH SHA256=111014b516b625083bef701df7880f78c2243835abdb263065b6b59b960b6bad
 )
 FetchContent_GetProperties(pybind11_src)
 if (NOT pybind11_src_POPULATED)
diff --git a/extensions/script/CMakeLists.txt b/extensions/script/CMakeLists.txt
index bc8145bf6..739cbc02b 100644
--- a/extensions/script/CMakeLists.txt
+++ b/extensions/script/CMakeLists.txt
@@ -32,10 +32,7 @@ add_library(minifi-script-extensions SHARED ${SOURCES})
 target_link_libraries(minifi-script-extensions ${LIBMINIFI} Threads::Threads)
 
 if (NOT DISABLE_PYTHON_SCRIPTING)
-    find_package(PythonLibs 3.5)
-    if (NOT PYTHONLIBS_FOUND)
-        find_package(PythonLibs 3.0 REQUIRED)
-    endif()
+    find_package(PythonLibs 3.6 REQUIRED)
 
     include(Pybind11)
     add_definitions(-DPYTHON_SUPPORT)
diff --git a/extensions/script/tests/CMakeLists.txt b/extensions/script/tests/CMakeLists.txt
index c70f967c7..5ec7ed767 100644
--- a/extensions/script/tests/CMakeLists.txt
+++ b/extensions/script/tests/CMakeLists.txt
@@ -21,11 +21,7 @@ if (NOT DISABLE_PYTHON_SCRIPTING)
     file(GLOB EXECUTESCRIPT_PYTHON_TESTS  "TestExecuteScriptProcessorWithPythonScript.cpp" "PythonScriptEngineTests.cpp" "PythonManifestTests.cpp")
     file(GLOB EXECUTEPYTHONPROCESSOR_UNIT_TESTS  "ExecutePythonProcessorTests.cpp")
     file(GLOB PY_SOURCES  "python/*.cpp")
-    find_package(PythonLibs 3.5)
-    if (NOT PYTHONLIBS_FOUND)
-        find_package(PythonLibs 3.0 REQUIRED)
-    endif()
-    file(COPY "${CMAKE_SOURCE_DIR}/extensions/script/tests/test_python_scripts" DESTINATION "${CMAKE_BINARY_DIR}/bin/")
+    find_package(PythonLibs 3.6 REQUIRED)
 endif()
 
 if (ENABLE_LUA_SCRIPTING)
@@ -49,6 +45,17 @@ FOREACH(testfile ${EXECUTESCRIPT_PYTHON_TESTS})
     createTests("${testfilename}")
     MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1")
     add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+
+    # Copy test resources only once after the first build to be available for all test cases
+    if(EXTENSIONS_TEST_COUNT EQUAL 1)
+        add_custom_command(
+            TARGET "${testfilename}"
+            POST_BUILD
+            COMMAND ${CMAKE_COMMAND} -E copy_directory
+                    "${CMAKE_SOURCE_DIR}/extensions/script/tests/test_python_scripts"
+                    "$<TARGET_FILE_DIR:${testfilename}>/test_python_scripts"
+            )
+    endif()
 ENDFOREACH()
 
 FOREACH(testfile ${EXECUTEPYTHONPROCESSOR_UNIT_TESTS})
@@ -73,6 +80,17 @@ FOREACH(testfile ${EXECUTEPYTHONPROCESSOR_UNIT_TESTS})
     createTests("${testfilename}")
     add_test(NAME "${testfilename}" COMMAND "${testfilename}"  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
     MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1")
+
+    # Copy test resources only once after the first build to be available for all test cases
+    if(EXTENSIONS_TEST_COUNT EQUAL 1)
+        add_custom_command(
+            TARGET "${testfilename}"
+            POST_BUILD
+            COMMAND ${CMAKE_COMMAND} -E copy_directory
+                    "${CMAKE_SOURCE_DIR}/extensions/script/tests/test_python_scripts"
+                    "$<TARGET_FILE_DIR:${testfilename}>/test_python_scripts"
+            )
+    endif()
 ENDFOREACH()
 
 FOREACH(testfile ${EXECUTESCRIPT_LUA_TESTS})
diff --git a/extensions/script/tests/ExecutePythonProcessorTests.cpp b/extensions/script/tests/ExecutePythonProcessorTests.cpp
index 71c030762..3298b48f6 100644
--- a/extensions/script/tests/ExecutePythonProcessorTests.cpp
+++ b/extensions/script/tests/ExecutePythonProcessorTests.cpp
@@ -47,7 +47,7 @@ class ExecutePythonProcessorTestBase {
     std::string path;
     std::string filename;
     getFileNameAndPath(__FILE__, path, filename);
-    SCRIPT_FILES_DIRECTORY = getFullPath(concat_path(path, "test_python_scripts"));
+    SCRIPT_FILES_DIRECTORY = getFullPath(concat_path(minifi::utils::file::FileUtils::get_executable_dir(), "test_python_scripts"));
     reInitialize();
   }
   virtual ~ExecutePythonProcessorTestBase() {
diff --git a/extensions/script/tests/TestExecuteScriptProcessorWithPythonScript.cpp b/extensions/script/tests/TestExecuteScriptProcessorWithPythonScript.cpp
index db68cf192..f527d3d66 100644
--- a/extensions/script/tests/TestExecuteScriptProcessorWithPythonScript.cpp
+++ b/extensions/script/tests/TestExecuteScriptProcessorWithPythonScript.cpp
@@ -358,11 +358,7 @@ TEST_CASE("Python: Test Module Directory property", "[executescriptPythonModuleD
   logTestController.setDebug<TestPlan>();
   logTestController.setDebug<minifi::processors::ExecuteScript>();
 
-  std::string path;
-  std::string filename;
-  minifi::utils::file::getFileNameAndPath(__FILE__, path, filename);
-  const std::string SCRIPT_FILES_DIRECTORY = minifi::utils::file::getFullPath(concat_path(path, "test_python_scripts"));
-
+  const std::string SCRIPT_FILES_DIRECTORY = minifi::utils::file::getFullPath(concat_path(minifi::utils::file::FileUtils::get_executable_dir(), "test_python_scripts"));
   auto getScriptFullPath = [&SCRIPT_FILES_DIRECTORY](const std::string& script_file_name) {
     return concat_path(SCRIPT_FILES_DIRECTORY, script_file_name);
   };
diff --git a/extensions/standard-processors/tests/CMakeLists.txt b/extensions/standard-processors/tests/CMakeLists.txt
index 8fddd890e..db9acd9b1 100644
--- a/extensions/standard-processors/tests/CMakeLists.txt
+++ b/extensions/standard-processors/tests/CMakeLists.txt
@@ -48,14 +48,16 @@ FOREACH(testfile ${PROCESSOR_UNIT_TESTS})
 
     MATH(EXPR PROCESSOR_INT_TEST_COUNT "${PROCESSOR_INT_TEST_COUNT}+1")
 
-    # Copy test resources
-    add_custom_command(
-        TARGET "${testfilename}"
-        POST_BUILD
-        COMMAND ${CMAKE_COMMAND} -E copy_directory
-                "${CMAKE_SOURCE_DIR}/extensions/standard-processors/tests/unit/resources"
-                "$<TARGET_FILE_DIR:${testfilename}>/resources"
-        )
+    # Copy test resources only once after the first build to be available for all test cases
+    if(PROCESSOR_INT_TEST_COUNT EQUAL 1)
+        add_custom_command(
+            TARGET "${testfilename}"
+            POST_BUILD
+            COMMAND ${CMAKE_COMMAND} -E copy_directory
+                    "${CMAKE_SOURCE_DIR}/extensions/standard-processors/tests/unit/resources"
+                    "$<TARGET_FILE_DIR:${testfilename}>/resources"
+            )
+    endif()
 ENDFOREACH()
 
 message("-- Finished building ${PROCESSOR_INT_TEST_COUNT} processor unit test file(s)...")
diff --git a/win_build_vs.bat b/win_build_vs.bat
index 39ef9b62c..467fe7216 100755
--- a/win_build_vs.bat
+++ b/win_build_vs.bat
@@ -107,11 +107,13 @@ pushd %builddir%\
 
 if [%generator%] EQU ["Ninja"] (
     set "buildcmd=ninja && copy bin\minifi.exe minifi_main\"
+    set "build_platform_cmd="
 ) else (
     set "buildcmd=msbuild /m nifi-minifi-cpp.sln /property:Configuration=%cmake_build_type% /property:Platform=%build_platform% && copy bin\%cmake_build_type%\minifi.exe minifi_main\"
+    set "build_platform_cmd=-A %build_platform%"
 )
 echo on
-cmake -G %generator% -A %build_platform% -DINSTALLER_MERGE_MODULES=%installer_merge_modules% -DTEST_CUSTOM_WEL_PROVIDER=%test_custom_wel_provider% -DENABLE_SQL=%build_SQL% -DUSE_REAL_ODBC_TEST_DRIVER=%real_odbc% ^
+cmake -G %generator% %build_platform_cmd% -DINSTALLER_MERGE_MODULES=%installer_merge_modules% -DTEST_CUSTOM_WEL_PROVIDER=%test_custom_wel_provider% -DENABLE_SQL=%build_SQL% -DUSE_REAL_ODBC_TEST_DRIVER=%real_odbc% ^
         -DCMAKE_BUILD_TYPE_INIT=%cmake_build_type% -DCMAKE_BUILD_TYPE=%cmake_build_type% -DWIN32=WIN32 -DENABLE_LIBRDKAFKA=%build_kafka% -DENABLE_JNI=%build_jni% -DOPENSSL_OFF=OFF ^
         -DENABLE_COAP=%build_coap% -DENABLE_AWS=%build_AWS% -DENABLE_PDH=%build_PDH% -DENABLE_AZURE=%build_azure% -DENABLE_SFTP=%build_SFTP% -DENABLE_SPLUNK=%build_SPLUNK% -DENABLE_GCP=%build_GCP% ^
         -DENABLE_NANOFI=%build_nanofi% -DENABLE_OPENCV=%build_opencv% -DENABLE_PROMETHEUS=%build_prometheus% -DENABLE_ELASTICSEARCH=%build_ELASTIC% -DUSE_SHARED_LIBS=OFF -DDISABLE_CONTROLLER=ON  ^