Commit f997c774 authored by Martin Nolte's avatar Martin Nolte
Browse files

only try to import mpi4py automatically, if MPI was found by DUNE

parent bdd8cc92
......@@ -15,4 +15,4 @@ function(add_python_target file)
endfunction()
include(PythonDuneModule)
declare_python_dune_module(MODULE dune-corepy INIT "try:" " from mpi4py import MPI" "except:" " pass" "import dune.common" "from dune.common import comm")
declare_python_dune_module(MODULE dune-corepy INIT "import dune.common" "from dune.common import comm")
......@@ -15,6 +15,9 @@ function(declare_python_dune_module)
if(${ARG_MODULE} STREQUAL ${CMAKE_PROJECT_NAME})
get_property(INIT_CODE GLOBAL PROPERTY PYTHON_DUNE_INIT_CODE)
if(MPI_FOUND)
set(INIT_CODE "try:\n from mpi4py import MPI\nexcept:\n pass\n${INIT_CODE}")
endif()
file(WRITE ${CMAKE_BINARY_DIR}/python/dune/__init__.py "from pkg_resources import declare_namespace\ndeclare_namespace(__name__)\n${INIT_CODE}")
endif()
endfunction()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment