[vtkusers] Python 3 requires relative or correct absolute imports

David Gobbi david.gobbi at gmail.com
Tue Oct 6 11:21:03 EDT 2015


On Mon, Oct 5, 2015 at 8:29 AM, Matthias Blaicher <matthias at blaicher.com>
wrote:

> On 10/05/2015 04:17 PM, David Gobbi wrote:
> > On Mon, Oct 5, 2015 at 6:56 AM, Matthias Blaicher <matthias at blaicher.com
> > <mailto:matthias at blaicher.com>> wrote:
> >     However, this should obviously work without manually defining the
> search
> >     path. I propose to change the line to
> >
> >     > from vtk.vtkCommonCorePython import *
> >     or
> >     > from .vtkCommonCorePython import *
> >
> >
> > This assumes that the extension modules are installed in the same
> > directory as the pure-python modules, which (for me at least) is
> > generally not the case.  Often the extension modules are kept in
> > a platform-specific directory somewhere else in the path.
> >
> > Tonight I can look at the PEPs for this.
> >
> >  - David
> >
>
> Where would you put them for a system vtk installation? For both the
> python 2 and the python 3 build, by default they are installed into the
> site-packages directory. It feels to me that this is a good place to put
> them. It's just that the import rules changed for py3k.
>
> However you are right that both of my proposals would break your
> workflow. The only thing which comes to my mind is to separate the
> extension into its own (private) package.
>

I've looked over the guidelines for installing python modules, and it
seems that your original proposal was correct, i.e. the extension
modules should be placed in the same dir as the python files, which
would require either a) a relative import or b) placing the extension
modules one directory level up (which is messy).

The relative import breaks things for me when I try to use VTK from
the build directory (i.e. without doing a make install).

I have no immediate solution, but I'll think on this if I find any spare
time over the next couple days...

 - David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151006/191670f3/attachment.html>


More information about the vtkusers mailing list