Skip to content

Commit

Permalink
MINIFICPP-2482 drop python3.6 support on mac
Browse files Browse the repository at this point in the history
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 41921b8
Author: Martin Zink <[email protected]>
Date:   Fri Oct 25 14:46:53 2024 +0200

    Revert "bump python version"

    This reverts commit 2daccca.

Closes #1887

Signed-off-by: Marton Szasz <[email protected]>
  • Loading branch information
martinzink authored and szaszm committed Oct 28, 2024
1 parent e62b5bb commit d011670
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
6 changes: 5 additions & 1 deletion extensions/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
37 changes: 19 additions & 18 deletions extensions/python/PythonInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d011670

Please sign in to comment.