| Index: src/python.cmake |
| =================================================================== |
| --- src/python.cmake (date 1570594392000) |
| +++ src/python.cmake (date 1570594473610) |
| @@ -4,8 +4,8 @@ |
| |
| if(VERA_USE_SYSTEM_PYTHON) |
| set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) |
| - find_package(PythonInterp 2.0) |
| - find_package(PythonLibs 2.0) |
| + find_package(PythonInterp 3.8) |
| + find_package(PythonLibs 3.8) |
| if(WIN32 AND NOT PYTHONLIBS_FOUND) |
| message(FATAL_ERROR "Could NOT find Python. Turn VERA_USE_SYSTEM_PYTHON to OFF to build it with vera++.") |
| endif() |
| Index: src/boost.cmake |
| =================================================================== |
| --- src/boost.cmake (date 1570594392000) |
| +++ src/boost.cmake (date 1570594473565) |
| @@ -8,7 +8,16 @@ |
| |
| set(boostLibs filesystem system program_options regex wave) |
| if(VERA_PYTHON) |
| - list(APPEND boostLibs python) |
| + # Note that Boost Python components require a Python version |
| + # suffix (Boost 1.67 and later), e.g. python36 or python27 for |
| + # the versions built against Python 3.6 and 2.7, respectively. |
| + # This also applies to additional components using Python |
| + # including mpi_python and numpy. Earlier Boost releases may use |
| + # distribution-specific suffixes such as 2, 3 or 2.7. These may also |
| + # be used as suffixes, but note that they are not portable. |
| + # |
| + # from https://cmake.org/cmake/help/latest/module/FindBoost.html |
| + list(APPEND boostLibs python38) |
| endif() |
| |
| if(VERA_USE_SYSTEM_BOOST) |
| @@ -35,6 +44,7 @@ |
| set(SOURCEFORGE downloads.sourceforge.net CACHE STRING |
| "Sourceforge host used to download external projects. Use it to force a specific mirror.") |
| mark_as_advanced(SOURCEFORGE) |
| + string(REPLACE "python38" "python" boostLibs "${boostLibs}") |
| string(REPLACE ";" "," boostLibsComma "${boostLibs}") |
| string(REPLACE ";" " --with-" WITH_LIBS "${boostLibs}") |
| set(WITH_LIBS "--with-${WITH_LIBS}") |
| --- src/plugins/python/PythonInterpreter.cpp 2015-01-22 13:28:22.000000000 +0300 |
| +++ src/plugins/python/PythonInterpreter.cpp.new 2019-11-04 00:28:29.895059200 +0300 |
| @@ -133,8 +133,17 @@ |
| { |
| try |
| { |
| - PyImport_AppendInittab("vera", initvera); |
| - Py_Initialize(); |
| + // Note: Boost Python (as of ver 1.69) does not support Py_Finalize(). |
| + // Thus, a previous call to this method may have already |
| + // initialized python. |
| + // See Boost Python documentation for more information: |
| + // https://www.boost.org/doc/libs/1_69_0/libs/python/doc/html/ |
| + // tutorial/tutorial/embedding.html |
| + if (not Py_IsInitialized()) |
| + { |
| + PyImport_AppendInittab("vera", PyInit_vera); |
| + Py_Initialize(); |
| + } |
| |
| py::object main_module = py::import("__main__"); |
| py::object main_namespace = main_module.attr("__dict__"); |
| @@ -158,7 +167,6 @@ |
| py::str formatted = py::str("").join(formatted_list).strip(); |
| throw std::runtime_error(py::extract<std::string>(formatted)); |
| } |
| - Py_Finalize(); |
| } |
| |
| } |