[vtkusers] Python wrappers for new extensions developed withC++

Jordi Campos i Miralles jcampos at maia.ub.es
Fri Jun 15 05:06:32 EDT 2007


Thanks very much, it works fine! ;)


To "close the case" ;), is there any possibility to automate this
process throw CMake? Let me explain:

If I place the python script as a normal test in the Testing directory:

"Build/vtkLocal/Testing/Python/vtkLocalTest.py"

and modify the CMake files:

"Build/vtkLocal/Testing/CMakeLists.txt" = SUBDIRS(Cxx Python)

"Build/vtkLocal/Testing/Python/CMakeLists.txt" =
ADD_EXECUTABLE(vtkLocalTest.py vtkLocalTest.py)



I would expect to obtain:

the test distributed as other binaries:

"Build/vtkLocal/bin/vtkLocalTest.py"

and the shortcut to load the library simply with "import vtkLocal" also
in the binary directory:

"Build/vtkLocal/bin/vtkLocal.py" = "import os; if os.name == 'posix'..."


So, I would add "Build/vtkLocal/bin" to my PATH and PYTHONPATH, and
"vtkLocalTest.py" would work fine containing just "import vtkLocal".



BUT, I obtain:

 CMake Error: Cannot determine link language for target
"vtkLocalTest.py".


I "grepped" all the VTK/Examples directories looking for '.py' in
CMakeList.txt files, but I found nothing.

For sure, my "Build/vtkLocal/Testing/Python/CMakeLists.txt" is not
correct. And something should be added to automatically obtain
"Build/vtkLocal/bin/vtkLocal.py". But I cannot solve it until I receive
the CMake and VTK User's Guide books I ordered to our university
library ;)... (they say we have to wait almost three weeks...)


I guess this is a feasible situation when preparing projects that have
Cxx and Python code, isn't it?


Thanks again! It's been nice to see a really active vtkusers list. It
encourages me to ask my research group partners to give a chance to
VTK... ;)

jor;)i


El dj 14 de 06 del 2007 a les 14:24 -0400, en/na David Gobbi va
escriure:
> Hi Jordi,
> 
> If you were able to make libvtkLocalPython.so, then all you should have 
> left to do is set the pythonpath.
> 
> The file libvtkLocalPython.so is a python extension module, so it must 
> be in the PYTHONPATH before you can load it.  The PYTHONPATH isn't only 
> for .py files.
> 
> "
> export PYTHONPATH=./bin/
> "
> 
> Note that usually you should use the full absolute path, instead of a 
> relative path starting with "."
> 
>  - David
> 
> 
> 
> Jordi Campos i Miralles wrote:
> > Hi, 
> >
> > Is there any complete example like VTK/Examples/Build/vtkLocal but
> > including a Python test?
> >
> > I followed the indications of the standard example
> > VTK/Examples/Build/vtkLocal, but it only has a TCL example. I created a
> > simple filter in C++ as vtkLocalExample.h/cxx.
> >
> > I commented the "IF(VTK_WRAP_PYTHON)" line present in the CMakeList.txt
> > to be sure the "wrapper instructions" are executed.
> >
> > With a "make" I obtain the wrapper libs "bin/libvtkLocalPython.so" and
> > "bin/libvtkLocalPython.so", but I still need the way to load them from
> > my python example.
> >
> > If I try to do an "import vtkLocal" it does not work.
> >
> > I check the standard python wrappers an I tried with:
> >
> > "
> > import os
> >
> > if os.name == 'posix':
> >     from libvtkLocalPython import *
> > else:
> >     from vtkLocalPython import *
> > "
> >
> > and executed it with: 
> > "
> > LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./bin/ vtkpython test.py
> > "
> >
> > But I can't load the library. I guess I should update also the
> > PYTHONPATH, but I need some "library" .py ...
> >
> > What I'm doing wrong?
> >
> > Is there any complete example like VTK/Examples/Build/vtkLocal but
> > including a Python test?
> >
> > Thanks a lot!
> >
> > jor;)i
> >
> >
> > BTW: I'm preparing a tutorial for my research group partners about
> > Volume Rendering with VTK that can be found here:
> >
> > http://namaste.maia.ub.es/public/vtk-volume-rendering-tutorial.pdf
> >
> > Would it be possible to add the pdf to VTK Wiki when I finish it?
> >
> >
> >   
> 
-- 
Jordi Campos i Miralles
Departament de Matemàtica Aplicada i Anàlisi, MAiA
Facultat de Matemàtiques, Universitat de Barcelona
Gran Via de les Corts Catalanes, 585
08007 Barcelona
Telf : +34 93 403 93 72 




More information about the vtkusers mailing list