[Numpy-discussion] NumPy, shared libraries and ctypes

Bill Baxter wbaxter at gmail.com
Tue Aug 8 19:22:37 CDT 2006


On 8/9/06, Albert Strasheim <fullung at gmail.com> wrote:
>
> Next caveat: on Windows, shared libraries aka DLLs, typically have a .dll
> extension. However, Python extensions have a .pyd extension.
>
> We have a utility function in NumPy called ctypes_load_library which
> handles
> finding and loading of shared libraries with ctypes. Currently, shared
> library extensions (.dll, .so, .dylib) are hardcoded in this function.
>
> I propose we modify this function to look something like this:
>
> def ctypes_load_library(libname, loader_path, distutils_hack=False):
>     ...
>
> If distutils_hack is True, instead of the default mechanism (which is
> currently hardcoded extensions), ctypes_load_library should do:
>
> import distutils.config
> so_ext = distutils.sysconfig.get_config_var('SO')
>
> to figure out the extension it should use to load shared libraries. This
> should make it reasonably easy for people to build shared libraries with
> distutils and use them with NumPy and ctypes.


Wouldn't it make more sense to just rename the .pyd generated by distutils
to .dll or .so?  Especially since the .pyd generated by distutils won't
actually be a python extension module.   This renaming could be automated by
a simple python script that wraps distutils.  The addition of the
init{modulename} function could also be done by that script.

--bb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060809/ba6c1814/attachment.html 


More information about the Numpy-discussion mailing list