Merge branch 'fix_no_python_build' into 'master'

Fix building without Python

See merge request ngsolve/netgen!657
This commit is contained in:
Hochsteger, Matthias 2024-07-04 17:36:34 +02:00
commit 151c8da887
3 changed files with 6 additions and 3 deletions

View File

@ -7,16 +7,16 @@
#include "array.hpp" #include "array.hpp"
#include "ngcore_api.hpp" #include "ngcore_api.hpp"
#include "pybind11/pytypes.h"
#ifdef NG_PYTHON #ifdef NG_PYTHON
#include "pybind11/pytypes.h"
#include "python_ngcore.hpp" #include "python_ngcore.hpp"
#endif
#define MPI4PY_LIMITED_API 1 #define MPI4PY_LIMITED_API 1
#define MPI4PY_LIMITED_API_SKIP_MESSAGE 1 #define MPI4PY_LIMITED_API_SKIP_MESSAGE 1
#define MPI4PY_LIMITED_API_SKIP_SESSION 1 #define MPI4PY_LIMITED_API_SKIP_SESSION 1
#include "mpi4py_pycapi.h" // mpi4py < 4.0.0 #include "mpi4py_pycapi.h" // mpi4py < 4.0.0
#endif
#ifdef MSMPI_VER #ifdef MSMPI_VER
int MPI_Comm_create_group(MPI_Comm arg0, MPI_Group arg1, int arg2, int MPI_Comm_create_group(MPI_Comm arg0, MPI_Group arg1, int arg2,

View File

@ -6,7 +6,9 @@
#include "ng_mpi.hpp" #include "ng_mpi.hpp"
#include "ngstream.hpp" #include "ngstream.hpp"
#ifdef NG_PYTHON
#include "python_ngcore.hpp" #include "python_ngcore.hpp"
#endif // NG_PYTHON
#include "utils.hpp" #include "utils.hpp"
using std::cerr; using std::cerr;
@ -94,6 +96,7 @@ void InitMPI(std::optional<std::filesystem::path> mpi_lib_path) {
throw e; throw e;
} }
} else { } else {
#ifdef NG_PYTHON
// Use mpi4py to init MPI library and get the vendor name // Use mpi4py to init MPI library and get the vendor name
auto mpi4py = py::module::import("mpi4py.MPI"); auto mpi4py = py::module::import("mpi4py.MPI");
vendor = mpi4py.attr("get_vendor")()[py::int_(0)].cast<std::string>(); vendor = mpi4py.attr("get_vendor")()[py::int_(0)].cast<std::string>();
@ -106,6 +109,7 @@ void InitMPI(std::optional<std::filesystem::path> mpi_lib_path) {
mpi_lib = mpi_lib =
std::make_unique<SharedLibrary>(mpi4py_lib_file, std::nullopt, true); std::make_unique<SharedLibrary>(mpi4py_lib_file, std::nullopt, true);
#endif // WIN32 #endif // WIN32
#endif // NG_PYTHON
} }
std::string ng_lib_name = ""; std::string ng_lib_name = "";

View File

@ -1,4 +1,3 @@
#include "pybind11/pytypes.h"
#ifdef NG_PYTHON #ifdef NG_PYTHON
#include <regex> #include <regex>