[vtk-developers] Patch to vtkWrapPython.c to make wrapped Python code GIL-friendly

Sander Niemeijer niemeijer at science-and-technology.nl
Wed Jul 13 17:43:31 EDT 2005


On woensdag, jul 13, 2005, at 21:24 Europe/Amsterdam, Charl P. Botha 
wrote:

> On 7/13/05, David Cole <david.cole at kitware.com> wrote:
>> It's always best to prevent crashing in the first place... right? You
>> could use a CMake construct like this:
>>   GET_FILENAME_COMPONENT(LIBNAME ${PYTHON_LIBRARY} NAME_WE)
>>   STRING(REGEX REPLACE "python" "" LIBVER "${LIBNAME}")
>>   IF(LIBVER LESS 23)
>>     MESSAGE(SEND_ERROR "VTK_WRAP_PYTHON requires a minimum of Python
>> version 2.3.\nUpgrade python or set VTK_WRAP_PYTHON to OFF to avoid 
>> this
>> error.")
>>   ENDIF(LIBVER LESS 23)
>>
>> ...if the following hold true:
>> VTK_WRAP_PYTHON is ON
>> PYTHON_LIBRARY is found/set
>> python libs are always named pythonNN where NN can be legally compared
>> to a value like 23... (Assuming future Python 3.0 will be named
>> python30.lib/a/so/dll...)
>
> This would force everybody to upgrade to python 2.3, which is not
> always practical.

I agree. It is still possible to use VTK with elder versions of Python 
as long as threading is disabled.

> Perhaps this check could be combined with threading
> on/off, i.e. if someone has a python < 2.3 and wants python wrappings,
> threading has to be deactivated.

This can be tricky since threading needs to be turned off in both VTK 
_and_ Python.
If you want to add a check for threading then you should also check 
whether Python was build without threading support otherwise things may 
still break.

Best regards,
Sander




More information about the vtk-developers mailing list