How to get Python Script -> Cython -> Blender

Hi, i’m trying to convert my Particle Fluid Tools to Cython. I just can’t find any good information about how to do that, so far.
I am able to convert it to “xxx.c” file. But then? I don’t see the Way.

I think it could be something like compile Blender with “xxx.c” file (how?) and then import as module?

And, since my Addon has UI… which probably don’t work as .c or .so. Would i have to Cython only the “Calculations” Part and load this in script?

As you can see, i don’t really have a Plan what i’m doing :slight_smile:

Some Ideas, Links to Cython (Tutorial) or even Blender+Cython would be much appreciated. thanks

EDIT: I’m able to make .so file, but can’t import it as python module. I have a simple “” with “import test”(name of at the same place as…

EDIT2: I’ve put both files into Blenders Addon Folder. In Python Console: import test=

Traceback (most recent call last):
File “<blender_console>”, line 1, in <module>
ImportError: dlopen(/Volumes/MacintoshBig/DATA/Users/bashi/Library/Application Support/Blender/2.62/scripts/addons/, 2): Symbol not found: _PyClass_Type
Referenced from: /Volumes/MacintoshBig/DATA/Users/bashi/Library/Application Support/Blender/2.62/scripts/addons/
Expected in: flat namespace
in /Volumes/MacintoshBig/DATA/Users/bashi/Library/Application Support/Blender/2.62/scripts/addons/


I’m a Cython fanboy, and I already used Cython compiled modules in Blender. This is how I do:

To test, I don’t move .so file in blender directory. Try to open a python console inside blender and type:

import sys

You’ll see a list of directories where Blender can find modules. So, append your developpement directory, for exemple “/My/Dev/Dir”

In My/Dev/Dir, you SHOULD have you .so file (and not your .py file). To be sure, I put a “build” directory where I move my .so file. So in fact, you shoud have /My/Dev/Dir/build path and /My/Dev/Dir/build/


So try to import your module, it should work. If not, check path and try to call your module again…

PS: to compile my module, on linux, I use:
gcc mymod.c -o build/ -fPIC $(pkg-config --cflags --libs)

The “real” command is:
gcc mymod.c -o build/ -fPIC --I/usr/include/python3.2mu -lpython3.2mu

The nice feature with Cython is that you can develop in the old python 2.x way, it works with python 3 :slight_smile:

hey Metal3d, thank you.

i will try it when i have time to work on my script again. thanks.