Search code examples
python-3.xpython-importswig

swig-3.0.12 generates python2 style import statements


I am converting a large swig based codebase to python3. My current problem is that in-sub directories swig generates import statements as: 'import xxx' vs 'import dir_name.xxx'. The former causes import failures in python3.


Solution

  • In order to generate proper python3 imports, one has to define modules with package parameter:

    %module(package="package_name") module_name
    vs
    %module module_name
    

    Unfortunately, I could not find command-line or environment options to supply the package name at compile time.