Skip to content Skip to sidebar Skip to footer

Using Cython Extension Once Compiled [under Windows], How To Use .pyd's?

I am used with compiling self-made python extensions under Linux using Cython. On Linux, I use distutils to produce a 'myext.so', that I can then simply add to my PYTHONPATH and ge

Solution 1:

It's clearly written in the documentation you linked:

Note that the search path for foo.pyd is PYTHONPATH, not the same as the path that Windows uses to search for foo.dll. Also, foo.pyd need not be present to run your program, whereas if you linked your program with a dll, the dll is required. Of course, foo.pyd is required if you want to say import foo. In a DLL, linkage is declared in the source code with __declspec(dllexport). In a .pyd, linkage is defined in a list of available functions.

So you should either place your .pyd file inside the python's installation directories(site-packages), or you can modify the environmental variable PYTHONPATH and add the directory where the .pyd is placed.

Yet an other alternative is to use .pth files to extend the PYTHONPATH.

Post a Comment for "Using Cython Extension Once Compiled [under Windows], How To Use .pyd's?"