[vtk-developers] python wrapping

Berk Geveci berk.geveci at kitware.com
Fri Mar 13 15:52:22 EDT 2009


The VTK Wiki is probably a better place for this. Unlike the ParaView
developer Wiki, it is public. Would you mind moving it there?

-berk

On Fri, Mar 13, 2009 at 12:04 PM, Burlen Loring
<burlen.loring at kitware.com> wrote:
> Thank you and also to Dave for all of the information. I collected this on
> the following Wiki.
>
> http://www.paraview.org/ParaView3/index.php/Python_Wrapping_FAQ
>
>
> Prabhu Ramachandran wrote:
>>
>> On 03/10/09 23:02, Burlen Loring wrote:
>>>
>>> I'd like to understand more about how the VTK python wrapping works. Can
>>> anyone recommend a starting point? Also of interest what CMake's role in
>>> this is. What macros available, when to use such and such a macro, what the
>>> purpose of arguments to the macros are?
>>
>> Here is a quick overview (it has been a while so I may be off, I'll let
>> others correct):
>>
>>  0. Big picture: All the automated wrapping code generation relies on the
>> consistent coding style followed in the VTK header files and the use of the
>> convenience macros. Specific markers (in comments) in the header mark parts
>> that are not to be parsed (BTX/ETX). Basically, a target language specific
>> parser parses the header file figures out suitable wrapper functions in the
>> desired target language and spits out the wrapper code that is used to
>> generate the wrappings.
>>
>>  1. First look in VTK/Wrapping.  Go over the files there.  Specifically
>> look at vtkWrapPython.c which actually does the code generation for Python.
>>
>>  2. When VTK is built, an executable called vtkWrapPython is built from
>> this.
>>
>>  3. vtkWrapPython generates the Python wrappers for each wrappable VTK
>> header and this is built to generate the Python wrapper.
>>
>>  4. The wrapper code makes use of Common/vtkPython.h
>> Common/vtkPythonUtil.cxx  and Common/vtkPythonUtil.h for various things.
>> Also note that Wrapping/hints is a mechanism for helping the wrapper code
>> with, err, hints to help the wrapping process along.  To see what the
>> individual codes represent see Wrapping/vtkParse.y and vtkParse.tab.c
>>
>>  5. The VTK module for the vtk Python package is all in
>> Wrapping/Python/vtk.  There is a rambling README in Wrapping/Python that
>> might be of some use. There is also a nice README_WRAP.txt in the same
>> directory that is useful.
>>
>> I think that should give you a pretty solid start.
>>
>> I think all CMake does is to build the parser and organize the building of
>> the generated code, link it correctly (which can be a bloody pain) etc.  I
>> don't think it directly does anything regarding the wrapper generation
>> process.  Any useful CMake macros are best gleaned by looking at CMake files
>> (at least thats how I used to do it).
>>
>> HTH.
>>
>> cheers,
>> prabhu
>
> _______________________________________________
> 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