Swig generated modules use relative imports which fails with python 3

Issue #363 resolved
Martin Sandve Alnæs created an issue

There's a bug in swig which makes it tricky to fix this the 'right way', and @johanhake has submitted a patch to swig fixing that bug.

The error looks like this:

Traceback (most recent call last):
  File "test.py", line 30, in <module>
    from dolfin import has_mpi, has_parmetis, has_scotch, has_linear_algebra_backend
  File "/home/buildbot/fenicsbbot/next/dolfin-full/lib/python3.4/site-packages/dolfin/__init__.py", line 16, in <module>
    from . import cpp
  File "/home/buildbot/fenicsbbot/next/dolfin-full/lib/python3.4/site-packages/dolfin/cpp/__init__.py", line 42, in <module>
    exec("from . import %s" % module_name)
  File "<string>", line 1, in <module>
  File "/home/buildbot/fenicsbbot/next/dolfin-full/lib/python3.4/site-packages/dolfin/cpp/la.py", line 111, in <module>
    import common
ImportError: No module named 'common'

@johanhake: since you apparently know a way to hack around this problem for now, can you apply that fix? All dolfin/py3 work so far is now in master.

Comments (5)

  1. Johan Hake

    The proposed fix is now in upstream SWIG master and will be available with the next release of SWIG, i.e. 3.0.3.

  2. Log in to comment