From a617e4cfedbbf46b185377fe9e94d3076034e032 Mon Sep 17 00:00:00 2001
From: dedner <a.s.dedner@warwick.ac.uk>
Date: Mon, 30 Mar 2020 14:10:33 +0100
Subject: [PATCH] use correct version number for python package add numpy,
 mpi4py to required packages

remove some python 2 related code and fixed up some other issues
pointed out by Timo
deprecated old compatibility file - move Python 3 code to dune.common.utility
---
 bin/find_modules.py                       |  2 -
 bin/setup-dunepy.py                       |  2 -
 cmake/modules/DuneAddPybind11Module.cmake |  2 -
 cmake/modules/DuneMacros.cmake            |  2 +-
 cmake/modules/DuneSphinxDoc.cmake         |  4 -
 dune/python/common/dynmatrix.hh           |  2 +-
 dune/python/common/dynvector.hh           |  2 +-
 dune/python/common/getdimension.hh        |  3 -
 dune/python/common/iteratorrange.hh       | 98 -----------------------
 dune/python/common/logger.hh              |  4 -
 dune/python/common/typeregistry.hh        |  4 -
 dune/python/common/vector.hh              |  4 +-
 dune/python/test/CMakeLists.txt           | 10 ++-
 python/CMakeLists.txt                     |  4 +-
 python/dune/common/CMakeLists.txt         |  5 +-
 python/dune/common/_common.cc             | 11 ---
 python/dune/common/checkconfiguration.py  |  6 +-
 python/dune/common/compatibility.py       | 48 ++---------
 python/dune/common/module.py              |  4 +-
 python/dune/common/pickle.py              | 11 +--
 python/dune/common/project.py             |  2 -
 python/dune/common/utility.py             | 17 ++++
 python/dune/create.py                     | 33 ++------
 python/dune/generator/algorithm.py        |  4 +-
 python/dune/generator/builder.py          |  4 +-
 python/dune/generator/exceptions.py       |  2 -
 python/dune/generator/generator.py        | 12 ---
 python/dune/generator/importclass.py      |  4 +-
 python/setup.py.in                        |  4 +-
 29 files changed, 64 insertions(+), 246 deletions(-)
 delete mode 100644 dune/python/common/iteratorrange.hh
 create mode 100644 python/dune/common/utility.py

diff --git a/bin/find_modules.py b/bin/find_modules.py
index 0b00c369c..f8fa618dd 100644
--- a/bin/find_modules.py
+++ b/bin/find_modules.py
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
 try:
     from dune.common.module import resolve_dependencies, resolve_order, select_modules
 
diff --git a/bin/setup-dunepy.py b/bin/setup-dunepy.py
index 5aa8654a0..52d7b4b3a 100755
--- a/bin/setup-dunepy.py
+++ b/bin/setup-dunepy.py
@@ -1,6 +1,4 @@
 #!/usr/bin/env python
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 import getopt
 import os
 import shlex
diff --git a/cmake/modules/DuneAddPybind11Module.cmake b/cmake/modules/DuneAddPybind11Module.cmake
index 98b4f850a..7f7180776 100644
--- a/cmake/modules/DuneAddPybind11Module.cmake
+++ b/cmake/modules/DuneAddPybind11Module.cmake
@@ -72,8 +72,6 @@ function(dune_add_pybind11_module)
 
   add_library(${PYBIND11_MODULE_NAME} SHARED ${PYBIND11_MODULE_SOURCES})
   set_target_properties(${PYBIND11_MODULE_NAME} PROPERTIES PREFIX "")
-  #set_target_properties(${PYBIND11_MODULE_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
-  #set_target_properties(${PYBIND11_MODULE_NAME} PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)
   target_compile_definitions(${PYBIND11_MODULE_NAME} PRIVATE ${PYBIND11_MODULE_COMPILE_DEFINITIONS})
   dune_target_enable_all_packages(${PYBIND11_MODULE_NAME})
 
diff --git a/cmake/modules/DuneMacros.cmake b/cmake/modules/DuneMacros.cmake
index 86bf35156..d3250019e 100644
--- a/cmake/modules/DuneMacros.cmake
+++ b/cmake/modules/DuneMacros.cmake
@@ -421,7 +421,7 @@ macro(dune_process_dependency_leafs modules versions is_required next_level_deps
     math(EXPR length "${mlength}-1")
     foreach(i RANGE 0 ${length})
       list(GET mmodules ${i} _mod)
-        list(GET mversions ${i} _ver)
+      list(GET mversions ${i} _ver)
       find_dune_package(${_mod} ${is_required} VERSION "${_ver}")
       set(${_mod}_SEARCHED ON)
       if(NOT "${is_required}" STREQUAL "")
diff --git a/cmake/modules/DuneSphinxDoc.cmake b/cmake/modules/DuneSphinxDoc.cmake
index eb8dd1af2..2be81667c 100644
--- a/cmake/modules/DuneSphinxDoc.cmake
+++ b/cmake/modules/DuneSphinxDoc.cmake
@@ -29,10 +29,6 @@ function(dune_sphinx_doc)
     configure_file(${SPHINX_DOC_CONF}.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py)
   elseif(EXISTS ${CMAKE_CURRENT_SOUREC_DIR}/${SPHINX_DOC_CONF})
     configure_file(${SPHINX_DOC_CONF} ${CMAKE_CURRENT_BINARY_DIR}/conf.py COPYONLY)
-    # elseif(EXISTS ${CMAKE_SOURCE_DIR}/${SPHINX_DOC_CONF}.in)
-    #  configure_file(${CMAKE_SOURCE_DIR}/${SPHINX_DOC_CONF}.in ${CMAKE_BINARY_DIR}/conf.py)
-    # elseif(EXISTS ${CMAKE_SOUREC_DIR}/${SPHINX_DOC_CONF})
-    #  configure_file(${CMAKE_SOURCE_DIR}/${SPHINX_DOC_CONF} ${CMAKE_BINARY_DIR}/conf.py COPYONLY)
   else()
     message(SEND_ERROR "Sphinx configuration '${SPHINX_DOC_CONF}' not found.")
   endif()
diff --git a/dune/python/common/dynmatrix.hh b/dune/python/common/dynmatrix.hh
index c2f6e27ab..0bc7e7769 100644
--- a/dune/python/common/dynmatrix.hh
+++ b/dune/python/common/dynmatrix.hh
@@ -50,7 +50,7 @@ namespace Dune
 
       cls.def("__repr__",
           [] (const DM& m) {
-            std::string repr = "DUNE DynamicMatrix:\n(";
+            std::string repr = "Dune::DynamicMatrix:\n(";
 
             for(unsigned int r = 0; r < m.rows(); r++)
             {
diff --git a/dune/python/common/dynvector.hh b/dune/python/common/dynvector.hh
index 86dbd4fbe..2bd837be2 100644
--- a/dune/python/common/dynvector.hh
+++ b/dune/python/common/dynvector.hh
@@ -44,7 +44,7 @@ namespace Dune
 
       cls.def("__repr__",
           [] (const DV &v) {
-            std::string repr = "DUNE DynamicVector: (";
+            std::string repr = "Dune::DynamicVector: (";
 
             for (std::size_t i = 0; i < v.size(); ++i)
               repr += (i > 0 ? ", " : "") + std::to_string(v[i]);
diff --git a/dune/python/common/getdimension.hh b/dune/python/common/getdimension.hh
index 050d14a21..766e2bd57 100644
--- a/dune/python/common/getdimension.hh
+++ b/dune/python/common/getdimension.hh
@@ -12,9 +12,6 @@ struct GetDimension;
 template< class T >
 struct GetDimension< T, std::enable_if_t<std::is_arithmetic<T>::value>>
    : public std::integral_constant< int, 1 > {};
-// template<>
-// struct GetDimension<double>
-//    : public std::integral_constant< int, 1 > {};
 template< class FT, int dim >
 struct GetDimension<Dune::FieldVector<FT,dim>>
    : public std::integral_constant< int, dim > {};
diff --git a/dune/python/common/iteratorrange.hh b/dune/python/common/iteratorrange.hh
deleted file mode 100644
index e122d7a2c..000000000
--- a/dune/python/common/iteratorrange.hh
+++ /dev/null
@@ -1,98 +0,0 @@
-#ifndef DUNE_PYTHON_COMMON_ITERATORRANGE_HH
-#define DUNE_PYTHON_COMMON_ITERATORRANGE_HH
-
-#include <dune/python/pybind11/pybind11.h>
-
-namespace Dune {
-namespace Python {
-
-/**
- * Simple range between a begin and an end iterator, with optional length.
- *
- * This class is similar to dune-common's IteratorRange, but allows
- * for different types for begin and end, and includes an optional length
- * for Python's `len(...)` operator.
- *
- * Instances of this type should be registered with
- * \seealso registerIteratorRange
- *
- * \tparam BeginIt type of begin iterator
- * \tparam EndIt   type of end iterator
- */
-template<typename BeginIt, typename EndIt = BeginIt>
-class PyIteratorRange
-{
-public:
-  using BeginIterator = BeginIt;
-  using EndIterator = EndIt;
-
-  /**
-   * construct a new iterator range
-   */
-  PyIteratorRange(const BeginIterator& begin, const EndIterator& end, std::size_t length = 0)
-    : begin_(begin)
-    , end_(end)
-    , length_(length)
-    {}
-
-  /**
-   * returns begin iterator
-   */
-  const BeginIterator& begin() const
-    { return begin_; }
-
-  /**
-   * returns end iterator
-   */
-  const EndIterator& end() const
-    { return end_; }
-
-  /**
-   * returns distance between begin and end iterator.
-   * Used to implement Python's `__len__` protocol.
-   */
-  std::size_t length() const
-    { return length_; }
-
-private:
-  BeginIterator begin_;
-  EndIterator end_;
-  std::size_t length_;
-};
-
-/**
- * register a new iterator range Python type
- *
- * \tparam Range    type of iterator range; should be an instance of \ref PyIteratorRange
- *
- * \param scope     Python scope for the new class
- * \param name      Python name for the new class
- * \param hasLength indicates whether Python type should implement `__len__` protocol or not
- */
-template<typename Range>
-auto registerIteratorRange(pybind11::handle scope, const char* name, bool hasLength = false)
-{
-  using BeginIterator = typename Range::BeginIterator;
-  using EndIterator = typename Range::EndIterator;
-
-  // TODO use insertClass
-  auto cls = pybind11::class_<Range>(scope, name)
-    .def("__iter__",
-         [](const Range& range) { return pybind11::make_iterator(range.begin(), range.end()); },
-         pybind11::keep_alive<0, 1>());
-
-  if (hasLength) {
-    cls.def(pybind11::init<const BeginIterator&, const EndIterator&, std::size_t>());
-    cls.def("__len__", &Range::length);
-  }
-  else {
-    cls.def(pybind11::init<const BeginIterator&, const EndIterator&>());
-  }
-
-  return cls;
-}
-
-} /* namespace Python */
-} /* namespace Dune */
-
-#endif
diff --git a/dune/python/common/logger.hh b/dune/python/common/logger.hh
index b7fe1f3c3..c3e5b4926 100644
--- a/dune/python/common/logger.hh
+++ b/dune/python/common/logger.hh
@@ -67,11 +67,7 @@ namespace Dune
       template< class... Args >
       void log ( int level, const std::string &msg, Args &&... args ) const
       {
-#if PY_MAJOR_VERSION < 3
-        pybind11::object pyLevel = pybind11::reinterpret_steal< pybind11::object >( PyInt_FromLong( level ) );
-#else // #if PY_MAJOR_VERSION < 3
         pybind11::object pyLevel = pybind11::int_( level );
-#endif // #else // #if PY_MAJOR_VERSION < 3
         logger_.attr( "log" )( pyLevel, msg, *pybind11::make_tuple( std::forward< Args >( args )... ) );
       }
 
diff --git a/dune/python/common/typeregistry.hh b/dune/python/common/typeregistry.hh
index 263de015d..1fa2afa96 100644
--- a/dune/python/common/typeregistry.hh
+++ b/dune/python/common/typeregistry.hh
@@ -375,9 +375,6 @@ namespace Dune
       std::vector<std::string> includes = typeName.includes();
       includes.insert(includes.end(), inc.begin(), inc.end());
       detail::insertIntoTypeRegistry<DuneType>(typeName.name(),"",includes);
-      // if (!entry.second)
-      //   throw std::invalid_argument( (std::string("adding a class (") +
-      //         typeid(DuneType).name() + ") twice to the type registry").c_str() );
     }
 
 
@@ -435,7 +432,6 @@ namespace Dune
 
         cls.def_property_readonly_static( "_typeName", [ entry ] ( pybind11::object ) { return entry.first->second.name; } );
         cls.def_property_readonly_static( "_includes", [ entry ] ( pybind11::object ) { return entry.first->second.includes; } );
-        // cls.def( "__str__", [ entry ] ( pybind11::object ) { return entry.first->second.name; } );
 
         return std::make_pair( cls, true );
       }
diff --git a/dune/python/common/vector.hh b/dune/python/common/vector.hh
index 59d2ad0f5..afb0cdba4 100644
--- a/dune/python/common/vector.hh
+++ b/dune/python/common/vector.hh
@@ -164,7 +164,7 @@ namespace Dune
 
     template< std::size_t... i, class T, class... X >
     inline static constexpr auto extendArray ( std::index_sequence< i... >, const std::array< T, sizeof...( i ) > &array, X &&... x )
-      -> std::enable_if_t< Std::conjunction< std::is_convertible< X, T >... >::value, std::array< T, sizeof...( i )+sizeof...( X ) > >
+      -> std::enable_if_t< std::conjunction< std::is_convertible< X, T >... >::value, std::array< T, sizeof...( i )+sizeof...( X ) > >
     {
       return {{ array[ i ]..., std::forward< X >( x )... }};
     }
@@ -283,7 +283,7 @@ namespace Dune
       return vectorize( std::forward< F >( f ), static_cast< pybind11::detail::function_signature_t< F > * >( nullptr ), std::move( xArray ) );
     }
 
-  } // namespace Corepy
+  } // namespace Python
 
 } // namespace Dune
 
diff --git a/dune/python/test/CMakeLists.txt b/dune/python/test/CMakeLists.txt
index 9756e60c3..b31e4bdb5 100644
--- a/dune/python/test/CMakeLists.txt
+++ b/dune/python/test/CMakeLists.txt
@@ -1,6 +1,12 @@
-# dune_symlink_to_source_files(FILES myclass.hh test_class_export.py)
-
 dune_python_add_test(NAME pythontests
                      COMMAND ${PYTHON_EXECUTABLE} pythontests.py
                      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                      LABELS quick)
+
+dune_add_test(SOURCES test_embed1.cc
+              LINK_LIBRARIES ${DUNE_LIBS} ${PYTHON_LIBRARIES}
+              LABELS quick
+              )
+
+add_executable(test_embed2 EXCLUDE_FROM_ALL test_embed2.cc)
+target_link_libraries(test_embed2 ${DUNE_LIBS} ${PYTHON_LIBRARIES})
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index 69d0db406..bf6f08c04 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -1,5 +1,3 @@
 add_subdirectory(dune)
 
-if((${DUNE_COMMON_VERSION} VERSION_LESS 2.6))
-  configure_file(setup.py.in setup.py)
-endif()
+configure_file(setup.py.in setup.py)
diff --git a/python/dune/common/CMakeLists.txt b/python/dune/common/CMakeLists.txt
index 1f815511c..de0dc7611 100644
--- a/python/dune/common/CMakeLists.txt
+++ b/python/dune/common/CMakeLists.txt
@@ -1,12 +1,13 @@
 add_python_targets(common
   __init__
   compatibility
-  deprecated
+  deprecated            # deprecated 2.8
   module
   checkconfiguration
   hashit
-  pickle
+  pickle                # deprecated 2.8
   project
+  utility
 )
 dune_add_pybind11_module(NAME _common)
 set_property(TARGET _common PROPERTY LINK_LIBRARIES dunecommon)
diff --git a/python/dune/common/_common.cc b/python/dune/common/_common.cc
index c8ecb6d47..00af8beb3 100644
--- a/python/dune/common/_common.cc
+++ b/python/dune/common/_common.cc
@@ -20,17 +20,6 @@ PYBIND11_MODULE( _common, module )
   Dune::Python::addToTypeRegistry<int>(Dune::Python::GenerateTypeName("int"));
   Dune::Python::addToTypeRegistry<std::size_t>(Dune::Python::GenerateTypeName("std::size_t"));
 
-  // to reduce compile during dune-common build don't preregister any FV/FM classes
-  /*
-  Dune::Python::registerFieldVector<double>(module, std::make_integer_sequence<int, 3>());
-
-  Dune::Hybrid::forEach( std::make_integer_sequence< int, 3 >(), [ module ] ( auto rows ) {
-      Dune::Hybrid::forEach( std::make_integer_sequence< int, 3 >(), [ module ] ( auto cols ) {
-        Dune::Python::registerFieldMatrix< double, decltype(rows)::value, cols >( module );
-      } );
-    } );
-    */
-
   Dune::Python::registerDynamicVector<double>(module);
   Dune::Python::registerDynamicMatrix<double>(module);
 
diff --git a/python/dune/common/checkconfiguration.py b/python/dune/common/checkconfiguration.py
index ee3e0a0df..21af19883 100644
--- a/python/dune/common/checkconfiguration.py
+++ b/python/dune/common/checkconfiguration.py
@@ -1,5 +1,3 @@
-from __future__ import print_function, unicode_literals
-
 import logging
 import os
 import re
@@ -7,7 +5,7 @@ import subprocess
 
 import dune.common.module
 
-from dune.common.compatibility import buffer_to_str
+from dune.common.utility import buffer_to_str
 from dune.generator import builder, ConfigurationError
 
 logger = logging.getLogger(__name__)
@@ -25,10 +23,8 @@ def assertHave(identifier):
         matches = [match for match in [re.match('^[ ]*#define[ ]+' + identifier.strip() + '[ ]+ENABLE', line) for line in open(config)] if match is not None]
 
     if not matches:
-        # logger.info("checkconfiguration.have(" + identifier + ") failed - identifier not defined in " + config)
         raise ConfigurationError(identifier + " is not set in dune-py's config.h")
     elif matches.__len__() > 1:
-        # logger.info("checkconfiguration.have(" + identifier + ") failed - multiple definitions in " + config)
         raise ConfigurationError(identifier + " found multiple times in dune-py's config.h")
 
 def preprocessorAssert(tests):
diff --git a/python/dune/common/compatibility.py b/python/dune/common/compatibility.py
index 726a7e71f..8fa1bee90 100644
--- a/python/dune/common/compatibility.py
+++ b/python/dune/common/compatibility.py
@@ -1,40 +1,8 @@
-import importlib
-import sys
-
-if sys.version_info.major == 2:
-    def buffer_to_str(b):
-        return b
-else:
-    def buffer_to_str(b):
-        return b.decode('utf-8')
-
-
-if sys.version_info.major == 2:
-    def isString(s):
-        return isinstance(s, (str, unicode))
-
-    def isInteger(i):
-        return isinstance(i, (int, long))
-else:
-    def isString(s):
-        return isinstance(s, str)
-
-    def isInteger(i):
-        return isinstance(i, int)
-
-
-if sys.version_info.major == 2:
-    def reload_module(module):
-        reload(module)
-        return module
-else:
-    reload_module = importlib.reload
-
-if sys.version_info.major == 2:
-    from inspect import getargspec
-    def getNumberOfParameters(func):
-        return len( getargspec(func).args )
-else:
-    from inspect import signature
-    def getNumberOfParameters(func):
-        return len( signature(func).parameters )
+print("""WARNING:
+Importing deprecated `dune.common.compatibility'. The Python 2.7 versions
+of the functions defined here were removed and the Python 3+ versions moved
+so use
+    import dune.common.utility
+instead
+""")
+from .utility import *
diff --git a/python/dune/common/module.py b/python/dune/common/module.py
index b799db285..ddf2a4da2 100644
--- a/python/dune/common/module.py
+++ b/python/dune/common/module.py
@@ -13,10 +13,10 @@ import sys
 from os.path import expanduser
 
 if __name__ == "dune.common.module":
-    from dune.common.compatibility import buffer_to_str
+    from dune.common.utility import buffer_to_str
     from dune.common import project
 else:
-    from compatibility import buffer_to_str
+    from utility import buffer_to_str
     import project
 
 logger = logging.getLogger(__name__)
diff --git a/python/dune/common/pickle.py b/python/dune/common/pickle.py
index 77ade5200..aacd7620a 100644
--- a/python/dune/common/pickle.py
+++ b/python/dune/common/pickle.py
@@ -1,6 +1,7 @@
-import sys
+print("""WARNING:
+Importing deprecated `dune.common.pickle' use
+    import pickle
+instead
+""")
 
-if sys.version_info.major == 2:
-    from cPickle import *
-else:
-    from pickle import *
+from pickle import *
diff --git a/python/dune/common/project.py b/python/dune/common/project.py
index 4b9889cca..ba4806c67 100644
--- a/python/dune/common/project.py
+++ b/python/dune/common/project.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 import os
 
 def write_cmake_file(dir, content=None, subdirs=None, install=None):
diff --git a/python/dune/common/utility.py b/python/dune/common/utility.py
new file mode 100644
index 000000000..b5a7b40b4
--- /dev/null
+++ b/python/dune/common/utility.py
@@ -0,0 +1,17 @@
+import importlib
+import sys
+from inspect import signature
+
+def buffer_to_str(b):
+    return b.decode('utf-8')
+
+def isString(s):
+    return isinstance(s, str)
+
+def isInteger(i):
+    return isinstance(i, int)
+
+reload_module = importlib.reload
+
+def getNumberOfParameters(func):
+    return len( signature(func).parameters )
diff --git a/python/dune/create.py b/python/dune/create.py
index 725fecdfc..29e9e8bf4 100644
--- a/python/dune/create.py
+++ b/python/dune/create.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 import importlib
 import sys
 import pkgutil
@@ -82,7 +80,6 @@ def get(category=None,entry=None):
             colLength[0] = max(colLength[0],len(entries[-1][0]))
             colLength[1] = max(colLength[1],len(entries[-1][1]))
             colLength[2] = max(colLength[2],len(entries[-1][2]))
-            # print(k,"\t function'"+e[0].__name__+"' from '"+'.'.join(m for m in n)+"'")
         entries.sort()
         print("entry".ljust(colLength[0]),
               "function".ljust(colLength[1]),
@@ -113,27 +110,17 @@ def signatureDict(func):
     # all non var argument of the function as key and containing a either
     # Empty or the default argument provided by the function signature
 
-    if sys.version_info.major == 2:
-        sig = inspect.getargspec(func)
-        names=list(sig.args)
-        defaults=list(sig.defaults) if sig.defaults else list()
-        for i in range(len(names)-len(defaults)):
-            defaults.insert(0,Empty)
-        ret = dict(zip(names, defaults))
-    else:
-        ret = {}
-        sig = inspect.signature(func)
-        for p,v in sig.parameters.items():
-            # we only extract positional or keyword argument (i.e. not  *args,**kwargs)
-            if v.kind == v.POSITIONAL_OR_KEYWORD:
-                name = v.name
-                default = v.default if not v.default is v.empty else Empty
-                ret.update({name:default})
+    ret = {}
+    sig = inspect.signature(func)
+    for p,v in sig.parameters.items():
+        # we only extract positional or keyword argument (i.e. not  *args,**kwargs)
+        if v.kind == v.POSITIONAL_OR_KEYWORD:
+            name = v.name
+            default = v.default if not v.default is v.empty else Empty
+            ret.update({name:default})
     return ret
 
 def _creatorCall(create, usedKeys, *args, **kwargs):
-    # print("*********************************************")
-    # print("creatorCall:",key)
     # get signature of create function to call
     signature = signatureDict(create)
     # check if any of the parameter names correspond to some creator -
@@ -147,7 +134,6 @@ def _creatorCall(create, usedKeys, *args, **kwargs):
         if name=='view' and not name in kwargs and 'grid' in kwargs:
             kwargs.update({"view":kwargs["grid"]})
             usedKeys.update(["grid"])
-        # print("checking parameter: ",name,end=" -\n ")
         creator = globals().get(name)
         if creator: # a creator for this parameter name exists
             assert signature[name] == Empty, "argument in create method corresponding to creatibles should not have default values"
@@ -170,8 +156,6 @@ def _creatorCall(create, usedKeys, *args, **kwargs):
             else:
                 signature[name] = argument
                 usedKeys.update([name])
-    # print(signature)
-    # print("*********************************************")
     return create(**signature)
 
 def creatorCall(self, key, *args, **kwargs):
@@ -193,7 +177,6 @@ def creatorCall(self, key, *args, **kwargs):
             kwargs.update({'view':kwargs['grid']})
             usedKeys.update(['grid'])
         instance = _creatorCall(create,usedKeys,*args,**kwargs)
-        # print(set(kwargs), usedKeys)
         assert set(kwargs) == usedKeys, "some provided named parameters where not used"
         return instance
 
diff --git a/python/dune/generator/algorithm.py b/python/dune/generator/algorithm.py
index bbdf343c4..a2dd20c84 100644
--- a/python/dune/generator/algorithm.py
+++ b/python/dune/generator/algorithm.py
@@ -1,10 +1,8 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 import numpy
 
 from dune.common.hashit import hashIt
 from . import builder
-from dune.common.compatibility import isString
+from dune.common.utility import isString
 
 def cppType(arg):
     try:
diff --git a/python/dune/generator/builder.py b/python/dune/generator/builder.py
index 002f65f22..541013b14 100644
--- a/python/dune/generator/builder.py
+++ b/python/dune/generator/builder.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 import importlib
 import logging
 import shlex
@@ -52,7 +50,7 @@ except ModuleNotFoundError:
             return exc_type == None
 
 from dune.common import comm
-from dune.common.compatibility import buffer_to_str, isString, reload_module
+from dune.common.utility import buffer_to_str, isString, reload_module
 from dune.generator.exceptions import CompileError, ConfigurationError
 import dune.common.module
 
diff --git a/python/dune/generator/exceptions.py b/python/dune/generator/exceptions.py
index b65a44e67..690e57057 100644
--- a/python/dune/generator/exceptions.py
+++ b/python/dune/generator/exceptions.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 class CompileError(Exception):
     '''raise this when there's a problem compiling an extension module'''
     def __init__(self, error):
diff --git a/python/dune/generator/generator.py b/python/dune/generator/generator.py
index f0529c42c..a7dbcea9e 100644
--- a/python/dune/generator/generator.py
+++ b/python/dune/generator/generator.py
@@ -6,8 +6,6 @@
     provided by python dictonaries stored in files.
 """
 
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 import logging
 
 from . import builder
@@ -155,13 +153,3 @@ def simpleGenerator(inc, baseType, namespace, pythonname=None, filename=None):
         moduleName = namespace + "_" + baseType + "_" + hashIt(typeName)
         return generator.load(includes, typeName, moduleName, *args)
     return load
-
-from . import Method as Method_
-from . import Constructor as Constructor_
-from dune.deprecate import deprecated
-@deprecated("import from dune.generator directly")
-class Method(Method_):
-    pass
-@deprecated("import from dune.generator directly")
-class Constructor(Constructor_):
-    pass
diff --git a/python/dune/generator/importclass.py b/python/dune/generator/importclass.py
index 45bfe01ca..d6cda077f 100644
--- a/python/dune/generator/importclass.py
+++ b/python/dune/generator/importclass.py
@@ -1,10 +1,8 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 import os
 
 from dune.common.hashit import hashIt
 from . import builder
-from dune.common.compatibility import isString
+from dune.common.utility import isString
 from dune.generator.algorithm import cppType
 
 def load(className, includeFiles, *args):
diff --git a/python/setup.py.in b/python/setup.py.in
index 1ae9da931..e52ec0c26 100644
--- a/python/setup.py.in
+++ b/python/setup.py.in
@@ -3,10 +3,10 @@ from setuptools import setup, find_packages
 setup(name="dune.common",
     namespace_packages=['dune'],
     description="Python lib for dune",
-    version="${DUNE_PYTHON_VERSION}",
+    version="${DUNE_COMMON_VERSION}",
     author="Andreas Dedner and Martin Nolte",
     packages = find_packages(),
     zip_safe = 0,
     package_data = {'': ['*.so']},
-    install_requires = ['portalocker']
+    install_requires = ['portalocker','mpi4py','numpy']
   )
-- 
GitLab