[vtk-developers] import vtkmy* in Python

Mathieu Sornay msornay at gmail.com
Wed Jun 20 08:07:27 EDT 2012


Nevermind, I'm dumb.
Thanks again for your help, everything works fine !

On 6/20/12, Mathieu Sornay <msornay at gmail.com> wrote:
> Hi Eric,
>
> Thank you very much for your response, I had not managed to solve my
> problem.
>
> Following your instructions I was able to import my classes into Python,
> yeah !
> However, I can't make it work using $PYTHONPATH (my successful import
> was with vtkMy-build/bin/ as the current working directory...)
> I simply did an out-of-source build and :
> # export PYTHONPATH=$PYTHONPATH:~/vtkMy-build/bin
> An import from python gives a "No modules named
> libvtkmyCommonPython..." (The .so is there).
>
> I'm using Debian, Python 2.6 and VTK 5.8. Any idea ?
>
> On 6/19/12, Eric E. Monson <emonson at cs.duke.edu> wrote:
>> 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