[vtkusers] Python 3 requires relative or correct absolute imports

David Gobbi david.gobbi at gmail.com
Wed Oct 7 11:33:57 EDT 2015


On Tue, Oct 6, 2015 at 12:06 PM, Ben Boeckel <ben.boeckel at kitware.com>
wrote:

>
> All of VTK's modules should go to the archful directory (/usr/lib64 or
> /usr/lib/$triple). The .py files don't work without the .so files, so
> they all go to the same directory (e.g., on Fedora,
> /usr/lib64/python2.7/site-packages/vtk/*).
>
> Python 3.3 introduced namespace packages where you can split a module
> over multiple directories, but this is generally intended for the "find
> all submodules of foo" use case for plugins where the foo package has a
> presence on the archless and archful system directories as well as
> $PYTHONPATH. But this is not the use case for VTK, so dropping the .py
> files beside the .so files should be the way to go.
>

Yes, the best way forward is probably to make it so that, during the build,
the Python .so modules go to "${VTK_BUILD_DIR}/Wrapping/Python/vtk/".
Currently the build drops them into the "lib" dir, but they're not
libraries.

We could also make the python "vtk" module more efficient by dropping
the useless ".py" files (vtkCommonCore.py et al).  These files only exist
because, historically (many many years ago), the VTK python extension
modules were named differently on Windows as compared to UNIX.  It
would make more sense for vtk/__init__.py to load the .so files directly.

There is also an opportunity to rename the files.  Instead of this:

   vtkCommonCorePython.so

for VTK 7 we could change the name to one of these:

   vtkCommonCore.so  or simply CommonCore.so

I'm a fan the former, for the sake of backwards compatibility.  In any case,
once the build location is moved, setting up the relative imports for Py3k
builds is trivial.

 - David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151007/6ce8399c/attachment.html>


More information about the vtkusers mailing list