On Fri, Aug 1, 2014 at 1:35 PM, Martin Sandve Alnæs <[email protected]> wrote:
> It doesn't make sense that _swig_property() triggers > Parameters.__setitem__ so something fishy is going on. > > If we disable this line in common.py the error disappears: > #parameters = _common.get_global_parameters() > Probably not a solution, see below. > Then we get to this error instead: > > > /home/martinal/opt/fenics/dorsal-unstable-py3/lib/python3.4/site-packages/dolfin/cpp/la.py > in <module>() > 109 return _la.has_petsc4py() > 110 has_petsc4py = _la.has_petsc4py > --> 111 import common > 112 class LinearAlgebraObject(common.Variable): > 113 """ > > ImportError: No module named 'common' > > > This is because relative imports are gone from python 3, we need 'import > dolfin.cpp.common'. However I cannot find any 'import common' in any .py or > .i files in dolfin. Where does this come from? > These are added by swig from the import statements in the generated module.i files: %import(module="common") "dolfin/parameter/Parameter.h" Here we state that types from Parameters.h should be imported and that the types resides in the local common module. We can change that line to: %import(module="dolfin.cpp.common") "dolfin/parameter/Parameter.h" These lines are generated at line 85 in dolfin_utils/cppparser/utils.py. Try add "dolfin.cpp." before the %s (or the py3 equivalent format string) at that line. The reason the typemaps does not kick in for the globalparameter line above is probably because the import does not work. Johan > > Martin > > > > > > On 1 August 2014 12:18, Johan Hake <[email protected]> wrote: > >> It looks like line 2473 triggers a call to __setitem__, which is strange >> in it self as it was not done in py2. That call goes into our swig extended >> python code which calls _get_parameter_keys. That call triggers a type >> miss-match for its self argument. This occurs for example when a class that >> are shared pointer stored is not properly marked as being a shared_ptr >> class. I see that dolfin::Parameters is indeed marked as being shared ptr >> stored, so it might be something else. >> >> You can try adding some print statements for self inside the __getitem__ >> method in dolfin/swig/parameters/post.i before calling >> _get_parameter_keys(). >> >> If you want me to check this out, can you please write a simple recipe >> for installing py3 alongside py2, I am on vacation and in particular I am >> in vacation-not-thinking-mode... >> >> Johan >> >> >> On Fri, Aug 1, 2014 at 10:45 AM, Martin Sandve Alnæs <[email protected]> >> wrote: >> >>> Note that you need the next branches of instant, fiat, ffc and master >>> branch of ufl to test Aslaks dolfin branch. >>> >>> I don't understand what's happening here, this is swig-generated code >>> which fails to match the python Parameters object with the C++ Parameters >>> type. >>> >>> Martin >>> >>> >>> On 1 August 2014 10:24, Aslak Bergersen <[email protected]> >>> wrote: >>> >>>> I'm trying to get dolfin to run with python 3. Previously this summer I >>>> have changed ffc, fiat, instant and ufl, which are now included in the >>>> master/next branches. >>>> >>>> Dolfin now builds for python 2 and 3, but for python 3 it fails to >>>> import from dolfin. You can find my code her: >>>> https://bitbucket.org/aslakbergersen/dolfin/branch/aslakbergersen/topic-prepare-py3 >>>> >>>> ''' >>>> Traceback (most recent call last): >>>> File "errorcontrol.py", line 26, in <module> >>>> from dolfin import * >>>> File >>>> "/home/aslak/Work/FEniCS/install_dir_py3/lib/python3.2/site-packages/dolfin/__init__.py", >>>> line 16, in <module> >>>> from . import cpp >>>> File >>>> "/home/aslak/Work/FEniCS/install_dir_py3/lib/python3.2/site-packages/dolfin/cpp/__init__.py", >>>> line 42, in <module> >>>> exec("from . import %s" % module_name) >>>> File "<string>", line 1, in <module> >>>> File >>>> "/home/aslak/Work/FEniCS/install_dir_py3/lib/python3.2/site-packages/dolfin/cpp/common.py", >>>> line 2458, in <module> >>>> class Event(object): >>>> File >>>> "/home/aslak/Work/FEniCS/install_dir_py3/lib/python3.2/site-packages/dolfin/cpp/common.py", >>>> line 2473, in Event >>>> thisown = _swig_property(lambda x: x.this.own(), lambda x, v: >>>> x.this.own(v), doc='The membership flag') >>>> File >>>> "/home/aslak/Work/FEniCS/install_dir_py3/lib/python3.2/site-packages/dolfin/cpp/common.py", >>>> line 2093, in __setitem__ >>>> if key not in self._get_parameter_keys(): >>>> TypeError: in method 'Parameters__get_parameter_keys', argument 1 of >>>> type 'dolfin::Parameters const * >>>> ''' >>>> >>>> There seems to be an error whith swig and the new C API for python. I'm >>>> using python 3.2 and swig 3.0.2. Does anyone have experience with this type >>>> of error? >>>> >>>> -- >>>> Mvh >>>> Aslak Bergersen >>>> 993 22 848 >>>> >>>> >>>> _______________________________________________ >>>> fenics mailing list >>>> [email protected] >>>> http://fenicsproject.org/mailman/listinfo/fenics >>>> >>>> >>> >>> _______________________________________________ >>> fenics mailing list >>> [email protected] >>> http://fenicsproject.org/mailman/listinfo/fenics >>> >>> >> >
_______________________________________________ fenics mailing list [email protected] http://fenicsproject.org/mailman/listinfo/fenics
