Skip to content

WIP remove pybind11 sources from dune-common

Andreas Dedner requested to merge feature/nopymodulebuildincore into master

restructure python bindings so that no module is compiled during the build of dune-common:

  • _common.so and _typeregistry.so are build within dune-py during import of dune.common/dune.typeregistry (if required)
  • no additional build time required with activated python bindings - so default can be TRUE
  • pybind11 is not needed during build of dune-common so we can simply add pybind11 as
    required package to setup.py and have it pip installed during the installation of the dune bindings
  • we can then remove the pybind11 sources from dune-commom

Requires additional changes in all downstream modules with python bindings since

   #include <dune/python/pybind11/...>

needs replacing with

  #include <pybind11/...>

and any module now build during the configuration of a module (i.e. _grid) needs to add something like (should be simplified in some utility function)

try:
    from dune.generated._grid import *
except ImportError:
    from dune.utility import buildAndImportModule
    buildAndImportModule(__file__,"_grid",globals())

to __init__.py instead of

from ._grid import *

To Do

  • The embedded tests are not yet working because the include path for pybind11 is missing but we should now be able to use the cmake functions available in pybind11
  • everything else involving dune.common seems to be working but more tests needed
  • Question: at the moment DuneAddPybind11Module is still in dune-common but could be generated while setting up dune-py (but perhaps its useful outside of dune-py?)

Changes

  • removed dune/python/pybind11
  • made sure nothing needed to build dune-py involved importing anything from dune.common since _common.so needs to be build as soon as dune.common is imported. Thus lead to a lot of changes in the commit that don't really do much:
    • moved dune module build code from dune.common to dune.project
    • needed some changes also in dune.generator and in the dune-common/bin scripts
  • all C++ header files for the bindings needed include statements changed
Edited by Simon Praetorius

Merge request reports

Loading