[vtk-developers] import vtkmy* in Python

Eric E. Monson emonson at cs.duke.edu
Tue Jun 19 13:00:33 EDT 2012


Hey Mathieu,

You may have already found a solution, but I though I'd try to help, anyway.

(First, a note: it often works best to do an "out of source" build with CMake projects like this, where you create a separate "build" directory in the vtkMy directory and then run "ccmake .." This way you can easily do other builds with different options turned on, the libraries don't end up mixed with the source code, and it's often easier to deal with version control systems this way.)

I think the minimal thing you could do is to also add $HOME/vtkMy/bin to your $PYTHONPATH, and then you should be able to do 

from libvtkmyCommonPython import *

to get your wrapped classes into python.

For my work I've duplicated part of the system from VTK/Wrapping/Python so I can either install my new wrapped VTK classes in the typical Python install location with setuptools, or I can just set the PYTHONPATH env variable to my build directory (what I typically do) and get these into Python with a simple

import vtkMy

call. If you want more details on that setup you can take a look at my repository on github:

https://github.com/emonson/vtkVTG

Note that my setup doesn't all work with the current "modular" VTK development version, but it works fine with VTK 5.10. I'll get it updated to the dev version once the SIP VTK wrapping has been fixed.

Talk to you later,
-Eric

· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
Eric E Monson
Duke Visualization Technology Group


On Jun 11, 2012, at 9:09 AM, Mathieu Sornay wrote:

> Hello,
> 
> I have added some classes to VTK using the vtkMy mecanism (thanks for
> providing it btw).
> 
> First, I'm not sure I have fully understood the
> compilation/installation process. Here's what I do (VTK-5.8 on Debian)
> :
> - I copy the VTK/Example/Build/vtkMy directory in my $HOME.
> - I add my .h and .cxx in the Common subdir, and add them in
> Common/CMakeList.txt .
> - I run "ccmake .", "make" so libvtkmyCommon.so
> libvtkmyCommonPython.so and libvtkmyCommonPythonD.so are created in
> the bin/ sub directory.
> - I add $HOME/vtkMy/bin/ to $PATH and $LD_LIBRARY_PATH.
> 
>> From there, I'm able to compile C++ code if I use the following lines
> in my CMakeList.txt (but I suppose I'm doing it wrong...)
> - include_directories(~/vtkMy/Common/)
> - link_directories(~/vtkMy/bin/)
> 
> I'm not, however, able to import anything into Python.
> 
> I'm sure I'm missing something really obvious here, any help would be
> greatly appreciated.
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers




More information about the vtk-developers mailing list