# Compiling custom VTK extension with python wrapper

**URL:** https://discourse.vtk.org/t/compiling-custom-vtk-extension-with-python-wrapper/6427
**Category:** Support
**Created:** [August 19, 2021, 10:28am UTC](https://discourse.vtk.org/t/compiling-custom-vtk-extension-with-python-wrapper/6427 "2021-08-19T10:28:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Korijn](https://discourse.vtk.org/user_avatar/discourse.vtk.org/korijn/32/3834_2.png) [@Korijn](https://discourse.vtk.org/u/Korijn)
#### Post date: [August 19, 2021, 10:28am UTC](https://discourse.vtk.org/t/compiling-custom-vtk-extension-with-python-wrapper/6427/1 "2021-08-19T10:28:24Z")

</div>

I am working to compile a [custom VTK extension](https://github.com/ClinicalGraphics/u3d/tree/master/Samples/SampleCode) with python wrappers, and am trying to figure out how to do it with the new VTK 9 cmake build system.

I must admit I am in a little bit over my head, and am hoping to receive some general guidance and/or references to other projects that have to overcome the same challenges. Any tips?

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [August 19, 2021, 12:59pm UTC](https://discourse.vtk.org/t/compiling-custom-vtk-extension-with-python-wrapper/6427/2 "2021-08-19T12:59:26Z")

</div>

In VTK 9, wrapping is done on a per-module basis, so the code that is to be wrapped must be arranged so that VTK can see it as a “module”, e.g.:

```bash
CMakeLists.txt # the cmake file that calls the cmake module macros
YourModule/ # the module directory
    vtk.module # the "module file", contains info about the module
    CMakeLists.txt # the module's CMakeLists.txt file
    vtkSomeClass.h # a header to be wrapped
    vtkSomeClass.cxx
    ...

```

A sample can be found in [Examples/Modules/Wrapping](https://gitlab.kitware.com/vtk/vtk/-/tree/master/Examples/Modules/Wrapping/module).
