distutils source dist question

Thomas Heller theller at python.net
Thu Feb 28 03:13:12 EST 2002


"Skip Montanaro" <skip at pobox.com>:

> I have a small library consisting of three C source files:
>
>     alf.c
>     alf.h
>     alfmodule.c
>
> The first two files are a standalone library, while the third is an
> extension module wrapping the library.
>
> The naive "python setup.py install" command creates alfmodule.so and
> installs it in site-packages.  I'd like libalf.so or libalf.a to also get
> created and installed in ${prefix}/lib and alf.h to be installed in
> ${prefix}/include.  Can this be done with distutils or do I need to fall
> back to Makefile for this?

This (untested) script

setup(name="alf",
      ext_modules=[Extension("alf",
                             sources=["alfmodule.c"],
                             libraries=["libalf"]),
      libraries=[("libalf", {"sources": ["alfmodule.c"]})],
      headers=["alf.h"])

would probably get most what you want out of distutils,
but there are some problems.
It would build your library and your extension module,
it would install "alf.h" in the alf subdirectory of
${prefix}/include, it would *not* install the libalf
library in the python tree somewhere, and you would
have problems running the sdist command, because the clib
option is somewhat broken (this is even mentioned in the
docs).
All in all, it may be  a start...

Thomas





More information about the Python-list mailing list