[Numpy-discussion] OT? Distutils extension with shared libs

David Cournapeau cournape@gmail....
Tue Jul 6 19:44:12 CDT 2010

On Wed, Jul 7, 2010 at 12:34 AM,  <silva@lma.cnrs-mrs.fr> wrote:
> More precisely, the constructor provides C source code to access data
> and metadata with files ReadIM{7,x}.{c.h}.
> I wrote a tiny ctypes wrappers in order to have a object-oriented
> class in python that handling reading the data files written by the
> constructor software.
> One issue is that ReadIM7.h includes zlib.h. On linux, it is easy to
> install zlib-dev package. All is simple, as it is installed in
> standard repertory. On windows of course no standards. How would you
> then proceed? Do I have to distribute zlib.h, and also zconf.h,
> zlib.lib, libz.a and libz.dll.a needed to get it work ?

Three solutions:
 - ask your users to build the software and install zlib by
themselves. On windows, I am afraid it means you concretely limit your
userbase to practically 0.
 - build zlib as part of the build process, and keep zlib internally.
 - include a copy of the zlib library (the binary) in the tarball.

> Other issue: with all these files in ./src, I have the following
> configuration:
>     ext = Extension('_im7',
>         sources=['src/ReadIM7.cpp', 'src/ReadIMX.cpp'],
>         include_dirs=['src'],\
>         libraries=['zlib',],\
>         library_dirs=['src'],\
>         define_macros=[('_WIN32', None), ('BUILD_DLL', None)], \
>         extra_compile_args=['-ansi', '-pedantic', '-g', '-v'])
> it builds a _im7.pyd file that ctypes is not able to load as it
> expects a _im7.dll file with
> ctypes.cdll.loadlibrary('_im7')...

You cannot build a library loadable with ctypes with distutils nor
numpy.distutils. You need to implement it in distutils, or copy the
code from one of the project which implemented it



More information about the NumPy-Discussion mailing list