72 lines
2.6 KiB
Diff
72 lines
2.6 KiB
Diff
--- src/python.cmake
|
|
+++ src/python.cmake
|
|
@@ -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.12)
|
|
+ find_package(PythonLibs 3.12)
|
|
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()
|
|
--- src/boost.cmake
|
|
+++ src/boost.cmake
|
|
@@ -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 python312)
|
|
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 "python312" "python" boostLibs "${boostLibs}")
|
|
string(REPLACE ";" "," boostLibsComma "${boostLibs}")
|
|
string(REPLACE ";" " --with-" WITH_LIBS "${boostLibs}")
|
|
set(WITH_LIBS "--with-${WITH_LIBS}")
|
|
--- src/plugins/python/PythonInterpreter.cpp
|
|
+++ src/plugins/python/PythonInterpreter.cpp
|
|
@@ -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();
|
|
}
|
|
|
|
}
|