Presuming your Python extension foo
is intended to be used as a module, accessible via import foo
, you don't need to know what the filename extension should be on what operating system. You just use distutils
. You will get a .pyd on Windows, and a .so on Linux etc. Read this documentation.
Update in response to comment by @gecco
import foo is working both both extension types: dll and pyd. The extension does not matter here... :
For me (Python 2.7.1, Windows 7), python -vv
shows only pyd, py, pyw and pyc extensions (in that order) being searched. If I have foo.pyd
in C:\python27\lib\site-packages
, import foo
works. If I rename that file to foo.dll
, import foo
fails.