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

commit d0116706ea3daab949c228a4c1b9830e196d0f39
Author: Martin Zink <[email protected]>
AuthorDate: Mon Oct 28 16:52:08 2024 +0100

    MINIFICPP-2482 drop python3.6 support on mac
    
    while we decide on MINIFICPP-2480 vs MINIFICPP-2481 we can safely disable 
python 3.6 support on macos so the CI can run
    
    includes:
    commit 41921b8a634804e41351d85b31b8984429055979
    Author: Martin Zink <[email protected]>
    Date:   Fri Oct 25 14:46:53 2024 +0200
    
        Revert "bump python version"
    
        This reverts commit 2daccca4893fabe08f2ae130593f5b548c9b5201.
    
    Closes #1887
    
    Signed-off-by: Marton Szasz <[email protected]>
---
 extensions/python/CMakeLists.txt        |  6 +++++-
 extensions/python/PythonInterpreter.cpp | 37 +++++++++++++++++----------------
 2 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/extensions/python/CMakeLists.txt b/extensions/python/CMakeLists.txt
index c69d2e51f..2e6694335 100644
--- a/extensions/python/CMakeLists.txt
+++ b/extensions/python/CMakeLists.txt
@@ -30,7 +30,11 @@ add_minifi_library(minifi-python-script-extension SHARED 
${SOURCES})
 target_link_libraries(minifi-python-script-extension PRIVATE ${LIBMINIFI} 
Threads::Threads)
 
 include(GenericPython)
-target_compile_definitions(minifi-python-script-extension PUBLIC 
Py_LIMITED_API=0x03070000)
+if(APPLE)
+    target_compile_definitions(minifi-python-script-extension PUBLIC 
Py_LIMITED_API=0x03090000)
+else()
+    target_compile_definitions(minifi-python-script-extension PUBLIC 
Py_LIMITED_API=0x03060000)
+endif()
 target_compile_definitions(minifi-python-script-extension PUBLIC 
PY_SSIZE_T_CLEAN)
 
 target_sources(minifi-python-script-extension PRIVATE ${PY_SOURCES})
diff --git a/extensions/python/PythonInterpreter.cpp 
b/extensions/python/PythonInterpreter.cpp
index 212aea705..e2ca00f4d 100644
--- a/extensions/python/PythonInterpreter.cpp
+++ b/extensions/python/PythonInterpreter.cpp
@@ -35,15 +35,14 @@ Interpreter* Interpreter::getInterpreter() {
   return &interpreter;
 }
 
-GlobalInterpreterLock::GlobalInterpreterLock()
-    : gil_state_(PyGILState_Ensure()) {
-}
+GlobalInterpreterLock::GlobalInterpreterLock() : 
gil_state_(PyGILState_Ensure()) {}
 
 GlobalInterpreterLock::~GlobalInterpreterLock() {
   PyGILState_Release(gil_state_);
 }
 
 namespace {
+#ifndef __APPLE__
 struct version {
   int major;
   int minor;
@@ -60,6 +59,7 @@ std::optional<version> getPythonVersion() {
     return std::nullopt;
   }
 }
+#endif  // !__APPLE__
 
 // PyEval_InitThreads might be marked deprecated (depending on the version of 
Python.h)
 // Python <= 3.6: This needs to be called manually after Py_Initialize to 
initialize threads (python < 3.6 is unsupported by us)
@@ -68,19 +68,19 @@ std::optional<version> getPythonVersion() {
 // Python >= 3.11: removed
 // This can be removed if we drop the support for Python 3.6
 void initThreads() {
-  using namespace std::literals;
+#if !defined(__APPLE__)
   // early return (skip workaround) above Python 3.6
   if (const auto version = getPythonVersion(); !version || (version->major == 
3 && version->minor > 6) || version->major > 3) {
     return;
   }
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-#elif defined(__GNUC__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-#ifndef WIN32  // dlsym hack, doesn't work on windows
+  #if defined(__clang__)
+    #pragma clang diagnostic push
+    #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+  #elif defined(__GNUC__)
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+  #endif
+  #ifndef WIN32  // dlsym hack, doesn't work on windows
   // dlsym hack: allows us to build with python 3.11+, where these were 
removed (so no header declarations), and run with python 3.6 (e.g. RHEL8)
   // the dlsym hack doesn't work on Windows, we'll drop python 3.6 support 
there
   // lowercase, to avoid name conflicts with the header declaration, in case 
we're using an old enough python to build
@@ -89,12 +89,13 @@ void initThreads() {
   gsl_Assert(pyeval_threads_initialized && pyeval_initthreads && "We're on 
python 3.6, yet we couldn't load PyEval_ThreadsInitialized and/or 
PyEval_InitThreads");
   if (!pyeval_threads_initialized())
     pyeval_initthreads();
-#endif  // !WIN32
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#elif defined(__GNUC__)
-#pragma GCC diagnostic pop
-#endif
+  #endif  // !WIN32
+  #if defined(__clang__)
+    #pragma clang diagnostic pop
+  #elif defined(__GNUC__)
+    #pragma GCC diagnostic pop
+  #endif
+#endif  // !__APPLE__
 }
 
 }  // namespace

Reply via email to