Prevent some C++ code from being wrapped for Python

Hello,

I have some code I’d like to NOT wrap in Python. In my extension’s MRML directory, I created some “internal” classes that should ideally not be exposed to the user. I’ve been looking at 3 options:

  • A preprocessor defined value I could use to surround the code I don’t need to wrap using #if and #endif. I couldn’t find anything obvious on google nor using grep on the Slicer and VTK source trees.
  • Exclude a full file using CMake source file properties. I tried set_source_files_properties with WRAP_EXCLUDE_PYTHON 1 but the xxxPython.cxx file is still generated and compiled.
  • The third option I can think of is to create a separate library to hide all my private classes. I haven’t tried yet. I fear the CMake part is not going to be trivial since I will need to compile and link against VTK/Slicer libraries but the Slicer CMake macros will likely enable Python wrapping.

Any thoughts before I go deeper in this rabbit hole?

Thanks

You can skip the .h in CMakeLists.txt file (only include the .cxx) to prevent classes showing up in Python. However, I would recommend to wrap all Python classes, even if users are not expected to use them, because they may be important for you (or for your users) for testing and troubleshooting (and you may decide later to use these classes from Python).